def __init__(self): logger.debug("Initializing.") proxyURL = checkAndConfigureProxy() if proxyURL: Trakt.http.proxies = {'http': proxyURL, 'https': proxyURL} # Get user login data self.__pin = getSetting('PIN') 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) if not self.authorization: self.authenticate()
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 )
def __init__(self, loadSettings=False): Debug("[traktAPI] Initializing.") self.__username = getSetting('username') self.__password = sha1(getSetting('password')).hexdigest() self.settings = None if loadSettings and self.testAccount(): self.getAccountSettings()
def __init__(self, loadSettings=False): Debug("[XbmcFilm] Initializing.") self.__username = getSetting('xbmcfilm_user') self.__password = sha1(getSetting('xbmcfilm_pass')).hexdigest() self.settings = None if loadSettings and self.testAccount(): self.getAccountSettings()
def updateSettings(self): _username = getSetting('username') _password = sha1(getSetting('password')).hexdigest() if not ((self.__username == _username) and (self.__password == _password)): self.__username = _username self.__password = _password self.testAccount(force=True)
def __init__(self): Debug("[traktAPI] Initializing.") self.__username = getSetting('username') self.__password = sha1(getSetting('password')).hexdigest() self.settings = None if self.testAccount(): Debug("[traktAPI] Getting account settings for '%s'." % self.__username) self.getAccountSettings()
def updateSettings(self): _username = getSetting('username') _password = getSetting('password') if not ((self.__username == _username)): self.__username = _username if not ((self.__password == _password)): self.__password = _password self.getToken()
def __init__(self): logger.debug("Initializing.") # Get user login data self.__username = getSetting('username') self.__password = getSetting('password') # Configure Trakt.configuration.defaults.client(id=self.__apikey) if not self.__token: self.getToken()
def updateSettings(self): if getSetting('authorization'): _auth = loads(getSetting('authorization')) else: _auth = {} if self.authorization != _auth: self.authorization = _auth user = self.getUser() if user and 'user' in user: setSetting('user', user['user']['username']) else: setSetting('user', '')
def __init__(self): logger.debug("Initializing.") # Get user login data self.__username = getSetting('username') self.__password = getSetting('password') # Configure Trakt.configuration.defaults.client( id=self.__apikey ) if not self.__token: self.getToken()
def updateSettings(self): _username = getSetting('username') _password = getSetting('password') updated = False if self.__username != _username: self.__username = _username updated = True if self.__password != _password: self.__password = _password updated = True if updated: self.getToken()
def __init__(self): Debug("[traktAPI] Initializing.") # Get user login data self.__username = getSetting('username') self.__password = getSetting('password') self.__token = getSetting('token') # Configure logging.basicConfig(level=logging.INFO) Trakt.configuration.defaults.http( retry=True, max_retries=getSettingAsInt('retries')) Trakt.configuration.defaults.client(id=self.__apikey) if not self.__token: self.getToken()
def getAccountSettings(self, force=False): _interval = (60 * 60 * 24 * 7) - (60 * 60) # one week less one hour _next = getSettingAsInt('trakt_settings_last') + _interval stale = force if force: Debug("[traktAPI] Forcing a reload of settings from trakt.tv.") if not stale and time.time() >= _next: Debug("[traktAPI] trakt.tv account settings are stale, reloading.") stale = True if stale: if self.testAccount(): Debug("[traktAPI] Getting account settings for '%s'." % self.__username) url = "%s/account/settings/%s" % (self.__baseURL, self.__apikey) Debug("[traktAPI] getAccountSettings(url: %s)" % url) response = self.traktRequest('POST', url, hideResponse=True) if response and 'status' in response: if response['status'] == 'success': del response['status'] setSetting('trakt_settings', json.dumps(response)) setSetting('trakt_settings_last', int(time.time())) self.settings = response else: Debug("[traktAPI] Loaded cached account settings for '%s'." % self.__username) s = getSetting('trakt_settings') self.settings = json.loads(s)
def getAccountSettings(self, force): _interval = (60 * 60 * 24 * 7) - (60 * 60) # one week less one hour _next = getSettingAsInt('xbmcfilm_settings_last') + _interval stale = force if force: Debug("[XbmcFilm] Forcing a reload of settings from xbmcfilm.tv.") if not stale and time.time() >= _next: Debug("[XbmcFilm] xbmcfilm.tv account settings are stale, reloading.") stale = True if stale: if self.testAccount(): Debug("[XbmcFilm] Getting account settings for '%s'." % self.__username) url = "%s/account/settings/%s" % (self.__baseURL, self.__apikey) Debug("[XbmcFilm] getAccountSettings(url: %s)" % url) response = self.xbmcfilmRequest('POST', url, hideResponse=True) if response and 'status' in response: if response['status'] == 'success': del response['status'] setSetting('xbmcfilm_settings', json.dumps(response)) setSetting('xbmcfilm_settings_last', int(time.time())) self.settings = response else: Debug("[XbmcFilm] Loaded cached account settings for '%s'." % self.__username) s = getSetting('xbmcfilm_settings') self.settings = json.loads(s)
def run(self): startup_delay = utilities.getSettingAsInt('startup_delay') if startup_delay: logger.debug("Delaying startup by %d seconds." % startup_delay) xbmc.sleep(startup_delay * 1000) logger.debug("Service thread starting.") # purge queue before doing anything self.dispatchQueue.purge() # setup event driven classes self.Player = traktPlayer(action=self._dispatchQueue) self.Monitor = traktMonitor(action=self._dispatchQueue) # init traktapi class globals.traktapi = traktAPI() # init sync thread self.syncThread = syncThread() # init scrobbler class self.scrobbler = Scrobbler(globals.traktapi) # start loop for events while not self.Monitor.abortRequested(): if not utilities.getSetting('authorization'): last_reminder = utilities.getSettingAsInt('last_reminder') now = int(time.time()) if last_reminder >= 0 and last_reminder < now - (24 * 60 * 60): gui_utils.get_pin() while len(self.dispatchQueue) and ( not self.Monitor.abortRequested()): data = self.dispatchQueue.get() logger.debug("Queued dispatch: %s" % data) self._dispatch(data) if xbmc.Player().isPlayingVideo(): self.scrobbler.transitionCheck() if self.Monitor.waitForAbort(1): # Abort was requested while waiting. We should exit break # we are shutting down logger.debug("Beginning shut down.") # delete player/monitor del self.Player del self.Monitor # check if sync thread is running, if so, join it. if self.syncThread.isAlive(): self.syncThread.join()
def run(self): startup_delay = utilities.getSettingAsInt('startup_delay') if startup_delay: logger.debug("Delaying startup by %d seconds." % startup_delay) xbmc.sleep(startup_delay * 1000) logger.debug("Service thread starting.") # purge queue before doing anything self.dispatchQueue.purge() # setup event driven classes self.Player = traktPlayer(action=self._dispatchQueue) self.Monitor = traktMonitor(action=self._dispatchQueue) # init traktapi class globals.traktapi = traktAPI() # init sync thread self.syncThread = syncThread() # init scrobbler class self.scrobbler = Scrobbler(globals.traktapi) # start loop for events while not self.Monitor.abortRequested(): if not utilities.getSetting('authorization'): last_reminder = utilities.getSettingAsInt('last_reminder') now = int(time.time()) if last_reminder >= 0 and last_reminder < now - (24 * 60 * 60): gui_utils.get_pin() while len(self.dispatchQueue) and (not self.Monitor.abortRequested()): data = self.dispatchQueue.get() logger.debug("Queued dispatch: %s" % data) self._dispatch(data) if xbmc.Player().isPlayingVideo(): self.scrobbler.transitionCheck() if self.Monitor.waitForAbort(1): # Abort was requested while waiting. We should exit break # we are shutting down logger.debug("Beginning shut down.") # delete player/monitor del self.Player del self.Monitor # check if sync thread is running, if so, join it. if self.syncThread.isAlive(): self.syncThread.join()
def updateSettings(self): _pin = getSetting('PIN') updated = False if self.__pin != _pin: self.__pin = _pin updated = True if updated: self.authenticate()
def getToken(self): if not self.__username and not self.__password: notification('Trakt', getString(32021)) #Username and password error elif not self.__password: notification('Trakt', getString(32022)) #Password error else: # Attempt authentication (retrieve new token) with Trakt.configuration.http(retry=True): try: auth = Trakt['auth'].login(getSetting('username'), getSetting('password')) if auth: self.__token = auth else: logger.debug("Authentication Failure") notification('Trakt', getString(32025)) except Exception as ex: message = createError(ex) logger.fatal(message) logger.debug("Cannot connect to server") notification('Trakt', getString(32023))
def getToken(self): if not self.__username and not self.__password: notification('trakt', getString(32021)) #Username and password error elif not self.__password: notification('trakt', getString(32022)) #Password error else: # Attempt authentication (retrieve new token) with Trakt.configuration.http(retry=True): try: auth = Trakt['auth'].login(getSetting('username'), getSetting('password')) if auth: self.__token = auth else: logger.debug("Authentication Failure") notification('trakt', getString(32025)) except Exception as ex: message = createError(ex) logger.fatal(message) logger.debug("Cannot connect to server") notification('trakt', getString(32023))
def __init__(self, show_progress=False, api=None): self.traktapi = api self.show_progress = show_progress self.notify = utilities.getSettingAsBool('show_sync_notifications') self.simulate = utilities.getSettingAsBool('simulate_sync') if self.simulate: Debug("[Sync] Sync is configured to be simulated.") _opts = ['ExcludePathOption', 'ExcludePathOption2', 'ExcludePathOption3'] _vals = ['ExcludePath', 'ExcludePath2', 'ExcludePath3'] self.exclusions = [] for i in range(3): if utilities.getSettingAsBool(_opts[i]): _path = utilities.getSetting(_vals[i]) if _path != "": self.exclusions.append(_path)
def __init__(self, show_progress=False, run_silent=False, library="all", api=None): self.traktapi = api self.show_progress = show_progress self.run_silent = run_silent self.library = library if self.show_progress and self.run_silent: Debug("[Sync] Sync is being run silently.") self.sync_on_update = utilities.getSettingAsBool('sync_on_update') self.notify = utilities.getSettingAsBool('show_sync_notifications') self.notify_during_playback = not (xbmc.Player().isPlayingVideo() and utilities.getSettingAsBool("hide_notifications_playback")) _opts = ['ExcludePathOption', 'ExcludePathOption2', 'ExcludePathOption3'] _vals = ['ExcludePath', 'ExcludePath2', 'ExcludePath3'] self.exclusions = [] for i in range(3): if utilities.getSettingAsBool(_opts[i]): _path = utilities.getSetting(_vals[i]) if _path != "": self.exclusions.append(_path)
def __init__(self, show_progress=False, run_silent=False, library="all", api=None): self.traktapi = api self.show_progress = show_progress self.run_silent = run_silent self.library = library if self.show_progress and self.run_silent: Debug("[Sync] Sync is being run silently.") self.sync_on_update = utilities.getSettingAsBool('sync_on_update') self.notify = utilities.getSettingAsBool('show_sync_notifications') self.notify_during_playback = not (xbmc.Player().isPlayingVideo() and utilities.getSettingAsBool("hide_notifications_playback")) self.simulate = utilities.getSettingAsBool('simulate_sync') if self.simulate: Debug("[Sync] Sync is configured to be simulated.") _opts = ['ExcludePathOption', 'ExcludePathOption2', 'ExcludePathOption3'] _vals = ['ExcludePath', 'ExcludePath2', 'ExcludePath3'] self.exclusions = [] for i in range(3): if utilities.getSettingAsBool(_opts[i]): _path = utilities.getSetting(_vals[i]) if _path != "": self.exclusions.append(_path)
def getToken(self): # Attempt authentication (retrieve new token) self.__token = Trakt['auth'].login(getSetting('username'), getSetting('password'))