コード例 #1
0
ファイル: tui.py プロジェクト: ekohl/next
    def add_show_details(self, show):
        '''
        A helper function that is used (amongst others) by the add_show function to
        query the user as to what season and episode the user is
        '''
        #found out which season and ep the user is
        showname = show[0]
        sid = show[1]
        seasons = db.find_seasons(self.conf, sid)

        #then the season in the show
        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(showname, 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, 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
        try:
            db.add_show(self.conf, sid, showname, season, ep)
            print u'Successfully added {0} to the database!'.format(showname)
        except sqlite3.IntegrityError:
            print u'Show already exists, use change command to change season and ep!'
コード例 #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)