How to use the trakt.Trakt.configuration.defaults.client 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 init_trakt(cls):
        config = Configuration.advanced['trakt']

        # Build timeout value
        timeout = (
            config.get_float('connect_timeout', 6.05),
            config.get_float('read_timeout', 24)
        )

        # Client
        Trakt.configuration.defaults.client(
            id='c9ccd3684988a7862a8542ae0000535e0fbd2d1c0ca35583af7ea4e784650a61',
            secret='bf00575b1ad252b514f14b2c6171fe650d474091daad5eb6fa890ef24d581f65'
        )

        # Application
        Trakt.configuration.defaults.app(
            name='trakt (for Plex)',
            version=PLUGIN_VERSION
        )

        # Http
        Trakt.base_url = (
            config.get('protocol', 'https') + '://' +
            config.get('hostname', 'api.trakt.tv')
        )
github sharkykh / TraktPlaybackProgressManager / tppm / app.py View on Github external
def __init__(self):
        # Trakt client configuration
        Trakt.base_url = 'https://api.trakt.tv'
        Trakt.configuration.defaults.app(**TRAKT_APP)
        Trakt.configuration.defaults.client(**TRAKT_CLIENT)
        # Bind trakt events
        Trakt.on('oauth.refresh', self._on_token_refreshed)

        self.main_tk = None
        self.main_win = None

        self._authorization = None
        self.username = None
        self.fullname = None
        self.playback_ids = []
github fuzeman / trakt.py / examples / scrobbler.py View on Github external
from __future__ import absolute_import, division, print_function

from examples.helpers import authenticate
from trakt import Trakt

from pprint import pprint
import logging
import os
import time

logging.basicConfig(level=logging.DEBUG)


if __name__ == '__main__':
    # Configure
    Trakt.configuration.defaults.client(
        id=os.environ.get('CLIENT_ID'),
        secret=os.environ.get('CLIENT_SECRET')
    )

    # Authenticate
    Trakt.configuration.defaults.oauth.from_response(
        authenticate()
    )

    # movie = {
    #     'title': 'Guardians of the Galaxy',
    #     'year': 2014,
    #     'ids': {
    #         'trakt': 28,
    #         'slug': 'guardians-of-the-galaxy-2014',
    #         'imdb': 'tt2015381',
github fuzeman / trakt.py / examples / collection.py View on Github external
from __future__ import absolute_import, division, print_function

from examples.helpers import authenticate
from trakt import Trakt
from trakt.objects import Movie, Show

import logging
import os

logging.basicConfig(level=logging.DEBUG)


if __name__ == '__main__':
    # Configure
    Trakt.configuration.defaults.client(
        id=os.environ.get('CLIENT_ID'),
        secret=os.environ.get('CLIENT_SECRET')
    )

    Trakt.configuration.defaults.http(
        retry=True
    )

    # Authenticate
    Trakt.configuration.defaults.oauth.from_response(
        authenticate()
    )

    # Fetch playback for movies
    playback = Trakt['sync/playback'].movies(exceptions=True)
github trakt / script.trakt / resources / lib / traktapi.py View on Github external
def __init__(self, force=False):
        logger.debug("Initializing.")

        proxyURL = checkAndConfigureProxy()
        if proxyURL:
            Trakt.http.proxies = {
                'http': proxyURL,
                'https': proxyURL
            }

        # Configure
        Trakt.configuration.defaults.client(
            id=self.__client_id,
            secret=self.__client_secret
        )

        # Bind event
        Trakt.on('oauth.token_refreshed', self.on_token_refreshed)

        Trakt.configuration.defaults.oauth(
            refresh=True
        )

        if getSetting('authorization') and not force:
            self.authorization = loads(getSetting('authorization'))
        else:
            last_reminder = getSettingAsInt('last_reminder')
            now = int(time.time())
github fuzeman / trakt.py / examples / lists.py View on Github external
from __future__ import absolute_import, division, print_function

from examples.helpers import authenticate

import logging
import os


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)

    from trakt import Trakt

    # Configure
    Trakt.configuration.defaults.client(
        id=os.environ.get('CLIENT_ID'),
        secret=os.environ.get('CLIENT_SECRET')
    )

    # Authenticate
    Trakt.configuration.defaults.oauth.from_response(
        authenticate()
    )

    for x, liked_list in enumerate(Trakt['users'].likes('lists', pagination=True)):
        print('[%s] %r' % (x + 1, liked_list))

        items = liked_list.items()

        if not items:
            print(' - ERROR')
github fuzeman / trakt.py / examples / history.py View on Github external
from __future__ import absolute_import, division, print_function

from examples.helpers import authenticate
from trakt import Trakt

from datetime import datetime
import os


if __name__ == '__main__':
    # Configure
    Trakt.configuration.defaults.client(
        id=os.environ.get('CLIENT_ID'),
        secret=os.environ.get('CLIENT_SECRET')
    )

    # Authenticate
    Trakt.configuration.defaults.oauth.from_response(
        authenticate()
    )

    now = datetime.utcnow()

    # Retrieve 10 history records (most recent)
    for item in Trakt['sync/history'].get(per_page=10):
        print(' - %-120s (watched_at: %r)' % (
            repr(item),
            item.watched_at.strftime('%Y-%m-%d %H:%M:%S')
github timbooo / traktforalfred / traktapi.py View on Github external
else:
            self.authorization = {}

        # bind trakt events
        Trakt.on('oauth.token_refreshed', self.__on_token_refreshed)

        # set base url
        Trakt.base_url = 'https://api-v2launch.trakt.tv'

        # set app defaults
        Trakt.configuration.defaults.app(
            id=self.__app_id
        )

        # set client defaults
        Trakt.configuration.defaults.client(
            id=self.__client_id,
            secret=self.__client_secret
        )

        # set oauth defaults
        Trakt.configuration.defaults.oauth(
            refresh=True
        )
github trakt / Plex-Trakt-Scrobbler / Trakttv.bundle / Contents / Code / bootstrap.py View on Github external
def configure_trakt(self):
        from plugin.core.configuration import Configuration

        from requests.packages.urllib3.util import Retry
        from trakt import Trakt

        config = Configuration.advanced['trakt']

        # Build timeout value
        timeout = (
            config.get_float('connect_timeout', 6.05),
            config.get_float('read_timeout', 24)
        )

        # Client
        Trakt.configuration.defaults.client(
            id='c9ccd3684988a7862a8542ae0000535e0fbd2d1c0ca35583af7ea4e784650a61',
            secret='bf00575b1ad252b514f14b2c6171fe650d474091daad5eb6fa890ef24d581f65'
        )

        # Application
        Trakt.configuration.defaults.app(
            name='trakt (for Plex)',
            version=PLUGIN_VERSION
        )

        # Http
        Trakt.base_url = (
            config.get('protocol', 'https') + '://' +
            config.get('hostname', 'api.trakt.tv')
        )
github fuzeman / trakt.py / examples / authentication / pin.py View on Github external
def on_token_refreshed(self, response):
        # OAuth token refreshed, save token for future calls
        self.authorization = response

        print('Token refreshed - authorization: %r' % self.authorization)


if __name__ == '__main__':
    # Configure
    Trakt.base_url = 'http://api.staging.trakt.tv'

    Trakt.configuration.defaults.app(
        id=os.environ.get('APP_ID')
    )

    Trakt.configuration.defaults.client(
        id=os.environ.get('CLIENT_ID'),
        secret=os.environ.get('CLIENT_SECRET')
    )

    # Start application
    app = Application()
    app.run()