def getEpisodes(self, name, accuracy = 0.8): """ Gets a list of all the episodes for a given show. Arguments: name {String} -- The name of the show being searched for. Keyword Arguments: accuracy {float} -- If no show with title found, how accurate should a match to the alias be. (default: {0.8}) Raises: InvalidInput: Raises if a non string is inputed for name. InvalidShowID: Raises if a show was not found. Returns: list -- Returns a list of all the episodes for a given show. """ if type(name) is not str: raise InvalidInput( "You have entered an invalid name. Please try again.") if not self.__authorized: self._authorize() id = self._getShowID(name, accuracy) if id == -1: raise InvalidShowID("Show was not found, please try again") pages = get_html(self.config['seriesEndpoint'] + "{id}/episodes", headers=self.headers).json()['links']['last'] episodes = [] for x in range(1,pages+1): params = { "page": x } data = get_html(self.config['seriesEndpoint'] + "{id}/episodes", params=params, headers=self.headers).json()['data'] for episode in data: episodes.append(episode) return episodes
def get_html_g(): headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Language': 'en-US,en;q=0.5', 'DNT': '1', 'Connection': 'keep-alive', 'Upgrade-Insecure-Requests': '1', 'Pragma': 'no-cache', 'Cache-Control': 'no-cache', 'TE': 'Trailers', } try: html_g_tv = {} url_g = 'https://api.themoviedb.org/3/genre/tv/list?api_key=34142515d9d23817496eeb4ff1d223d0&language=' + lang logging.warning(url_g) html_g_tv = get_html(url_g, headers=headers).json() html_g_movie = {} url_g = 'https://api.themoviedb.org/3/genre/movie/list?api_key=34142515d9d23817496eeb4ff1d223d0&language=' + lang html_g_movie = get_html(url_g, headers=headers).json() except Exception as e: logging.warning('Err in HTML_G:' + str(e)) return html_g_tv, html_g_movie
def get_html_g(): url_g='https://api.themoviedb.org/3/genre/tv/list?api_key=fb126fd0d6df5cb02b1cb676eadd2d1a&language='+lang html_g_tv=get_html(url_g).json() try: url_g='https://api.themoviedb.org/3/genre/tv/list?api_key=fb126fd0d6df5cb02b1cb676eadd2d1a&language='+lang html_g_tv=get_html(url_g).json() url_g='https://api.themoviedb.org/3/genre/movie/list?api_key=fb126fd0d6df5cb02b1cb676eadd2d1a&language='+lang html_g_movie=get_html(url_g).json() except Exception as e: logging.warning('Err in HTML_G:'+str(e)) return html_g_tv,html_g_movie
def get_links(tv_movie, original_title, season_n, episode_n, season, episode, show_original_year, id): global global_var, stop_all all_links = [] if tv_movie == 'tv': return [] headers = { 'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 9.0.1; samsung Build/AXXXXXXX)', 'Connection': 'Keep-Alive' } c_name = clean_name(original_title, 1).lower() url = 'https://yumovfreemov.com/salam/hangat.php?cai=%s&tadondo=com.yumovies.mushdomovidev' % clean_name( original_title, 1).replace(' ', '%20') x = get_html(url, headers=headers).json() logging.warning(x) for items in x['STREAME']: if c_name in items['channel_title'].lower( ) and show_original_year in items['channel_title']: url = 'https://yumovfreemov.com/salam/hangat.php?channel_id=%s&tadondo=com.yumovies.mushdomovidev' % items[ 'id'] y = get_html(url, headers=headers).json() for itt in y['STREAME']: size = 0 try: try_head = get_html(itt['channel_url'], headers=base_header, stream=True, verify=False, timeout=3) if 'Content-Length' in try_head.headers: if int(try_head.headers['Content-Length']) > (1024 * 1024): size = (round( float(try_head.headers['Content-Length']) / (1024 * 1024 * 1024), 2)) except: size = 0 all_links.append( (clean_name(original_title, 1), 'Direct_link$$$' + itt['channel_url'], str(size), '720')) global_var = all_links return global_var
def get_youtube_link2(url): headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Language': 'en-US,en;q=0.5', 'Connection': 'keep-alive', 'Referer': 'https://qdownloader.io/', 'Upgrade-Insecure-Requests': '1', 'Pragma': 'no-cache', 'Cache-Control': 'no-cache', 'TE': 'Trailers', } params = (('url', url), ) response = get_html('https://qdownloader.io/download', headers=headers, params=params).content() regex = ' download="(.+?)" href="(.+?)"' match = re.compile(regex).findall(response) all_results = [] for name, link in match: return link.replace('&', '&') all_results.append((name, link.replace('&', '&')))
def _get_token_and_cookies(url): headers = { 'authority': 'bitlordsearch.com', 'pragma': 'no-cache', 'cache-control': 'no-cache', 'accept': '*/*', 'dnt': '1', 'x-requested-with': 'XMLHttpRequest', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 Safari/537.36', 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8', 'origin': 'https://bitlordsearch.com', 'sec-fetch-site': 'same-origin', 'sec-fetch-mode': 'cors', 'sec-fetch-dest': 'empty', } token = '' x, cook = get_html(url, get_cookies=True, headers=headers).content() regex = 'token: (.+?)\n' m = re.compile(regex).findall(x) regex = "var %s = '(.+?)'" % m[0] m2 = re.compile(regex).findall(x) token = m2[0] regex = ">%s \+= '(.+?)'" % m[0] m3 = re.compile(regex).findall(x) for itt in m3: token += itt cookies = '' for cookie in cook: cookies += '%s=%s;' % (cookie, cook[cookie]) return (token, cookies)
def token_request(self): import time if self.ClientSecret is '': return postData = { 'client_id': self.ClientID, 'client_secret': self.ClientSecret, 'code': self.DeviceCode, 'grant_type': 'http://oauth.net/grant_type/device/1.0' } url = self.OauthUrl + self.TokenUrl response = get_html(url, data=postData).json() Addon.setSetting('rd.auth', response['access_token']) Addon.setSetting('rd.refresh', response['refresh_token']) try: resuaddon.setSetting('RealDebridResolver_token', response['access_token']) resuaddon.setSetting('RealDebridResolver_refresh', response['refresh_token']) except: pass self.token = response['access_token'] self.refresh = response['refresh_token'] Addon.setSetting('rd.expiry', str(time.time() + int(response['expires_in'])))
def _get(self, url, params={}): headers = {'Authorization': self.auth} response = get_html(url, params=params, headers=headers).content() try: return to_utf8(json.loads(response)) except: return to_utf8(response)
def getShow(self, name): """ Gets basic info about the show with given 'name'. Arguments: name {String} -- The name of the show you are searching for. Raises: InvalidInput: Raises if a non string is entered for name. ShowNotFound: Raises if no show was found for the given name/alias. Returns: dict -- Returns a dictionary containg basic data about the show. """ if not self.__authorized: self._authorize() params = { "name": name } r = get_html('https://api.thetvdb.com/search/series?name='+urllib.quote(name), headers=self.headers).json() logging.warning(r) error = r.get('Error') if error: return {'data':[]} return r
def auth_loop(self, dp): if dp.iscanceled(): dp.close() return time.sleep(self.OauthTimeStep) url = "client_id=%s&code=%s" % (self.ClientID, self.DeviceCode) url = self.OauthUrl + self.DeviceCredUrl % url response = get_html(url).json() error = response.get("error", "OK") if error == 1 or 'client_id' not in response: return else: dp.close() Addon.setSetting('rd.client_id', response['client_id']) Addon.setSetting('rd.secret', response['client_secret']) try: resuaddon.setSetting('RealDebridResolver_client_id', response['client_id']) resuaddon.setSetting('RealDebridResolver_client_secret', response['client_secret']) except: pass self.ClientSecret = response['client_secret'] self.ClientID = response['client_id'] logging.warning('All Good') return
def auth(self): data = {'client_id': self.client_id, 'response_type': 'device_code'} token = get_html('https://www.premiumize.me/token', data=data).json() expiry = token['expires_in'] token_ttl = token['expires_in'] poll_again = True success = False copy2clip(token['user_code']) tools.progressDialog.create( tools.addonName, 'Open this link in a browser: {}'.format( colorString(token['verification_uri'])) + '\n' + 'Enter the code: {}'.format(colorString(token['user_code']))) tools.progressDialog.update(0) logging.warning(token) while poll_again and not token_ttl <= 0 and not tools.progressDialog.iscanceled( ): poll_again, success = self.poll_token(token['device_code']) progress_percent = 100 - int((float( (expiry - token_ttl) / expiry) * 100)) tools.progressDialog.update(progress_percent) time.sleep(token['interval']) token_ttl -= int(token['interval']) tools.progressDialog.close() if success: tools.showDialog.ok(tools.addonName, 'Authentication is completed')
def auth(self): self.ClientSecret = '' self.ClientID = 'X245A4XAIBGVM' url = ("client_id=%s&new_credentials=yes" % self.ClientID) url = self.OauthUrl + self.DeviceCodeUrl % url response = get_html(url).json() if 1: copy2clip(response['user_code']) dp = xbmcgui . DialogProgress ( ) dp.create("Real Debrid "+Addon.getLocalizedString(32282),Addon.getLocalizedString(32283) + ' %s' % colorString('https://real-debrid.com/device')+'\n'+ Addon.getLocalizedString(32284) + ' %s' % colorString(response['user_code'])+'\n'+ Addon.getLocalizedString(32285)) dp.update(-1, Addon.getLocalizedString(32283) + ' %s' % colorString('https://real-debrid.com/device')+'\n'+ Addon.getLocalizedString(32284) + ' %s' % colorString(response['user_code'])+'\n'+Addon.getLocalizedString(32285)) self.OauthTimeout = int(response['expires_in']) self.OauthTimeStep = int(response['interval']) self.DeviceCode = response['device_code'] while self.ClientSecret == '': self.auth_loop(dp) if dp.iscanceled(): dp.close() return 0 xbmc.sleep(300) self.token_request() return 0
def get_links(tv_movie, original_title, season_n, episode_n, season, episode, show_original_year, id): global global_var, stop_all all_links = [] if tv_movie == 'movie': search_url = ( '%s %s' % (clean_name(original_title, 1), show_original_year)).lower() else: search_url = ( '%s s%se%s' % (clean_name(original_title, 1), season_n, episode_n)).lower() for page in range(0, 4): params = ( ('sort', 'seeders'), ('q', search_url), ('category', 'all'), ('skip', str(page * 40)), ('fuv', 'yes'), ) x = get_html('https://solidtorrents.net/api/v1/search', headers=base_header, params=params, timeout=10).json() for items in x['results']: if stop_all == 1: break link = items['magnet'] size = float(items['size']) / (1024 * 1024 * 1024) title = items['title'] if '4k' in title: res = '2160' elif '2160' in title: res = '2160' elif '1080' in title: res = '1080' elif '720' in title: res = '720' elif '480' in title: res = '480' elif '360' in title: res = '360' else: res = 'HD' max_size = int(Addon.getSetting("size_limit")) if size < max_size: all_links.append((title, link, str(size), res)) global_var = all_links return global_var
def get_url(self, url): if self.headers['Authorization'] == 'Bearer ': tools.log('User is not authorised to make PM requests') return None url = "https://www.premiumize.me/api{}".format(url) req = get_html(url, timeout=10, headers=self.headers).json() return req
def get_url_new(self, url, data, fail_check=False): original_url = url url = self.BaseUrl + url url += "?auth_token=%s" % self.token response = get_html(url, data=data, put=True).json() return response
def _authorize(self): r = get_html( self.config['loginURL'], json=self.config['authPayload'], headers=self.headers).json() error = r.get('Error') if error: raise InvalidCredentials token = r.get('token') self.headers['Authorization'] = 'Bearer %s'%token self.__authorized = True
def _get_v3(self, url, params={}): headers = {'Authorization': self.auth} response = get_html(url, params=params, headers=headers).content() response = re.compile(self.regex, re.DOTALL).findall(response)[0] response = response + '}' try: return to_utf8(json.loads(response)) except: return to_utf8(response)
def poll_auth(self, poll_url): resp = get_html(poll_url).json()['data'] if resp['activated']: self.tools.setSetting('alldebrid.token', resp['apikey']) self.token = resp['apikey'] return True, 0 return False, int(resp['expires_in'])
def _getImages(self, showID, imageType): images = [] params = { 'keyType': imageType } r = get_html(self.config['seriesEndpoint'] + "%s/images/query"%showID, params=params, headers=self.headers).json() error = r.get('Error') if error: raise NoImagesFound("No images were found for the show of that type") for image in r['data']: images.append(self.config['imageURL'] + image['fileName']) return images
def next_level(url, icon, fanart, plot, name, id): import posixpath if id == '247': table_name = 'twenty_four_seven' table_key = 'appMiehwc18Akz8Zv' elif id == 'Tv_channels': table_key = 'appw1K6yy7YtatXbm' table_name = 'TV_channels' elif id == 'Sports_channels': table_key = 'appFVmVwiMw0AS1cJ' table_name = 'Sports_channels' ur = posixpath.join('https://api.airtable.com/', 'v0', table_key, table_name) headers = {'Authorization': 'Bearer {0}'.format('keyikW1exArRfNAWj')} x = get_html(ur, headers=headers, verify=False).json() all_d = [] for field in x['records']: links = [] res = field['fields'] title = res['channel'] channel = res['channel'] thumbnail = res['thumbnail'] fanart = res['fanart'] category = res['category'] if len(thumbnail) < 2: thumbnail = icon if len(res['link']) > 2: links.append(res['link']) if len(res['link2']) > 2: links.append(res['link2']) if len(res['link3']) > 2: links.append(res['link3']) if len(links) == 0: continue if len(links) > 1: f_link = '$$$$'.join(links) else: f_link = links[0] aa = addLink(title, f_link, 6, False, thumbnail, fanart, category, original_title=title, place_control=True) all_d.append(aa) xbmcplugin.addDirectoryItems(int(sys.argv[1]), all_d, len(all_d))
def next_level(url, icon, fanart, plot, name, id): param_string = base64.b64decode(id).decode('utf-8') param_string = param_string.split('|') view = param_string[4] sort = param_string[3] maxRecords = param_string[2] api_key = param_string[5] # App ID, Table ID, Max Results, Sort ID, View Mode, API Key headers = {'Authorization': 'Bearer {}'.format(api_key)} import posixpath ur = posixpath.join('https://api.airtable.com/', 'v0', param_string[0], param_string[1]) x = get_html(ur, headers=headers, verify=False).json() all_d = [] for field in x['records']: links = [] res = field['fields'] title = res['channel'] channel = res['channel'] thumbnail = res['thumbnail'] fanart = res['fanart'] category = res['category'] if len(thumbnail) < 2: thumbnail = icon if len(res['link']) > 2: links.append(res['link']) if len(res['link2']) > 2: links.append(res['link2']) if len(res['link3']) > 2: links.append(res['link3']) if len(links) == 0: continue if len(links) > 1: f_link = '$$$$'.join(links) else: f_link = links[0] aa = addLink(title, f_link, 6, False, thumbnail, fanart, category, original_title=title, place_control=True) all_d.append(aa) xbmcplugin.addDirectoryItems(int(sys.argv[1]), all_d, len(all_d))
def post_url(self, url, data): if self.headers['Authorization'] == 'Bearer ': tools.log('User is not authorised to make PM requests') xbmc.executebuiltin( (u'Notification(%s,%s)' % ('Error', 'User is not authorised to make PM requests'))) return None url = "https://www.premiumize.me/api{}".format(url) logging.warning('f_url') logging.warning(url) req = get_html(url, headers=self.headers, data=data, timeout=10).json() logging.warning(req) return req
def get_youtube_link5(url): import requests headers = { 'authority': 'y2mate.guru', 'accept': 'application/json, text/plain, */*', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36', 'content-type': 'application/json;charset=UTF-8', 'origin': 'https://y2mate.guru', 'sec-fetch-site': 'same-origin', 'sec-fetch-mode': 'cors', 'sec-fetch-dest': 'empty', 'referer': 'https://y2mate.guru/en7/', 'accept-language': 'he-IL,he;q=0.9,en-US;q=0.8,en;q=0.7', } x = get_html('https://y2mate.guru/en7/', headers=headers).content() regex = 'name="csrfmiddlewaretoken" value="(.+?)"' m = re.compile(regex).findall(x) cookies = {'csrftoken': m[0]} data = '{"url":"%s"}' % url response = get_html('https://y2mate.guru/api/convert', headers=headers, data=data, cookies=cookies).json() max = 0 f_url = '' for items in response['url']: if items['attr']['class'] == 'no-audio': continue if int(items['quality']) > max: max = int(items['quality']) f_url = items['url'] logging.warning(f_url) return f_url
def _getShowID(self, name, accuracy): params = { 'name': name } r = get_html(self.config['searchEndpoint'], params=params, headers=self.headers).json() error = r.get('Error') if error: raise ShowNotFound for show in r['data']: if SequenceMatcher(None, name.lower(), show['seriesName'].lower()).ratio() >= accuracy: return show['id'] for alias in show['aliases']: if SequenceMatcher(None, name.lower(), alias.lower()).ratio() >= accuracy: return show['id'] return -1
def get_url(self, url, fail_check=False): original_url = url url = self.BaseUrl + url if not fail_check: if '?' not in url: url += "?auth_token=%s" % self.token else: url += "&auth_token=%s" % self.token a=time.time() logging.warning('Send req time:'+str(a)) response = get_html(url,headers=base_header).json() logging.warning('Got req time:'+str(a)) if 'error_code' in response: logging.warning('error_code') logging.warning(url) logging.warning(response) self.count_rd+=1 if self.count_rd>4: xbmcgui.Dialog().ok('Error', 'Error in RD') return '0' self.refreshToken() response = self.get_url(original_url, fail_check=False) jresonce= response if type(jresonce)!=dict: jresonce=False if jresonce: if 'error' in jresonce: logging.warning(jresonce) if 'bad_token' in jresonce['error'] or 'Bad Request' in jresonce['error']: if not fail_check: self.count_rd+=1 if self.count_rd>4: xbmcgui.Dialog().ok('Error', 'Error in RD') return '0' self.refreshToken() response = self.get_url(original_url, fail_check=False) return response
def get_links(tv_movie, original_title, season_n, episode_n, season, episode, show_original_year, id): global global_var, stop_all import xbmc, sys path = xbmc.translatePath( 'special://home/addons/script.module.resolveurl/lib') sys.path.append(path) path = xbmc.translatePath('special://home/addons/script.module.six/lib') sys.path.append(path) path = xbmc.translatePath( 'special://home/addons/script.module.kodi-six/libs') sys.path.append(path) import resolveurl all_links = [] if tv_movie == 'movie': return [] y = get_html( 'http://www1.watchserieshd.tv/series/%s-season-%s-episode-%s' % (clean_name(original_title, 1).replace(' ', '-'), season, episode), headers=base_header).content() regex = 'data-video="(.+?)"' lk_pre = re.compile(regex, re.DOTALL).findall(y) for f_lk in lk_pre: f_lk_r = False if 'vev.io' in f_lk.lower() or 'vidup.me' in f_lk.lower(): continue try: if '#caption=' in f_lk: f_lk = f_lk.split('#caption=')[0] f_lk_r = resolveurl.resolve(f_lk) except: pass size = 0 title = clean_name(original_title, 1) + '.S%sE%s' % (season_n, episode_n) if f_lk_r: all_links.append( (title, 'Direct_link$$$' + f_lk_r, str(size), 'HD')) global_var = all_links return global_var
def get_links(tv_movie,original_title,season_n,episode_n,season,episode,show_original_year,id): global global_var,stop_all all_links=[] if tv_movie=='tv': search_url=('{0}%20s{1}e{2}'.format(clean_name(original_title,1).replace(' ','%20'),season_n,episode_n)).lower() else: search_url=clean_name(original_title,1).replace(' ','%20')+'%20'+show_original_year if 1: x=get_html('https://api.magsearch.net/search?keywords=%s&itemn=200&start=0&filetype=video&sortby=hot&userid=99999999999999999999999999999999'%(search_url.replace(' ','%20')),headers=base_header,timeout=10).json() max_size=int(Addon.getSetting("size_limit")) dev_num=1024*1024*1024 for items in x: title=items['name'] lk=items['url'] size=(float(items['length'])/dev_num) if int(size)<max_size: if '2160' in title: res='2160' if '1080' in title: res='1080' elif '720' in title: res='720' elif '480' in title: res='480' elif '360' in title: res='360' else: res='HD' all_links.append((title,lk,str(size),res)) global_var=all_links return global_var
def refreshToken(self): import time postData = { 'grant_type': 'http://oauth.net/grant_type/device/1.0', 'code': self.refresh, 'client_secret': self.ClientSecret, 'client_id': self.ClientID } url = self.OauthUrl + 'token' response = get_html(url, data=postData).json() #response =self.post_url(url, postData=postData) logging.warning(response) if 'error_code' in response: xbmcgui.Dialog().ok( Addon.getAddonInfo('name'), Addon.getLocalizedString(32286) + ', [B]' + 'error_code' + '[/B]') self.auth() return '0' try: if 'access_token' not in response: if 'error' in response: added = str(response['error']) else: added = '' xbmcgui.Dialog().ok( Addon.getAddonInfo('name'), Addon.getLocalizedString(32286) + ', [B]' + added + '[/B]') self.auth() return '0' except: pass self.token = response['access_token'] self.refresh = response['refresh_token'] try: resuaddon.setSetting('RealDebridResolver_token', self.token) resuaddon.setSetting('RealDebridResolver_refresh', self.refresh) resuaddon.setSetting('RealDebridResolver_refresh', self.refresh) except: pass Addon.setSetting('rd.auth', self.token) Addon.setSetting('rd.refresh', self.refresh) Addon.setSetting('rd.expiry', str(time.time() + int(response['expires_in'])))
def get_url(self, url, token_req=False): if self.token == '': return url = '{}{}'.format(self.base_url, url) if not '?' in url: url += '?' url += 'agent={}'.format(self.agent_identifier) else: url += '&agent={}'.format(self.agent_identifier) if token_req: url += '&apikey={}'.format(self.token) return get_html(url).json()
def get_api(self): if 1: #try: api_key = __addon__.getSetting('furk_api_key') if not api_key: if not self.user_name or not self.user_pass: return else: link = (self.base_link + self.login_link % (self.user_name, self.user_pass)) p = get_html(link, timeout=self.timeout).json() if p['status'] == 'ok': api_key = p['api_key'] __addon__.setSetting('furk_api_key', api_key) else: pass return api_key