def yandex(url): try: cookie = client.request(url, output='cookie') r = client.request(url, cookie=cookie) r = re.sub(r'[^\x00-\x7F]+', ' ', r) sk = re.findall('"sk"\s*:\s*"([^"]+)', r)[0] idstring = re.findall('"id"\s*:\s*"([^"]+)', r)[0] idclient = binascii.b2a_hex(os.urandom(16)) post = { 'idClient': idclient, 'version': '3.9.2', 'sk': sk, '_model.0': 'do-get-resource-url', 'id.0': idstring } post = urllib_parse.urlencode(post) r = client.request('https://yadi.sk/models/?_m=do-get-resource-url', post=post, cookie=cookie) r = json.loads(r) url = r['models'][0]['data']['file'] return url except: return
def searchMovie(self, title, year, aliases, headers): try: for alias in aliases: url = '%s/full-movie/%s' % (self.base_link, cleantitle.geturl(alias['title'])) url = client.request(url, headers=headers, output='geturl', timeout='10') if url is not None and url != self.base_link: break if url is None: for alias in aliases: url = '%s/full-movie/%s-%s' % (self.base_link, cleantitle.geturl( alias['title']), year) url = client.request(url, headers=headers, output='geturl', timeout='10') if url is not None and url != self.base_link: break return url except: log_utils.log('cartoonhd - Exception', 1) return
def sources(self, url, hostDict, hostprDict): try: sources = [] if url == None: return sources data = urlparse.parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) aliases = eval(data['aliases']) headers = {} title = data['tvshowtitle'] if 'tvshowtitle' in data else data['title'] year = data['year'] if 'tvshowtitle' in data: episode = data['episode'] season = data['season'] url = self._search(title, year, aliases, headers) url = url.replace('online-free', 'season-%s-episode-%s-online-free' % (season, episode)) else: episode = None year = data['year'] url = self._search(data['title'], data['year'], aliases, headers) url = url if 'http' in url else urlparse.urljoin(self.base_link, url) result = client.request(url); result = client.parseDOM(result, 'li', attrs={'class':'link-button'}) links = client.parseDOM(result, 'a', ret='href') i = 0 for l in links: #if i == 15: #break try: l = l.split('=')[1] l = urlparse.urljoin(self.base_link, self.video_link % l) result = client.request(l, post={}, headers={'Referer':url}) u = result if 'http' in result else 'http:' + result if ' href' in u: u = 'http:' + re.compile(r" href='(.+?)'").findall(u)[0] if 'google' in u: valid, hoster = source_utils.is_host_valid(u, hostDict) urls, host, direct = source_utils.check_directstreams(u, hoster) for x in urls: sources.append({'source': host, 'quality': x['quality'], 'language': 'en', 'url': x['url'], 'direct': direct, 'debridonly': False}) else: valid, hoster = source_utils.is_host_valid(u, hostDict) if not valid: continue try: u.decode('utf-8') sources.append({'source': hoster, 'quality': 'sd', 'language': 'en', 'url': u, 'direct': False, 'debridonly': False}) i+=1 except: pass except: pass return sources except: return sources
def sources(self, url, hostDict, hostprDict): try: sources = [] if url == None: return sources hostDict = hostprDict + hostDict r = client.request(url) r = re.compile( 'class="watch-button" data-actuallink="(.+?)"').findall(r) for url in r: if url in str(sources): continue quality, info = source_utils.get_release_quality(url, url) valid, host = source_utils.is_host_valid(url, hostDict) if valid: sources.append({ 'source': host, 'quality': quality, 'language': 'en', 'url': url, 'direct': False, 'debridonly': False }) return sources except: log_utils.log('Watchepisodes4 Exception', 1) return sources
def sources(self, url, hostDict, hostprDict): try: sources = [] if url is None: return sources if debrid.status() is False: raise Exception() html = client.request(url) link = re.findall('href="(magnet:.+?)"', html, re.DOTALL) for link in link: link = str(client.replaceHTMLCodes(link).split('&tr')[0]) quality, info = source_utils.get_release_quality(link, link) try: size = re.findall('((?:\d+\.\d+|\d+\,\d+|\d+)\s*(?:GB|GiB|MB|MiB))', html)[-1] div = 1 if size.endswith(('GB', 'GiB')) else 1024 size = float(re.sub('[^0-9|/.|/,]', '', size)) / div size = '%.2f GB' % size info.append(size) except: pass info = ' | '.join(info) sources.append({'source': 'Torrent', 'quality': quality, 'language': 'en', 'url': link, 'info': info, 'direct': False, 'debridonly': True}) return sources except: return sources
def get_size(url): try: size = client.request(url, output='file_size') if size == '0': size = False size = convert_size(size) return size except: return False
def resolve(self, url): if 'google' in url: return directstream.googlepass(url) elif 'vidcloud' in url: r = client.request(url) url = re.findall("file: '(.+?)'", r)[0] return url else: return url
def _search(self, title, year, aliases, headers): try: q = urlparse.urljoin(self.base_link, self.search_link % urllib.quote_plus(cleantitle.getsearch(title))) r = client.request(q) r = client.parseDOM(r, 'div', attrs={'class':'ml-img'}) r = zip(client.parseDOM(r, 'a', ret='href'), client.parseDOM(r, 'img', ret='alt')) url = [i for i in r if cleantitle.get(title) == cleantitle.get(i[1]) and year in i[1]][0][0] return url except: pass
def get_sources(self, link): try: url = link[0].encode('ascii', errors='ignore').decode('ascii', errors='ignore').replace(' ', ' ') if '/torrent/' not in url: return name = link[1].encode('ascii', errors='ignore').decode('ascii', errors='ignore').replace(' ', '.').replace(' ', '.') if any(x in url.lower() for x in ['french', 'italian', 'spanish', 'truefrench', 'dublado', 'dubbed']): raise Exception() t = name.split(self.hdlr)[0].replace(self.year, '').replace('(', '').replace(')', '').replace('&', 'and').replace('.US.', '.').replace('.us.', '.') if cleantitle.get(t) != cleantitle.get(self.title): return if self.hdlr not in name: return if not url.startswith('http'): link = urllib.parse.urljoin(self.base_link, url) link = client.request(link) if link is None: return infohash = re.findall('<b>Infohash</b></td><td valign=top>(.+?)</td>', link, re.DOTALL)[0] url = 'magnet:?xt=urn:btih:%s&dn=%s' % (infohash, name) if url in str(self.sources): return try: seeders = int(re.findall('<font color=red>(.*?)</font>.+Seeds', link, re.DOTALL)[0].replace(',', '')) if self.min_seeders > seeders: return except: pass quality, info = source_utils.get_release_quality(name, url) try: size = re.findall('((?:\d+\,\d+\.\d+|\d+\.\d+|\d+\,\d+|\d+)\s*(?:GiB|MiB|GB|MB))', link)[0] div = 1 if size.endswith('GB') else 1024 size = float(re.sub('[^0-9|/.|/,]', '', size.replace(',', '.'))) / div size = '%.2f GB' % size info.insert(0, size) except: size = '0' pass info = ' | '.join(info) self.sources.append({'source': 'torrent', 'quality': quality, 'language': 'en', 'url': url, 'info': info, 'direct': False, 'debridonly': True}) except: source_utils.scraper_error('TORRENTFUNK') pass
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if not url: return r = client.request(url) r = re.compile('<a title=".+? Season ' + season + ' Episode ' + episode + ' .+?" href="(.+?)">').findall(r) for url in r: return url except: return
def _getAniList(url): try: url = urllib_parse.urljoin('https://anilist.co', '/api%s' % url) return client.request(url, headers={ 'Authorization': '%s %s' % cache.get(_getToken, 1), 'Content-Type': 'application/x-www-form-urlencoded' }) except: pass
def geturl(url): try: r = client.request(url, output='geturl') if r is None: return r host1 = re.findall('([\w]+)[.][\w]+$', urllib_parse.urlparse( url.strip().lower()).netloc)[0] host2 = re.findall('([\w]+)[.][\w]+$', urllib_parse.urlparse(r.strip().lower()).netloc)[0] if host1 == host2: return r proxies = sorted(get(), key=lambda x: random.random()) proxies = sorted(proxies, key=lambda x: random.random()) proxies = proxies[:3] for p in proxies: p += urllib_parse.quote_plus(url) r = client.request(p, output='geturl') if r is not None: return parse(r) except: pass
def sources(self, url, hostDict, hostprDict): sources = [] try: if url is None: return sources if debrid.status() is False: raise Exception() data = urllib.parse.parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) title = data['tvshowtitle'] if 'tvshowtitle' in data else data['title'] hdlr = 'S%02dE%02d' % (int(data['season']), int(data['episode'])) if 'tvshowtitle' in data else data['year'] query = '%s s%02de%02d' % ( data['tvshowtitle'], int(data['season']), int(data['episode'])) if 'tvshowtitle' in data else '%s %s' % ( data['title'], data['year']) query = re.sub('(\\\|/| -|:|;|\*|\?|"|\'|<|>|\|)', ' ', query) url = self.search_link % urllib.parse.quote_plus(query) url = urllib.parse.urljoin(self.base_link, url) try: r = client.request(url) posts = client.parseDOM(r, 'div', attrs={'class': 'tgxtable'}) for post in posts: link = re.findall('a href="(magnet:.+?)"', post, re.DOTALL) try: size = re.findall('((?:\d+\,\d+\.\d+|\d+\.\d+|\d+\,\d+|\d+)\s*(?:GiB|MiB|GB|MB))', post)[0] div = 1 if size.endswith('GB') else 1024 size = float(re.sub('[^0-9|/.|/,]', '', size.replace(',', '.'))) / div size = '%.2f GB' % size except BaseException: size = '0' for url in link: if hdlr not in url: continue url = url.split('&tr')[0] quality, info = source_utils.get_release_quality(url) if any(x in url for x in ['FRENCH', 'Ita', 'italian', 'TRUEFRENCH', '-lat-', 'Dublado']): continue info.append(size) info = ' | '.join(info) sources.append( {'source': 'Torrent', 'quality': quality, 'language': 'en', 'url': url, 'info': info, 'direct': False, 'debridonly': True}) except: return return sources except: return sources
def sources(self, url, hostDict, hostprDict): sources = [] try: if url == None: return sources data = parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) aliases = eval(data['aliases']) if 'tvshowtitle' in data: ep = data['episode'] url = '%s/film/%s-season-%01d/watching.html?ep=%s' % (self.base_link, cleantitle.geturl(data['tvshowtitle']), int(data['season']), ep) r = client.request(url, timeout='10', output='geturl') if url == None: url = self.searchShow(data['tvshowtitle'], data['season'], aliases) else: url = self.searchMovie(data['title'], data['year'], aliases) if url == None: raise Exception() r = cfScraper.get(url).content r = ensure_text(r, errors='ignore') r = client.parseDOM(r, 'div', attrs={'class': 'les-content'}) if 'tvshowtitle' in data: ep = data['episode'] links = client.parseDOM(r, 'a', attrs={'episode-data': ep}, ret='player-data') else: links = client.parseDOM(r, 'a', ret='player-data') for link in links: try: if link.startswith('//'): link = 'https:' + link host = re.findall('([\w]+[.][\w]+)$', urlparse(link.strip().lower()).netloc)[0] if not host in hostDict: raise Exception() host = client.replaceHTMLCodes(host) host = host.encode('utf-8') if 'load.php' not in link: sources.append({'source': host, 'quality': '720p', 'language': 'en', 'url': link, 'direct': False, 'debridonly': False}) except: pass return sources except: log_utils.log('123movies0 exception', 1) return sources
def sources(self, url, hostDict, hostprDict): try: self._sources = [] if url is None: return self._sources data = parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) title = data['tvshowtitle'] if 'tvshowtitle' in data else data[ 'title'] hdlr = 's%02de%02d' % (int(data['season']), int( data['episode'])) if 'tvshowtitle' in data else data['year'] query = '%s s%02de%02d' % ( data['tvshowtitle'], int(data['season']), int(data['episode'])) if 'tvshowtitle' in data else '%s %s' % ( data['title'], data['year']) query = re.sub('(\\\|/| -|:|;|\*|\?|"|\'|<|>|\|)', ' ', query) query = self.search_link % cleantitle.geturl(query) url = urljoin(self.base_link, query) r = client.request(url) posts = dom_parser2.parse_dom(r, 'div', {'class': 'eTitle'}) posts = [ dom_parser2.parse_dom(i.content, 'a', req='href') for i in posts if i ] posts = [(i[0].attrs['href'], re.sub('<.+?>', '', i[0].content)) for i in posts if i] posts = [ (i[0], i[1]) for i in posts if (cleantitle.get_simple(i[1].split(hdlr)[0]) == cleantitle.get(title) and hdlr.lower() in i[1].lower()) ] self.hostDict = hostDict + hostprDict threads = [] for i in posts: threads.append(workers.Thread(self._get_sources, i)) [i.start() for i in threads] [i.join() for i in threads] alive = [x for x in threads if x.is_alive() == True] while alive: alive = [x for x in threads if x.is_alive() == True] time.sleep(0.1) return self._sources except Exception: return self._sources
def movie(self, imdb, title, localtitle, aliases, year): try: search_id = cleantitle.getsearch(title) url = urlparse.urljoin(self.base_link, self.search_link) url = url % (search_id.replace(':', ' ').replace(' ', '+')) search_results = client.request(url) match = re.compile('<a href="/watch/(.+?)" title="(.+?)">', re.DOTALL).findall(search_results) for row_url, row_title in match: row_url = self.base_link + '/watch/%s' % row_url if cleantitle.get(title) in cleantitle.get(row_title): return row_url return except: return
def __get_base_url(self, fallback): try: for domain in self.domains: try: url = 'https://%s' % domain result = client.request(url, limit=1, timeout='4') search_n = re.findall('<title>(.+?)</title>', result, re.DOTALL)[0] if search_n and 'EZTV' in search_n: return url except Exception: pass except Exception: pass return fallback
def sources(self, url, hostDict, hostprDict): sources = [] try: if url == None: return sources data = parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) title = data['title'] year = data['year'] if int(year) > 1970: return sources scrape = title.lower().replace(' ','+') #start_url = self.search_link %(self.goog,scrape,year) start_url = self.base_link + self.search_link % scrape html = client.request(start_url) posts = client.parseDOM(html, 'div', attrs={'class': 'post'}) for post in posts: url = client.parseDOM(post, 'a', ret='href')[0] if self.base_link in url: if 'webcache' in url: continue if cleantitle.geturl(title) in url: html2 = client.request(url) chktitle = re.compile('<title.+?>(.+?)</title>',re.DOTALL).findall(html2)[0] if title in chktitle and year in chktitle: links = client.parseDOM(html2, 'source', ret='src') for link in links: sources.append({'source': 'direct', 'quality': 'SD', 'language': 'en', 'url': link, 'info': '', 'direct': True, 'debridonly': False}) return sources except: log_utils.log('BNWM1 - Exception', 1) return sources
def vk(url): try: query = urllib_parse.parse_qs(urllib_parse.urlparse(url).query) try: oid, video_id = query['oid'][0], query['id'][0] except: oid, video_id = re.findall('\/video(.*)_(.*)', url)[0] sources_url = 'http://vk.com/al_video.php?act=show_inline&al=1&video=%s_%s' % ( oid, video_id) html = client.request(sources_url) html = re.sub(r'[^\x00-\x7F]+', ' ', html) sources = re.findall('(\d+)x\d+.+?(http.+?\.m3u8.+?)n', html) if not sources: sources = re.findall('"url(\d+)"\s*:\s*"(.+?)"', html) sources = [(i[0], i[1].replace('\\', '')) for i in sources] sources = dict(sources) url = [] try: url += [{'quality': 'HD', 'url': sources['720']}] except: pass try: url += [{'quality': 'SD', 'url': sources['540']}] except: pass try: url += [{'quality': 'SD', 'url': sources['480']}] except: pass if not url == []: return url try: url += [{'quality': 'SD', 'url': sources['360']}] except: pass if not url == []: return url try: url += [{'quality': 'SD', 'url': sources['240']}] except: pass if not url == []: return url except: return
def _getToken(): result = urllib_parse.urlencode({ 'grant_type': 'client_credentials', 'client_id': 'kodiexodus-7erse', 'client_secret': 'XelwkDEccpHX2uO8NpqIjVf6zeg' }) result = client.request( 'https://anilist.co/api/auth/access_token', post=result, headers={'Content-Type': 'application/x-www-form-urlencoded'}, error=True) result = utils.json_loads_as_str(result) return result['token_type'], result['access_token']
def cldmailru(url): try: v = url.split('public')[-1] r = client.request(url) r = re.sub(r'[^\x00-\x7F]+', ' ', r) tok = re.findall('"tokens"\s*:\s*{\s*"download"\s*:\s*"([^"]+)', r)[0] url = re.findall('"weblink_get"\s*:\s*\[.+?"url"\s*:\s*"([^"]+)', r)[0] url = '%s%s?key=%s' % (url, v, tok) return url except: return
def googlepass(url): try: try: headers = dict(urllib_parse.parse_qsl(url.rsplit('|', 1)[1])) except: headers = None url = url.split('|')[0].replace('\\', '') url = client.request(url, headers=headers, output='geturl') if 'requiressl=yes' in url: url = url.replace('http://', 'https://') else: url = url.replace('https://', 'http://') if headers: url += '|%s' % urllib_parse.urlencode(headers) return url except: return
def searchShow(self, title, season, episode, aliases, headers): try: for alias in aliases: url = '%s/tv-show/%s/season/%01d/episode/%01d' % ( self.base_link, cleantitle.geturl(title), int(season), int(episode)) url = client.request(url, headers=headers, output='geturl', timeout='10') if url is not None and url != self.base_link: break return url except: log_utils.log('cartoonhd - Exception', 1) return
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: tvshowtitle = cleantitle.geturl(tvshowtitle) url = self.base_link + self.search_link % (tvshowtitle.replace(' ', '+').replace('-', '+').replace('++', '+')) page = client.request(url) items = client.parseDOM(page, 'div', attrs={'class': 'content-left'}) for item in items: match = re.compile('<a href="(.+?)">', re.DOTALL).findall(item) for url in match: if cleantitle.get(tvshowtitle) in cleantitle.get(url): url = self.base_link + url return url return except: failure = traceback.format_exc() log_utils.log('watchseriestv - Exception: \n' + str(failure)) return
def _get_sources(self, url): try: item = client.request(url[0]) title = url[1] links = dom_parser2.parse_dom(item, 'a', req='href') links = [i.attrs['href'] for i in links] info = [] try: size = re.findall( '((?:\d+\.\d+|\d+\,\d+|\d+)\s*(?:GiB|MiB|GB|MB))', item)[0] div = 1 if size.endswith(('GB', 'GiB')) else 1024 size = float(re.sub('[^0-9|/.|/,]', '', size)) / div size = '%.2f GB' % size info.insert(0, size) except Exception: pass info = ' | '.join(info) for url in links: if 'youtube' in url: continue if any(x in url.lower() for x in ['.rar.', '.zip.', '.iso.']) or any( url.lower().endswith(x) for x in ['.rar', '.zip', '.iso']): raise Exception() if any(x in url.lower() for x in ['youtube', 'sample', 'trailer']): raise Exception() valid, host = source_utils.is_host_valid(url, self.hostDict) if not valid: continue host = client.replaceHTMLCodes(host) quality, info2 = source_utils.get_release_quality(title, url) self._sources.append({ 'source': host, 'quality': quality, 'language': 'en', 'url': url, 'info': info, 'direct': False, 'debridonly': False }) except Exception: pass
def sources(self, url, hostDict, hostprDict): try: hostDict = hostprDict + hostDict sources = [] if url == None: return sources page = client.request(url) links = re.compile('<a rel="nofollow" target="blank" href="(.+?)"', re.DOTALL).findall(page) for link in links: link = "https:" + link if not link.startswith('http') else link valid, host = source_utils.is_host_valid(link, hostDict) if valid: quality, info = source_utils.get_release_quality(link, link) sources.append({'source': host, 'quality': quality, 'language': 'en', 'url': link, 'info': info, 'direct': False, 'debridonly': False}) return sources except: failure = traceback.format_exc() log_utils.log('watchseriestv - Exception: \n' + str(failure)) return sources
def sources(self, url, hostDict, hostprDict): self._sources = [] try: if url is None: return self._sources if debrid.status() is False: return self._sources data = parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) self.title = data[ 'tvshowtitle'] if 'tvshowtitle' in data else data['title'] self.title = cleantitle.get_query(self.title) self.hdlr = 'S%02dE%02d' % ( int(data['season']), int(data['episode']) ) if 'tvshowtitle' in data else data['year'] query = '%s S%02dE%02d' % ( self.title, int(data['season']), int(data['episode'])) if 'tvshowtitle' in data else '%s %s' % ( self.title, data['year']) query = re.sub(r'(\\\|/| -|:|;|\*|\?|"|\'|<|>|\|)', ' ', query) if 'tvshowtitle' in data: url = self.search.format('8', quote(query)) else: url = self.search.format('4', quote(query)) self.hostDict = hostDict + hostprDict headers = {'User-Agent': client.agent()} _html = client.request(url, headers=headers) threads = [] for i in re.findall(r'<item>(.+?)</item>', _html, re.DOTALL): threads.append(workers.Thread(self._get_items, i)) [i.start() for i in threads] [i.join() for i in threads] return self._sources except BaseException: return self._sources
def sources(self, url, hostDict, hostprDict): self.sources = [] try: if url is None: return self.sources if debrid.status() is False: return self.sources data = parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) self.title = data['tvshowtitle'] if 'tvshowtitle' in data else data['title'] self.title = cleantitle.get_query(self.title) self.hdlr = 's%02de%02d' % (int(data['season']), int(data['episode'])) if 'tvshowtitle' in data else data['year'] self.hdlr = self.hdlr.lower() self.year = data['year'] query = '%s %s' % (self.title, self.hdlr) query = re.sub('[^A-Za-z0-9\s\.-]+', '', query) url = self.search_link % quote_plus(query) url = urljoin(self.base_link, url).replace('+', '-') try: r = client.request(url) links = re.findall('<a href="(/torrent/.+?)"', r, re.DOTALL)[:20] threads = [] for link in links: threads.append(workers.Thread(self.get_sources, link)) [i.start() for i in threads] [i.join() for i in threads] return self.sources except: log_utils.log('YourBT3 - Exception', 1) return self.sources except: log_utils.log('YourBT3 - Exception', 1) return self.sources
def cdnImport(uri, name): import imp from prophetscrapers.modules import client path = os.path.join(dataPath, 'py' + name) path = six.ensure_text(path) deleteDir(os.path.join(path, ''), force=True) makeFile(dataPath) makeFile(path) r = client.request(uri) p = os.path.join(path, name + '.py') f = openFile(p, 'w') f.write(r) f.close() m = imp.load_source(name, p) deleteDir(os.path.join(path, ''), force=True) return m
def resolve(self, url): if 'putlocker' in url: try: r = client.request(url) r = six.ensure_text(r, errors='replace') try: v = re.findall('document.write\(Base64.decode\("(.+?)"\)', r)[0] v = v.encode('utf-8') b64 = base64.b64decode(v) b64 = six.ensure_text(b64, errors='ignore') url = client.parseDOM(b64, 'iframe', ret='src')[0] url = url.replace('///', '//') except: u = client.parseDOM(r, 'div', attrs={'class': 'player'}) url = client.parseDOM(u, 'a', ret='href')[0] except: log_utils.log('plockersR Exception', 1) return url else: return url