Пример #1
0
def do_refresh_series(series_id_str, config, debug):
    try:
        thetvdb = TheTvDb(config, debug)
        database = Database(config, debug)

        try:
            series_id = int(series_id_str)
        except:
            print "Argument is not a valid series id: %s" % (series_id_str, )
            return 1

        series = database.get_series(series_id)
        if series is not None:
            new_series = thetvdb.get_series_info(series.id)
            new_series.watch = series.watch

            database.clear_series(series.id)
            database.clear_all_episodes(series.id)

            database.add_series(new_series)
            episodes = get_episodes(thetvdb, database, new_series)
        else:
            new_series = thetvdb.get_series_info(series_id)
            series = new_series

            database.add_series(new_series)
            episodes = get_episodes(thetvdb, database, new_series)

        print "Metadata for series '%s' and its episodes has been cleared from the local cache and reloaded from TheTvDb.com." % (series.title, )
        return 0
    except:
        traceback.print_exc()
        return 11
Пример #2
0
def watch_series_guts(series_id_str, watch, config, debug):
    try:
        thetvdb = TheTvDb(config, debug)
        database = Database(config, debug)

        try:
            series_id = int(series_id_str)
        except:
            print "Argument is not a valid series id: %s" % (series_id_str, )
            return 2

        series = database.get_series(series_id)
        if series is None:
            series = thetvdb.get_series_info(series_id)
            if series is not None:
                database.add_series(series)

        if not series is None:
            database.watch_series(series, watch)
            return 0
        else:
            print "No series with id '%i' exists in the local cache.  Did you lookup the series?" % (series_id,)
            return 3
    except:
        traceback.print_exc()
        return 11
Пример #3
0
def do_episode_lookup(episode_search_pattern, config, debug):
    try:
        thetvdb = TheTvDb(config, debug)
        database = Database(config, debug)

        split_pattern = episode_search_pattern.split(':')

        if len(split_pattern) < 1 or len(split_pattern) > 3:
            print "Search pattern must be of the form series_id[:season_number[:episode_number]]"
            return 1

        series_id = split_pattern[0]
        series = database.get_series(series_id)
        if series is None:
            print "No series with id '%i' exists in the local cache.  Did you lookup the series?" % (series_id,)
            return 2

        existing_episode_list = database.get_all_episodes(series_id)
        if len(existing_episode_list) == 0:
            all_episodes = thetvdb.get_full_episode_list(series)
            for e in all_episodes:
                database.add_episode(e, series)


        if len(split_pattern) == 1:
            print_episodes(database.get_all_episodes(series_id))
        elif len(split_pattern) == 2:
            season = int(split_pattern[1])
            print_episodes(database.get_episodes(series_id, season))
        elif len(split_pattern) == 3:
            season = int(split_pattern[1])
            episode = int(split_pattern[2])

            result = get_specific_episode(thetvdb, database, series, season, episode)
            if result is None:
                print "Could not locate an episode matching pattern: %s" % (episode_search_pattern, )
                return 3

            print_episodes([result])

        return 0 
    except:
        traceback.print_exc()
        return 11
Пример #4
0
def do_clear_series(series_id_str, config, debug):
    try:
        database = Database(config, debug)

        try:
            series_id = int(series_id_str)
        except:
            print "Argument is not a valid series id: %s" % (series_id_str, )
            return 1

        series = database.get_series(series_id)
        if not series is None:
            database.clear_all_episodes(series.id)
            database.clear_series(series.id)
            print "Series '%s' and all of its episodes have been cleared from the local cache." % (series.title, )
            return 0
        else:
            print "No series with id '%i' exists in the local cache." % (series_id,)
            return 3
    except:
        traceback.print_exc()
        return 11
Пример #5
0
def do_clear_episodes(series_id_str, config, debug):
    try:
        thetvdb = TheTvDb(config, debug)
        database = Database(config, debug)

        try:
            series_id = int(series_id_str)
        except:
            print "Argument is not a valid series id: %s" % (series_id_str, )
            return 1

        series = database.get_series(series_id)
        if not series is None:
            database.clear_all_episodes(series.id)
            print "All episodes of series '%s' have been cleared from the local cache." % (series.title, )
            return 0
        else:
            print "No series with id '%i' exists in the local cache.  Did you lookup the series?" % (series_id,)
            return 3
    except:
        traceback.print_exc()
        return 11