def play_next(conf, show): ''' This method plays the next episode for the given show. ''' cmd_line = conf[ConfKeys.PLAYER_CMD] ep_path = build_ep_path(conf, show) if not ep_path: print u'Could not find s{S:02d}e{E:02d} for {name}, ep not available or marked maybe_finished?'.format(S=show.season, E=show.ep, name=show.name) return command = cmd_line.split(' ') + [ep_path] if not play(command, show): return #update the db print u'Should I update the database for you?' try: answer = raw_input(u'Update [yes]? ') if u'y' in answer.lower() or answer.strip() == '': next_ep = admin.find_next_ep(conf, show) if next_ep: db.change_show(conf, show.sid, next_ep.season, next_ep.epnum) show.season = next_ep.season show.ep = next_ep.epnum else: print u'No information about new eps yet, try updating later!' db.mark_maybe_finished(conf, show.sid) return show except: print '' print u'Database unmodified.' return
def process_maybe_finished(conf, all_shows): ''' This method walks over all the shows that are marked maybe_finished, to find out if they're really finished or if the database was just outdated. If a new ep can be found for the given show, this is set as the current ep and the maybe_finished mark is removed ''' for show in all_shows: if show.maybe_finished: next_ep = find_next_ep(conf, show) if next_ep: db.change_show(conf, show.sid, next_ep.season, next_ep.epnum) db.mark_not_maybe_finished(conf, show.sid)
def do_change_show(self, line=None): ''' A TUI function used to change the season and episode of a show where the user is ''' try: all_shows = self.get_all_shows() except NoShowsException: print u'There are no shows to change!' return print u'Which show would you like to change?' print_shows(self.conf, all_shows) number = int(get_input(u'Show number: ', range(1, len(all_shows) + 1))) show = all_shows[number - 1] #then the season in the show seasons = db.find_seasons(self.conf, show.sid) if not seasons: print u'There are no seasons for this show!' return print u'What season are you at for {0} ({1}-{2})?'.format(show.name, min(seasons), max(seasons)) season = int(get_input(u'Season: ', range(1, len(seasons) + 1))) #then the ep in the season eps = db.find_all_eps(self.conf, show.sid, season) if not eps: print u'This season has no eps!' return print u'What ep are you at in season {0}?'.format(season) for (i, ep) in enumerate(eps): print u'{id:3d}. s{S:>02d}e{E:>02d} - {title}'.format(id=i + 1, S=ep.season, E=ep.epnum, title=ep.title) ep = int(get_input(u'Episode: ', range(1, len(eps) + 1))) #and finally put everything in the database db.change_show(self.conf, show.sid, season, ep) print u'Successfully changed details for {0}!'.format(show.name)