def login(self): data = { 'e': utfenc(email), 'p': utfenc(password) } r = requests.post(self.v2 + 'session', headers=self.headers, data=data) return r.headers.get('set-cookie', '')
def json_request(self, url): if self.post_data: r = requests.post(url, headers=self.headers, data=self.post_data, params=self.params) else: r = requests.get(url, headers=self.headers, params=self.params) if r.headers.get('content-type', '').startswith('application/json'): return r.json() else: log('[%s] error: json request failed with %s response' % (addon_id, str(r.status_code))) return {}
def request(self, url): if self.POST_DATA: r = requests.post(url, headers=self.HEADERS, data=self.POST_DATA, params=self.PARAMS) else: r = requests.get(url, headers=self.HEADERS, params=self.PARAMS) if r.headers.get("content-type", "").startswith("application/json"): return r.json() else: if not r.status_code == 204: log("[%s] error: json request (%s, %s)" % (addon_id, str(r.status_code), r.headers.get("content-type", ""))) return {}
def grant(self, code): headers = { 'accept': 'application/json', 'content-type': 'application/json', 'authorization': 'Bearer ' + self.ACCESS_TOKEN } post_data = { 'id_token': code } data = requests.post(self.GRANT_URL, headers=headers, json=post_data).json() return data['assertion']
def authentication(self, credentials): headers = { 'accept': 'application/json', 'content-type': 'application/json', 'authorization': 'Bearer ' + self.ACCESS_TOKEN } post_data = { 'email': credentials['email'], 'password': credentials['password'] } return requests.post(self.IDENTITY_URL, headers=headers, json=post_data).json()
def login(self): credentials = Credentials() if credentials.email and credentials.password: post_data = { 'e': utfenc(credentials.email), 'p': utfenc(credentials.password) } r = requests.post(self.v2 + 'session', headers=self.headers, data=post_data) if r.headers.get('content-type', '').startswith('application/json') and not '<html>' in r.text: data = r.json() if data.get('error', None): msg = data['error'][0] log('[%s] login: %s' % (addon_id, msg)) dialog.ok(addon_name, msg) self.cookie = '' credentials.reset() elif data.get('result', None): self.cookie = r.headers.get('set-cookie', '') log('[%s] login: premium=%s' % (addon_id, data['result']['premium'])) credentials.save() else: self.cookie = '' log('[%s] login: %s' % (addon_id, 'error - reset cookie')) else: post_data_ = { 'email': utfenc(credentials.email), 'password': utfenc(credentials.password) } params_ = {'redirect': 'http://www.laola1.tv/de-de/home/'} r = requests.post(self.web_login, headers=self.headers, params=params_, data=post_data_, allow_redirects=False) self.cookie = r.headers.get('set-cookie', '') self.session() result = self.user(login_=False) if result: credentials.save() else: self.cookie = '' credentials.reset() addon.setSetting('cookie', self.cookie)
def device(self): headers = { 'accept': 'application/json', 'content-type': 'application/json', 'authorization': 'Bearer ' + self.API_KEY } post_data = { 'applicationRuntime': 'kodi', 'attributes': {}, 'deviceFamily': 'browser', 'deviceProfile': self.plugin.device_profile().lower() } data = requests.post(self.DEVICE_URL, headers=headers, json=post_data).json() return data['assertion']
def authorization(self, grant_type='refresh_token', token=''): if token == '': token = addon.getSetting('device_id') headers = { 'accept': 'application/json', 'content-type': 'application/x-www-form-urlencoded', 'authorization': 'Bearer ' + self.API_KEY } data = { 'grant_type': grant_type, 'platform': 'browser', 'token': token } return requests.post(self.TOKEN_URL, headers=headers, data=data).json()
def request(self, url): if self.POST_DATA: r = requests.post(url, headers=self.HEADERS, data=self.POST_DATA, params=self.PARAMS) else: r = requests.get(url, headers=self.HEADERS, params=self.PARAMS) if r.headers.get('content-type', '').startswith('application/json'): return r.json() else: if not r.status_code == 204: log('[%s] error: %s (%s, %s)' % (addon_id, url, str( r.status_code), r.headers.get('content-type', ''))) return {}
def request(self, url): if self.POST_DATA: r = requests.post(url, headers=self.HEADERS, data=self.POST_DATA, params=self.PARAMS) else: r = requests.get(url, headers=self.HEADERS, params=self.PARAMS) if r.headers.get("content-type", "").startswith("application/json"): return r.json() else: if not r.status_code == 204: log("[%s] error: json request (%s, %s)" % (addon_id, str( r.status_code), r.headers.get("content-type", ""))) return {}
def authentication(self, credentials): headers = { 'accept': 'application/vnd.identity-service+json; version=1.0', 'content-type': 'application/json', 'authorization': self.authorization(grant_type='client_credentials')['access_token'] } data = { "type": "email-password", "email": { "address": credentials.email }, "password": { "value": credentials.password } } return requests.post(self.IDENTITY_URL, headers=headers, json=data).json()
def suche(): url = args['url'][0] kb = xbmc.Keyboard('', 'Suche Anime-Tube.TV', False) kb.doModal() search = kb.getText() data = {'suchtext': search, 'submit': 'Go'} content = requests.post(url, data=data).text match = re.findall( 'preview".*?src="(.*?)".*?></a>.*?"title"><a href=".(/anime.*?html)" title="(.*?)">.*?Jahr</b>: (.*?)</span>.*?</div>.*?<div class="element">.*?<div class="meta_r" style=".*?">(.*?)</div>', content, re.DOTALL) for cover, url, name, year, plot in match: url = 'http://www.anime-tube.tv' + url plot = plot.replace("…", "...") year = year.replace("<i>Unbekannt</i>", "...") addDir(name + ' ' + '(' + year + ')', url, 'folgen', cover, plot) xbmcplugin.endOfDirectory(pluginhandle)
def graphql_request(self, url, query='', variables={}): headers = { 'accept': 'application/json', 'content-type': 'application/json', 'authorization': self.ACCESS_TOKEN } variables.update({ 'language': language, 'mediaRights': ['GeoMediaRight'], 'preferredLanguages': [language, 'en'] }) post_data = { 'query': query, 'operationName': '', 'variables': variables } return requests.post(url, headers=headers, json=post_data).json()
def request(self, url): self.HEADERS['Authorization'] = 'Bearer ' + self.TOKEN self.PARAMS['LanguageCode'] = self.LANGUAGE self.PARAMS['Country'] = self.COUNTRY if self.POST_DATA: r = requests.post(url, headers=self.HEADERS, data=self.POST_DATA, params=self.PARAMS) self.POST_DATA = {} else: r = requests.get(url, headers=self.HEADERS, params=self.PARAMS) if r.headers.get('content-type', '').startswith('application/json'): return r.json() else: if not r.status_code == 204: self.plugin.log('[{0}] error: {1} ({2}, {3})'.format(self.plugin.addon_id, url, str(r.status_code), r.headers.get('content-type', ''))) return {}
def authorization(self, grant_type='refresh_token', token='', token_type=''): if token == '': token = self.device() headers = { 'accept': 'application/json', 'content-type': 'application/x-www-form-urlencoded', 'authorization': 'Bearer ' + self.API_KEY } post_data = { 'grant_type': grant_type, 'platform': 'browser' } if token_type: post_data['subject_token'] = token post_data['subject_token_type'] = token_type else: post_data['refresh_token'] = token return requests.post(self.TOKEN_URL, headers=headers, data=post_data).json()
def request(self, url): if self.POST_DATA: r = requests.post(url, headers=self.HEADERS, data=self.POST_DATA, params=self.PARAMS) self.POST_DATA = {} else: r = requests.get(url, headers=self.HEADERS, params=self.PARAMS) if r.headers.get('content-type', '').startswith('application/json'): return r.json() else: if not r.status_code == 204: self.plugin.log('[{0}] error: {1} ({2}, {3})'.format( self.plugin.addon_id, url, str(r.status_code), r.headers.get('content-type', ''))) return {}
def login(self): credentials = Credentials() if credentials.email and credentials.password: post_data = { 'e': utfenc(credentials.email), 'p': utfenc(credentials.password) } r = requests.post(self.v2 + 'session', headers=self.headers, data=post_data) if r.headers.get('content-type', '').startswith('application/json'): data = r.json() if data.get('error', None): log('[%s] login: %s' % (addon_id, data['error'][0])) credentials.reset() elif data.get('result', None): log('[%s] login: premium=%s' % (addon_id, data['result']['premium'])) addon.setSetting('cookie', r.headers.get('set-cookie', '')) credentials.save() else: log('[%s] login: %s' % (addon_id, 'error - reset cookie')) addon.setSetting('cookie', '')
def login(self): credentials = Credentials() LOGIN_DATA = { 'login.username': utfenc(credentials.email), 'login.password': utfenc(credentials.password), 'login.successRedirectUrl': '/on-demand', 'login.failureRedirectUrl': '/login?loginError=1' } r = requests.post('https://secure.wtatv.com/system/userlogin', headers=self.HEADERS, data=LOGIN_DATA, allow_redirects=False) if '/on-demand' in r.headers.get('location', '') and r.headers.get( 'set-cookie', ''): cookie = r.headers['set-cookie'] self.HEADERS.update({'Cookie': cookie}) addon.setSetting('cookie', cookie) log('[%s] info: loginsuccess' % (addon_id)) credentials.save() else: log('[%s] info: loginerror' % (addon_id)) credentials.reset()
def logout(self): if cookie: self.headers['cookie'] = cookie r = requests.post(self.v2 + 'session/delete', headers=self.headers)
def videos(self, id): self.DATA['query'] = '{ sport_%s:query (index: "eurosport_global",sort: new,page: 1,page_size: 100,type: ["Video","Airing"],must: {termsFilters: [{attributeName: "category", values: ["%s"]}]},must_not: {termsFilters: [{attributeName: "mediaConfigState", values: ["OFF"]}]},should: {termsFilters: [{attributeName: "mediaConfigProductType", values: ["VOD"]},{attributeName: "type", values: ["Video"]}]}) @context(uiLang: "%s") { ... on QueryResponse { ...queryResponse }} }fragment queryResponse on QueryResponse {meta { hits }hits {hit { ... on Airing { ... airingData } ... on Video { ... videoData } }}}fragment airingData on Airing {type contentId mediaId liveBroadcast linear partnerProgramId programId runTime startDate endDate expires genres playbackUrls { href rel templated } channel { id parent callsign partnerId } photos { id uri width height } mediaConfig { state productType type } titles { language title descriptionLong descriptionShort episodeName } }fragment videoData on Video {type contentId epgPartnerProgramId programId appears releaseDate expires runTime genres media { playbackUrls { href rel templated } } titles { title titleBrief episodeName summaryLong summaryShort tags { type value displayName } } photos { rawImage width height photos { imageLocation width height } } }' % (id, id, self.LANGUAGE) return requests.post(self.GRAPHQL_URL, headers=self.HEADERS, json=self.DATA).json()
def epg(self, prev_date, date): self.DATA['query'] = '{ Airings: query(index: "eurosport_global_all", type: "Airing", from: "%sT22:00:00.000Z", to: "%sT21:59:59.999Z", sort: new, page_size: 500) @context(uiLang: "%s") { hits { hit { ... on Airing {type contentId mediaId liveBroadcast linear partnerProgramId programId runTime startDate endDate expires genres playbackUrls { href rel templated } channel { id parent callsign partnerId } photos { id uri width height } mediaConfig { state productType type } titles { language title descriptionLong descriptionShort episodeName } } } } } }' % (prev_date, date, self.LANGUAGE) return requests.post(self.GRAPHQL_URL, headers=self.HEADERS, json=self.DATA).json()
def channels(self): self.DATA['query'] = '{ onNow: query(index: "eurosport_global_on_now", type: "Airing", page_size: 500) @context(uiLang: "%s") { hits { hit { ... on Airing { type liveBroadcast linear runTime startDate endDate expires genres playbackUrls { href rel templated } channel { callsign } photos { uri width height } mediaConfig { state productType type } titles { language title descriptionLong } } } } } }' % (self.LANGUAGE) return requests.post(self.GRAPHQL_URL, headers=self.HEADERS, json=self.DATA).json()
def categories(self): self.DATA['query'] = '{ ListByTitle(title: "sports_filter") { list { ... on Category { id: sport sport tags { type displayName } defaultAssetImage { rawImage width height photos { imageLocation width height } } } } } } ' return requests.post(self.GRAPHQL_URL, headers=self.HEADERS, json=self.DATA).json()
def deletesession(self): if cookie: self.headers['cookie'] = cookie r = requests.post(self.v3 + 'user/session/premium/delete', headers=self.headers)
def ondemand(self): return requests.post( base_url + '/json/videos/pageSize/50/type/on-demand/').json()
def deletesession(self): if self.cookie: self.headers['cookie'] = self.cookie r = requests.post(self.v3 + 'user/session/premium/delete', headers=self.headers)
def logout(self): if self.cookie: self.headers['cookie'] = self.cookie r = requests.post(self.v2 + 'session/delete', headers=self.headers)
def features(self): return requests.post(base_url + '/json/videos/pageSize/50/type/features/').json()