Example #1
0
    def __init__(self):
        logger.debug("Initializing.")

        proxyURL = checkAndConfigureProxy()
        if proxyURL:
            Trakt.http.proxies = {
                'http': proxyURL,
                'https': proxyURL
            }
        
        if getSetting('authorization'):
            self.authorization = loads(getSetting('authorization'))
        else:
            self.authorization = {}

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

        Trakt.configuration.defaults.app(
            id=999
        )

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

        #Set defaults
        Trakt.configuration.defaults.oauth(
            refresh=True
        )
Example #2
0
    def __init__(self):
        self.is_authenticating = Condition()

        self.authorization = None

        # Bind trakt events
        Trakt.on('oauth.token_refreshed', self.on_token_refreshed)
Example #3
0
    def __init__(self, force=False):
        logger.debug("Initializing.")

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

        Trakt.configuration.defaults.app(
            id=999
        )

        # 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())
            if last_reminder >= 0 and last_reminder < now - (24 * 60 * 60) or force:
                self.login()
def add_to_trakt_watchlist(type,imdb_id,title):
    Trakt.configuration.defaults.app(
        id=8835
    )
    Trakt.configuration.defaults.client(
        id="aa1c239000c56319a64014d0b169c0dbf03f7770204261c9edbe8ae5d4e50332",
        secret="250284a95fd22e389b565661c98d0f33ac222e9d03c43b5931e03946dbf858dc"
    )
    Trakt.on('oauth.token_refreshed', on_token_refreshed)
    if not __settings__.getSetting('authorization'):
        if not authenticate():
            return
    authorization = loads(__settings__.getSetting('authorization'))
    with Trakt.configuration.oauth.from_response(authorization, refresh=True):
        result = Trakt['sync/watchlist'].add({
            type: [
                {
                    'ids': {
                        'tmdb': imdb_id
                    }
                }
            ]
        })
        dialog = xbmcgui.Dialog()
        dialog.notification("Trakt: add to watchlist",title)
Example #5
0
    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')
        )

        Trakt.configuration.defaults.http(
            timeout=timeout
        )

        # Configure keep-alive
        Trakt.http.keep_alive = config.get_boolean('keep_alive', True)

        # Configure requests adapter
        Trakt.http.adapter_kwargs = {
            'pool_connections': config.get_int('pool_connections', 10),
            'pool_maxsize': config.get_int('pool_size', 10),
            'max_retries': Retry(
                total=config.get_int('connect_retries', 3),
                read=0
            )
        }

        Trakt.http.rebuild()

        # Bind to events
        Trakt.on('oauth.refresh', cls.on_trakt_refresh)
        Trakt.on('oauth.refresh.rejected', cls.on_trakt_refresh_rejected)

        log.info(
            'Configured trakt.py (timeout=%r, base_url=%r, keep_alive=%r, adapter_kwargs=%r)',
            timeout,
            Trakt.base_url,
            Trakt.http.keep_alive,
            Trakt.http.adapter_kwargs,
        )
Example #6
0
    def init_trakt(cls):
        # Client
        Trakt.configuration.defaults.client(
            id='c9ccd3684988a7862a8542ae0000535e0fbd2d1c0ca35583af7ea4e784650a61',
            secret='bf00575b1ad252b514f14b2c6171fe650d474091daad5eb6fa890ef24d581f65'
        )

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

        # Setup request retrying
        Trakt.http.adapter_kwargs = {'max_retries': Retry(total=3, read=0)}
        Trakt.http.rebuild()

        Trakt.on('oauth.token_refreshed', cls.on_token_refreshed)
    def init_trakt():
        def get_credentials():
            password_hash = hashlib.sha1(Prefs['password'])

            return (
                Prefs['username'],
                password_hash.hexdigest()
            )

        Trakt.configure(
            # Application
            api_key='ba5aa61249c02dc5406232da20f6e768f3c82b28',

            # Version
            plugin_version=PLUGIN_VERSION,
            media_center_version=PlexMediaServer.get_version(),

            # Account
            credentials=get_credentials
        )
    def __init__(self, username='ddboline', mq_=None):
        credentials = read_credentials()
        self.username = username
        self.client_id = credentials['client_id']
        self.client_secret = credentials['client_secret']
        self.trakt = Trakt.configuration.defaults.client(
            id=self.client_id, secret=self.client_secret)

        if mq_ is not None:
            self.mq_ = mq_
        else:
            self.mq_ = MovieCollection()
        self.imdb_show_map = {v['link']: k for k, v in self.mq_.imdb_ratings.items()}

        self.is_authenticating = Condition()

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

        self.authorization = self.read_auth()

        if self.authorization is None:
            self.authenticate()
Example #9
0
    def __init__(self):
        # Set trakt app id
        Trakt.configuration.defaults.app(
            id=sickrage.app.config.trakt_app_id
        )

        # Set trakt client id/secret
        Trakt.configuration.defaults.client(
            id=sickrage.app.config.trakt_api_key,
            secret=sickrage.app.config.trakt_api_secret
        )

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

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

        if sickrage.app.config.trakt_oauth_token:
            Trakt.configuration.defaults.oauth.from_response(
                sickrage.app.config.trakt_oauth_token
            )
Example #10
0
    def __init__(self, wf):
        self.wf = wf

        # load authorization from settings
        if 'access_token' in self.wf.settings:
            self.authorization['access_token'] = self.wf.settings['access_token']
            self.authorization['created_at'] = self.wf.settings['created_at']
            self.authorization['expires_in'] = self.wf.settings['expires_in']
            self.authorization['refresh_token'] = self.wf.settings['refresh_token']
            self.authorization['scope'] = self.wf.settings['scope']
            self.authorization['token_type'] = self.wf.settings['token_type']
        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'
        Trakt.base_url = 'https://api.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
        )
Example #11
0
    def __init__(self):
        self.authorization = None

        # Bind trakt events
        Trakt.on('oauth.token_refreshed', self.on_token_refreshed)
Example #12
0
tvdb = tvdb_api.Tvdb()

my_episodes = MyEpisodes(
        config.get('MyEpisodes', 'Username'),
        config.get('MyEpisodes', 'Password'))
login = my_episodes.login()
if(login == False):
    print "ERROR - Could not login to MyEpisodes"
    sys.exit(1)

my_episodes.get_show_list()


trakt = Trakt(
        config.get('Trakt', 'ClientId'),
        config.get('Trakt', 'ClientSecret'))

print "Requesting Trakt.tv authorization..."
print "To authorize access to you trakt.tv account access the following URL in a web browser and copy the authorization code:"
print trakt.get_authorize_url()
code = raw_input('Paste the authorization code here: ')
trakt.authorize(code)

for show in my_episodes.show_list:
    show['name'] = unicodedata.normalize('NFKD', show['name']).encode('ascii','ignore')
    print "\nProcessing: {}".format(show['name'])
    try:
        tvdb_data = tvdb[show['name']]

    except: