예제 #1
0
파일: admin.py 프로젝트: ekohl/next
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)
예제 #2
0
파일: tui.py 프로젝트: ekohl/next
    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(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)
예제 #3
0
파일: player.py 프로젝트: ekohl/next
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}!'.format(S=show.season, E=show.ep, name=show.name)
        return
    command = cmd_line.split(' ') + [ep_path]
    #play the show
    print u'Starting S{S:02}E{E:02} of {name}!'.format(S=show.season, E=show.ep, name=show.name)
    try:
        print " ".join(command)
        subprocess.call(command)
    except KeyboardInterrupt:
        sys.stdout.flush()
        time.sleep(1) #give the movie player some time to clean up
    except OSError:
        # maybe the player isn't installed or something?
        print u'An error occurred while starting the player, check your config!'
        return

    #update the db
    print u'Should I update the database for you?'
    answer = raw_input(u'Update [yes]? ')
    if u'y' in answer.lower() or answer == '':
        next_ep = admin.find_next_ep(conf, show)
        if next_ep:
            db.change_show(conf, show.sid, next_ep.season, next_ep.epnum)
        else:
            print u'No information about new eps yet, try updating later!'
            db.mark_maybe_finished(conf, show.sid)
        print u'Player stopped, database updated.'
    else:
        print u'Database unmodified.'