def find_unlisted(conf): ''' This method searches in your shows folder for shows that aren't in the database yet ''' listed = map(lambda x : x.name, db.all_shows(conf)) basedir = os.path.expanduser(conf['show_path']) all_shows = filter(lambda x : os.path.isdir(os.path.join(basedir, x)), os.listdir(basedir)) return list(set(all_shows) - set(listed))
def do_random(self, line=None): ''' A TUI function that plays a new ep from a random show ''' all_shows = db.all_shows(self.conf) if not all_shows: print u'There are no shows to play!' return s = db.find_show(self.conf, random.choice(all_shows).name) player.play_next(self.conf, s)
def do_add_show_location(self, line=None): ''' A TUI function that adds a custom location to a show. Can be used if shows are spread across the disk instead of centrally located. ''' all_shows = db.all_shows(self.conf) if not all_shows: print u'There are no shows to add a location for!' return print u'Which show would you like to add a location for?' print_shows(all_shows) number = int(get_input(u'Show number: ', range(1, len(all_shows) + 1))) show = all_shows[number - 1] print u'What location do you want to add?' location = get_input(u'Location: ') db.add_location(self.conf, show.sid, location)
def update_eps(conf): ''' This method updates the eplist for a given show using the TVRage database ''' #first we check tvr to see if there are any updates for our shows print "Updating TVRage episode database...", all_shows = db.all_shows(conf) try: for show in all_shows: all_eps = parser.get_all_eps(show.sid) db.store_tvr_eps(conf, all_eps) except:#probably no internet connection print "Could not connect to TVRage, aborting update!" return process_maybe_finished(conf, all_shows) print "done."
def do_play(self, line=None): ''' A TUI function that plays a new episode from the user-specified show ''' all_shows = db.all_shows(self.conf) if not all_shows: print u'There are no shows to play!' return if line: candidates = filter(lambda s : set(line.split()) <= set(s.name.lower().split()), all_shows) if not candidates: print u'No show found for "{0}"'.format(line) return #just assume the first show show = candidates[0] else: print u'Which show would you like to play the next ep from?' print_shows(all_shows) number = int(get_input(u'Show number: ', range(1, len(all_shows) + 1))) show = all_shows[number - 1] if show: player.play_next(self.conf, show)
def get_all_shows(self): shows = db.all_shows(self.conf) if not shows: raise NoShowsException return shows