def start(self): self.bar = xbmcgui.DialogProgress() self.bar.create(__lang__(32130), __lang__(32131) + '...') # generate random key key = self.generateKEY() # init auth with random key ret = function.sendRequest(AUTH_URL, '', get={ 'option': 'init', 'key': key }) if ret is False or 'init' not in ret or 'ok' not in ret['init']: self.bar.close() debug.notify(__lang__(32132), True) return None # wait for authenticate self.bar.update( 25, __lang__(32133), __lang__(32134) + ' ' + AUTH_URL + ' ' + __lang__(32135) + ' ' + key, __lang__(32136) + '...') token = self.checkForResponse(key) if token is None: debug.notify(__lang__(32137), True) self.bar.close() return token
def sendAction(self, token, link): url = link[0] runtime = link[1] action = { 'movie': url, 'fb:explicitly_shared': 'true', 'privacy': json.dumps({'value': PRIVACY[int(__addon__.getSetting('privacy'))]}), 'expires_in': runtime } ret = function.sendRequest(API_URL, '/' + USER + '/' + METHOD, get={'access_token': token}, post=action) if ret is False: return False
def findTMDbID(self, imdbid): API_KEY = '1009b5cde25c7b0692d51a7db6e49cbd' API_URL = 'https://api.themoviedb.org/3/' API_HOST = 'api.themoviedb.org' import function ret = function.sendRequest(API_URL, 'find/' + imdbid, get={ 'api_key': API_KEY, 'external_source': 'imdb_id' }) return ret
def checkForResponse(self, key): for i in range(COUNT_RETRY): if (self.bar.iscanceled()): return None ret = function.sendRequest(AUTH_URL, '', get={ 'option': 'auth', 'key': key }) if ret is not False and key in ret and len(ret[key]) > 0: return ret[key] time.sleep(RETRY_TIME) return None
def prepare(self, user, link): token = user['token'] # check token ret = function.sendRequest(API_URL, '/me', get={'access_token': token}) if ret is False: debug.notify(__lang__(32111), True) import auth token = auth.AUTH().start() if token is None: debug.notify(__lang__(32112), True) return ret = self.sendAction(token, link) if ret is False: debug.notify(__lang__(32113), True) else: debug.notify(__lang__(32114))