Exemple #1
0
    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
Exemple #2
0
    def update_library(ep_obj):
        """Send a request to trakt indicating that the given episode is part of our library.

        ep_obj: The Episode object to add to trakt
        """
        # Check if TRAKT supports that indexer
        if not get_trakt_indexer(ep_obj.series.indexer):
            return

        if app.USE_TRAKT:
            try:
                # URL parameters
                title = get_title_without_year(ep_obj.series.name,
                                               ep_obj.series.start_year)
                data = {
                    'shows': [{
                        'title': title,
                        'year': ep_obj.series.start_year,
                        'ids': {},
                    }]
                }

                data['shows'][0]['ids'][get_trakt_indexer(
                    ep_obj.series.indexer)] = ep_obj.series.indexerid

                # Add Season and Episode + Related Episodes
                data['shows'][0]['seasons'] = [{
                    'number': ep_obj.season,
                    'episodes': []
                }]

                for rel_ep_obj in [ep_obj] + ep_obj.related_episodes:
                    data['shows'][0]['seasons'][0]['episodes'].append(
                        {'number': rel_ep_obj.episode})

                if app.TRAKT_SYNC_WATCHLIST:
                    if app.TRAKT_REMOVE_SERIESLIST:
                        sync.remove_from_watchlist(data)

                # update library
                sync.add_to_collection(data)
            except (TraktException, RequestException) as error:
                log.warning('Unable to update Trakt: {error!r}',
                            {'error': error})
Exemple #3
0
    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
Exemple #4
0
 def remove_from_watchlist(self):
     """Remove this :class:`TVEpisode` from your watchlist"""
     remove_from_watchlist(self)
Exemple #5
0
 def remove_from_watchlist(self):
     remove_from_watchlist(self)
Exemple #6
0
 def remove_from_watchlist(self):
     """Remove this :class:`TVEpisode` from your watchlist"""
     remove_from_watchlist(self)
Exemple #7
0
 def remove_from_watchlist(self):
     remove_from_watchlist(self)