def add_show_watchlist(self): """Add show to Trakt watchlist. It will add all shows from Medusa library """ if not (app.TRAKT_SYNC_WATCHLIST and app.USE_TRAKT): return if not app.showList: return trakt_show_objects = [] for show_obj in app.showList: if not self._check_list(show_obj=show_obj, list_type='Show'): log.info("Adding show '{show}' to Trakt watchlist", {'show': show_obj.name}) trakt_show_objects.append(create_show_structure(show_obj)) if trakt_show_objects: try: sync.add_to_watchlist({'shows': trakt_show_objects}) except TraktException as error: log.info( 'Unable to add shows to Trakt watchlist. Error: {error!r}', {'error': error}) self._get_show_watchlist()
def add_episode_watchlist(self): """Add episode to Tratk watchlist.""" if not (app.TRAKT_SYNC_WATCHLIST and app.USE_TRAKT): return main_db_con = db.DBConnection() statuses = [SNATCHED, SNATCHED_BEST, SNATCHED_PROPER, WANTED] sql_selection = 'SELECT s.indexer, s.startyear, s.indexer_id, s.show_name, e.season, e.episode ' \ 'FROM tv_episodes AS e, tv_shows AS s ' \ 'WHERE e.indexer = s.indexer AND s.indexer_id = e.showid AND s.paused = 0 ' \ 'AND e.status in ({0})'.format(','.join(['?'] * len(statuses))) sql_result = main_db_con.select(sql_selection, statuses) if not sql_result: return episodes = [] shows = {} for cur_episode in sql_result: # Check if TRAKT supports that indexer if not get_trakt_indexer(cur_episode['indexer']): continue show_id = cur_episode['indexer'], cur_episode['indexer_id'] episode = cur_episode['season'], cur_episode['episode'] if show_id not in shows: shows[show_id] = [] shows[show_id].append(episode) media_object_shows = [] for show_id in shows: episodes = [] show_obj = Show.find_by_id(app.showList, show_id[0], show_id[1]) for season, episode in shows[show_id]: if not self._check_list(indexer=show_obj.indexer, indexer_id=show_obj.series_id, season=season, episode=episode, list_type='Collection'): continue log.info("Adding episode '{show}' {ep} to Trakt watchlist", { 'show': show_obj.name, 'ep': episode_num(season, episode) }) episodes.append(show_obj.get_episode(season, episode)) media_object_shows.append( create_episode_structure(show_obj, episodes)) try: sync.add_to_watchlist({'shows': media_object_shows}) self._get_episode_watchlist() except TraktException as error: log.info( 'Unable to add episode to Trakt watchlist. Error: {error!r}', {'error': error})
def update_watchlist_episode(show_obj, episodes, remove=False): """ Use Trakt sync/watchlist to updata an episode. As we want to prevent Trakt.tv api rate limiting. Try to use the array of episodes as much as possible. :param episodes: An episode object or array of episode objects. """ try: if remove: result = sync.remove_from_watchlist( {'shows': [create_episode_structure(show_obj, episodes)]}) else: result = sync.add_to_watchlist( {'shows': [create_episode_structure(show_obj, episodes)]}) except (TraktException, RequestException) as error: log.warning('Unable to update Trakt watchlist: {error!r}', {'error': error}) return False if result and (result.get('added') or result.get('existing')): if result['added']['episodes']: return True return False
def update_watchlist_show(show_obj, remove=False): """Use Trakt sync/watchlist to updata a show.""" trakt_media_object = {'shows': [create_show_structure(show_obj)]} try: if remove: result = sync.remove_from_watchlist(trakt_media_object) else: result = sync.add_to_watchlist(trakt_media_object) except (TraktException, RequestException) as error: log.warning('Unable to update Trakt: {error!r}', {'error': error}) return False if result and (result.get('added') or result.get('existing')): if result['added']['shows']: return True return False
def add_to_watchlist(self): """Add this :class:`TVEpisode` to your watchlist""" add_to_watchlist(self)
def add_to_watchlist(self): """Add this :class:`TVShow` to your watchlist""" add_to_watchlist(self)
def add_to_watchlist(self): """Add this :class:`Movie` to your watchlist""" add_to_watchlist(self)