code: def keep_episodes(show, keep):
      
      deleted = 0
      print('%s Cleaning %s to %s episodes.' % (datestr(), show.title, keep))
      sort = lambda x:x.originallyAvailableAt or x.addedAt
      items = sorted(show.episodes(), key=sort, reverse=True)
      for episode in items[keep:]:
          delete_episode(episode)
          deleted += 1
      return deleted
docs: Delete all but last count episodes in show.