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
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
def do_series_lookup(name, config, debug): try: thetvdb = TheTvDb(config, debug) database = Database(config, debug) results = thetvdb.lookup_series_info(name) for r in results: database.add_series(r) print "%i: %s" % (r.id, r.title) return 0 except: traceback.print_exc() return 11