コード例 #1
0
ファイル: tui.py プロジェクト: Sakartu/next
 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)
コード例 #2
0
ファイル: admin.py プロジェクト: Sakartu/next
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'])
    try:
        all_shows = [ d for d in os.listdir(basedir) if os.path.isdir(os.path.join(basedir, d)) ]
    except OSError:
        print "Could not list directory {0}".format(basedir)
        all_shows = []

    has_match = lambda s: any(x for x in listed if shows_match(s, x))
    return [ s for s in all_shows if not has_match(s) ]
コード例 #3
0
ファイル: tui.py プロジェクト: Sakartu/next
 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(self.conf, 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)
コード例 #4
0
ファイル: admin.py プロジェクト: Sakartu/next
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:
            print '.',
            status = parser.get_status(show.sid)
            all_eps = parser.get_all_eps(show.sid)
            db.change_status(conf, show.sid, status)
            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."
コード例 #5
0
ファイル: tui.py プロジェクト: Sakartu/next
    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(self.conf, all_shows)
            number = int(get_input(u'Show number: ', range(1, len(all_shows) + 1)))
            show = all_shows[number - 1]

        if show:
            player.play_show(self.conf, show)
コード例 #6
0
ファイル: tui.py プロジェクト: Sakartu/next
 def get_all_shows(self):
     shows = db.all_shows(self.conf)
     if not shows:
         raise NoShowsException
     return shows