How to use the trakt.Trakt.configuration.http function in trakt

To help you get started, we’ve selected a few trakt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trakt / Plex-Trakt-Scrobbler / Trakttv.bundle / Contents / Code / main.py View on Github external
def on_trakt_refresh(cls, username, authorization):
        log.debug('[Trakt.tv] Token has been refreshed for %r', username)

        # Retrieve trakt account matching this `authorization`
        with Trakt.configuration.http(retry=True).oauth(token=authorization.get('access_token')):
            settings = Trakt['users/settings'].get(validate_token=False)

        if not settings:
            log.warn('[Trakt.tv] Unable to retrieve account details for token')
            return False

        # Retrieve trakt account username from `settings`
        s_username = settings.get('user', {}).get('username')

        if not s_username:
            log.warn('[Trakt.tv] Unable to retrieve username for token')
            return False

        if s_username != username:
            log.warn('[Trakt.tv] Token mismatch (%r != %r)', s_username, username)
            return False
github trakt / script.trakt / resources / lib / traktapi.py View on Github external
def getTextQuery(self, query, type, year):
        with Trakt.configuration.http(retry=True, timeout=90):
            result = Trakt['search'].query(query, type, year)
            if result and not isinstance(result, list):
                result = [result]
            return result
github trakt / script.trakt / resources / lib / traktapi.py View on Github external
def getMovieSummary(self, movieId):
        with Trakt.configuration.http(retry=True):
            return Trakt['movies'].get(movieId)
github trakt / script.trakt / resources / lib / traktapi.py View on Github external
def getShowRatingForUser(self, showId, idType='tvdb'):
        ratings = {}
        with Trakt.configuration.oauth.from_response(self.authorization):
            with Trakt.configuration.http(retry=True):
                Trakt['sync/ratings'].shows(ratings)
        return findShowMatchInList(showId, ratings, idType)
github trakt / script.trakt / resources / lib / traktapi.py View on Github external
def getUser(self):
        with Trakt.configuration.oauth.from_response(self.authorization):
            with Trakt.configuration.http(retry=True):
                result = Trakt['users/settings'].get()
                return result
github trakt / script.trakt / resources / lib / traktapi.py View on Github external
def getEpisodeSummary(self, showId, season, episode):
        with Trakt.configuration.http(retry=True):
            return Trakt['shows'].episode(showId, season, episode)
github trakt / script.trakt / resources / lib / traktapi.py View on Github external
def getShowsWatched(self, shows):
        with Trakt.configuration.oauth.from_response(self.authorization):
            with Trakt.configuration.http(retry=True, timeout=90):
                Trakt['sync/watched'].shows(shows, exceptions=True)
        return shows
github trakt / script.trakt / resources / lib / traktapi.py View on Github external
def getShowRatingForUser(self, showId, idType='tvdb'):
        ratings = {}
        with Trakt.configuration.oauth.from_response(self.authorization):
            with Trakt.configuration.http(retry=True):
                Trakt['sync/ratings'].shows(ratings)
        return findShowMatchInList(showId, ratings, idType)
github trakt / script.trakt / resources / lib / traktapi.py View on Github external
def removeRating(self, mediaObject):
        with Trakt.configuration.oauth.from_response(self.authorization):
            with Trakt.configuration.http(retry=True):
                result = Trakt['sync/ratings'].remove(mediaObject)
        return result
github trakt / script.trakt / resources / lib / traktapi.py View on Github external
def scrobbleMovie(self, movie, percent, status):
        result = None

        with Trakt.configuration.oauth.from_response(self.authorization):
            if status == 'start':
                with Trakt.configuration.http(retry=True):
                    result = Trakt['scrobble'].start(
                        movie=movie,
                        progress=percent)
            elif status == 'pause':
                with Trakt.configuration.http(retry=True):
                    result = Trakt['scrobble'].pause(
                        movie=movie,
                        progress=percent)
            elif status == 'stop':
                # don't retry on stop, this will cause multiple scrobbles
                result = Trakt['scrobble'].stop(
                    movie=movie,
                    progress=percent)
            else:
                logger.debug("scrobble() Bad scrobble status")
        return result