def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} response = self.net.http_GET(web_url, headers=headers) html = response.content headers['Cookie'] = response.get_headers(as_dict=True).get('Set-Cookie', '') sources = helpers.scrape_sources(html, result_blacklist=['dl', '.mp4']) # mp4 fails source = helpers.pick_source(sources) if '.smil' in source: smil = self.net.http_GET(source, headers=headers).content sources = helpers.parse_smil_source_list(smil) return helpers.pick_source(sources) + helpers.append_headers(headers)
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} html = self.net.http_GET(web_url, headers=headers).content data = json.loads(html) if data['success'] == '0': html = self.net.http_GET('http://indavideo.hu/video/%s' % media_id).content hash = re.search('emb_hash.+?value\s*=\s*"([^"]+)', html) if not hash: raise ResolverError('File not found') web_url = self.get_url(host, hash.group(1)) html = self.net.http_GET(web_url).content data = json.loads(html) if data['success'] == '1': video_files = data['data']['video_files'] if not video_files: raise ResolverError('File removed') tokens = data['data']['filesh'] sources = [(re.search('\.(\d+)\.mp4', i).group(1), i) for i in video_files] sources = [(i[0], i[1] + '&token=%s' % tokens[i[0]]) for i in sources] try: sources = list(set(sources)) except: pass sources = sorted(sources, key=lambda x: x[0])[::-1] return helpers.pick_source(sources) raise ResolverError('File not found')
def get_media_url(self, host, media_id): headers = { 'User-Agent': common.IE_USER_AGENT } query = urlparse.parse_qs(media_id) try: oid, video_id = query['oid'][0], query['id'][0] except: oid, video_id = re.findall('(.*)_(.*)', media_id)[0] try: hash = query['hash'][0] except: hash = self.__get_hash(oid, video_id) api_url = 'http://api.vk.com/method/video.getEmbed?oid=%s&video_id=%s&embed_hash=%s' % (oid, video_id, hash) html = self.net.http_GET(api_url).content html = re.sub(r'[^\x00-\x7F]+', ' ', html) try: result = json.loads(html)['response'] except: result = self.__get_private(oid, video_id) sources = [(key[3:], result[key]) for key in result if re.match('url\d+', key)] try: sources.sort(key=lambda x: int(x[0]), reverse=True) except: pass source = helpers.pick_source(sources, self.get_setting('auto_pick') == 'true') return source + '|' + urllib.urlencode(headers) raise ResolverError('No video found')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.RAND_UA, 'Referer': web_url.replace("iframe-", "preview-")} html = self.net.http_GET(web_url, headers=headers).content if html: sources = helpers.scrape_sources(html, patterns=['''src\s*:\s*["'](?P<url>[^"']+)''']) data = re.findall("""_[^=]+=\[([^\]]+)\];""", html, re.DOTALL) if sources and data: data = data[3].replace('\\x', '').split(",") data = [x.replace('"', '').replace(' ', '').decode("hex") for x in data] key = "".join(data[7:9]) if key.startswith("embed"): key = key[6:]+key[:6] i = 0 headers.update({'Referer': web_url}) for source in sources: try: src = urlparse.urlparse(source[1]) l = list(src) b = l[2].split("/")[1:] b[0] = self.decrypt(b[0], key) l[2] = "/".join(b) sources[i] = (source[0], urlparse.urlunparse(l)) i += 1 except: i += 1 return helpers.pick_source(sources) + helpers.append_headers(headers) raise ResolverError('File not found')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} try: html = self.net.http_GET(web_url, headers=headers).content except urllib2.HTTPError as e: if e.code == 404: raise ResolverError("Video not found") srcs = re.findall(r'href="(%s&q=[^"]+)' % web_url, html, re.I) if srcs: sources = [] for src in srcs: shtml = self.net.http_GET(src, headers=headers).content strurl = helpers.parse_html5_source_list(shtml) if strurl: sources.append(strurl[0]) sources = helpers.sort_sources_list(sources) else: sources = helpers.parse_html5_source_list(html) if len(sources) > 0: return helpers.pick_source(sources) + helpers.append_headers(headers) else: raise ResolverError("Video not found")
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) html = self.net.http_GET(web_url).content try: r = re.search('flashvars.filekey=(.+?);', html) if r is None: raise Exception() r = r.group(1) try: filekey = re.compile('\s+%s="(.+?)"' % r).findall(html)[-1] except: filekey = r player_url = 'http://www.auroravid.to/api/player.api.php?key=%s&file=%s' % (filekey, media_id) html = self.net.http_GET(player_url).content r = re.search('url=(.+?)&', html) if r: stream_url = r.group(1) return stream_url except: sources = helpers.parse_html5_source_list(html) source = helpers.pick_source(sources) return source + helpers.append_headers({'User-Agent': common.FF_USER_AGENT}) raise ResolverError('File Not Found or removed')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {"User-Agent": common.FF_USER_AGENT} html = self.net.http_GET(web_url, headers=headers).content if "File Not Found" in html: raise ResolverError("File got deleted?") cookies = self.__get_cookies(html) match = re.compile("'([^']+counter\.cgi[^']+)'", re.DOTALL).findall(html) if not match: raise ResolverError("Site structure changed!") self.net.http_GET(match[0], headers=headers) data = helpers.get_hidden(html) data["imhuman"] = "Proceed to this video" common.kodi.sleep(5500) headers.update({"Referer": web_url, "Cookie": "; ".join(cookies)}) html = self.net.http_POST("http://www.flashx.tv/dl", data, headers=headers).content sources = [] for match in re.finditer("(eval\(function.*?)</script>", html, re.DOTALL): packed_data = jsunpack.unpack(match.group(1)) sources += self.__parse_sources_list(packed_data) source = helpers.pick_source(sources, self.get_setting("auto_pick") == "true") return source
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} html = self.net.http_GET(web_url, headers=headers).content if html: srcs = re.findall(r'href="(%s&q=[^"]+)' % web_url, html, re.I) if srcs: sources = [] for src in srcs: shtml = self.net.http_GET(src, headers=headers).content strurl = helpers.parse_html5_source_list(shtml) if strurl: sources.append(strurl[0]) if len(sources) > 1: try: sources.sort(key=lambda x: int(re.sub("\D", "", x[0])), reverse=True) except: common.logger.log_debug('Scrape sources sort failed |int(re.sub("\D", "", x[0])|') try: sources.sort(key=lambda x: re.sub("[^a-zA-Z]", "", x[0])) except: common.logger.log_debug('Scrape sources sort failed |re.sub("[^a-zA-Z]", "", x[0])|') else: sources = helpers.parse_html5_source_list(html) return helpers.pick_source(sources) + helpers.append_headers(headers) raise ResolverError("Video not found")
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} html = self.net.http_GET(web_url, headers=headers).content if 'File Not Found' in html: raise ResolverError('File got deleted?') cookies = self.__get_cookies(html) #match = re.search('"([^"]+counter(?:\d+|)\.cgi[^"]+)".*?<span id="cxc(?:\d+|)">(\d+)<', html, re.DOTALL) match2 = re.search('action=[\'"]([^\'"]+)', html, re.IGNORECASE) print match2.group(0) if not match2: raise ResolverError('Site structure changed!') self.net.http_GET(match2.group(1), headers=headers) data = helpers.get_hidden(html) data['imhuman'] = 'Proceed to this video' #print data #print match2.group(1) common.kodi.sleep(int(10000)*1000+500) headers.update({'Referer': web_url, 'Cookie': '; '.join(cookies)}) html = self.net.http_POST(match2.group(1), data, headers=headers).content print html sources = [] for match in re.finditer('(eval\(function.*?)</script>', html, re.DOTALL): #print match.group(0) packed_data = jsunpack.unpack(match.group(1)) #print "a",packed_data sources += self.__parse_sources_list(packed_data) source = helpers.pick_source(sources, self.get_setting('auto_pick') == 'true') return source
def get_media_url(self, host, media_id): base_url = self.get_url(host, media_id) soup = self.net.http_GET(base_url).content html = soup.decode('cp1251') vBlocks = re.findall('{(file.*?label.*?)}', html) html5 = re.findall('}\((.*?)\)\)<', html) if not vBlocks and not html5: raise ResolverError('No vsource found') data = {} data['purged_jsonvars'] = {} data['lines'] = [] if html5: for source in html5: params = source.split(',') data = self.__decodeLinks(params[0], params[3].split('|'), data) elif vBlocks: data = self.__getFlashVids() sources = [(line, data['purged_jsonvars'][line]) for line in data['lines']] try: sources.sort(key=lambda x: int(x[0][3:]), reverse=True) except: pass source = helpers.pick_source(sources) return source + helpers.append_headers({'User-Agent': common.IE_USER_AGENT})
def get_media_url(self, host, media_id): source = None logger.log('in get_media_url %s : %s' % (host, media_id)) url = 'http://www.alldebrid.com/service.php?link=%s' % (media_id) html = self.net.http_GET(url).content if html == 'login': raise ResolverError('alldebrid: Authentication Error') try: js_data = json.loads(html) except: js_data = {} if js_data.get('error'): raise ResolverError('alldebrid: %s' % (js_data['error'])) if 'streaming' in js_data: source = helpers.pick_source(js_data['streaming'].items()) elif 'link' in js_data: source = js_data['link'] else: match = re.search('''class=["']link_dl['"][^>]+href=["']([^'"]+)''', html) if match: source = match.group(1) if source: return source.encode('utf-8') else: raise ResolverError('alldebrid: no stream returned')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) response, video_urls = self._parse_google(web_url) if video_urls: video_urls.sort(key=self.__key, reverse=True) video = helpers.pick_source(video_urls) else: video = None if response is not None: res_headers = response.get_headers(as_dict=True) if 'Set-Cookie' in res_headers: self.headers['Cookie'] = res_headers['Set-Cookie'] if not video: if any(url_match in web_url for url_match in self.url_matches): video = self._parse_redirect(web_url, hdrs=self.headers) elif 'googlevideo.' in web_url: video = web_url + helpers.append_headers(self.headers) else: if any(url_match in video for url_match in self.url_matches): video = self._parse_redirect(video, hdrs=self.headers) if video: if 'plugin://' in video: # google plus embedded videos may result in this return video else: return video + helpers.append_headers(self.headers) raise ResolverError('File not found')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) html = self.net.http_GET(web_url).content data = json.loads(html) if data['success'] == '0': html = self.net.http_GET('http://indavideo.hu/video/%s' % media_id).content hash = re.search('emb_hash.+?value\s*=\s*"([^"]+)', html) if not hash: raise ResolverError('File not found') web_url = self.get_url(host, hash.group(1)) html = self.net.http_GET(web_url).content data = json.loads(html) if data['success'] == '1': flv_files = list(set(data['data']['flv_files'])) sources = [(data['data']['video_file'].rsplit('/', 1)[0] + '/' + i) for i in flv_files] sources = [(i.rsplit('.', 2)[1] + 'p', i) for i in sources] sources = sorted(sources, key=lambda x: x[0])[::-1] return helpers.pick_source(sources) raise ResolverError('File not found')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) response = self.net.http_GET(web_url) html = response.content if html: smil_id = re.search('([a-zA-Z0-9]+)(?=\|smil)', html).groups()[0] smil_url = 'http://%s/%s.smil' % (host, smil_id) result = self.net.http_GET(smil_url).content base = re.search('base="(.+?)"', result).groups()[0] srcs = re.findall('src="(.+?)"', result) try: res = re.findall('width="(.+?)"', result) except: res = res = re.findall('height="(.+?)"', result) i = 0 sources = [] for src in srcs: sources.append([str(res[i]), '%s playpath=%s' % (base, src)]) i += 1 source = helpers.pick_source(sources, self.get_setting('auto_pick') == 'true') source = source.encode('utf-8') return source raise ResolverError('No playable video found.')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) response = self.net.http_GET(web_url) html = response.content if html: try: if "config.playwire.com" in host: response = json.loads(html)["content"]["media"]["f4m"] elif not "v2" in host: response = re.findall(r"<src>(.+?)</src>", html)[0] else: response = json.loads(html)["src"] return response response = self.net.http_GET(response).content baseURL = re.findall(r"<baseURL>\s*(.+)\s*</baseURL>", response)[0] media = re.findall(r'<media url="(\S+)".+?height="(\d+)".*?/>', response) media.sort(key=lambda x: x[1], reverse=True) sources = [("%s" % self.__replaceQuality(i[1], i[1]), "%s/%s" % (baseURL, i[0])) for i in media] source = helpers.pick_source(sources, self.get_setting("auto_pick") == "true") source = source.encode("utf-8") return source except: raise ResolverError("Unable to resolve url.") raise ResolverError("No playable video found.")
def get_media_url(url, media_id): headers = {'User-Agent': common.RAND_UA} html = net.http_GET(url, headers=headers).content if html: html = html.encode('utf-8') aa_text = re.findall("""(゚ω゚ノ\s*=\s*/`m´\s*)\s*ノ.+?)</SCRIPT>""", html, re.I) if aa_text: try: aa_decoded = '' for i in aa_text: try: aa_decoded += str(aadecode.decode(re.sub('\(+゚Д゚\)+\s*\[゚o゚\]\)*\s*\+(.+?)\(+゚Д゚\s*\)+\[゚o゚\]\)+', r'(゚Д゚)[゚o゚]+\1(゚Д゚)[゚o゚])', i))) except: pass href = re.search("""\.location\s*=\s*['"]\/([^"']+)""", aa_decoded) if href: href = href.group(1) if href.startswith("http"): location = href elif href.startswith("//"): location = "http:%s" % href else: location = "http://www.speedvid.net/%s" % href headers.update({'Referer': url, 'Cookie': str((int(math.floor((900-100)*random())+100))*(int(time.time()))*(128/8))}) _html = net.http_GET(location, headers=headers).content sources = helpers.scrape_sources(_html, patterns=['''file\s*:\s*.["'](?P<url>(?=http://s(?:02|06))[^"']+)''']) if sources: del headers['Cookie'] headers.update({'Referer': location}) return helpers.pick_source(sources) + helpers.append_headers(headers) except Exception as e: raise ResolverError(e) raise ResolverError('File not found')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT, 'Referer': web_url} html = self.net.http_GET(web_url, headers=headers).content sources = self.__parse_sources_list(html) source = helpers.pick_source(sources, self.get_setting('auto_pick') == 'true') return source + helpers.append_headers(headers)
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.RAND_UA} html = self.net.http_GET(web_url, headers=headers).content if html: file_id = re.search("file_id',\s*'([^']+)",html) if file_id: headers.update({'cookie': 'lang=1; file_id={}'.format(file_id.group(1))}) html = self.net.http_GET(web_url, headers=headers).content else: html = None if html: html = html.encode('utf-8') aa_text = re.search("""(゚ω゚ノ\s*=\s*/`m´\s*)\s*ノ.+?;)\svar""", html, re.I) if aa_text: try: aa_decoded = str(aadecode.decode(aa_text.group(1))) except: raise ResolverError('Error decoding') sources = helpers.scrape_sources(aa_decoded) if sources: headers.update({'Referer': web_url}) return helpers.pick_source(sources) + helpers.append_headers(headers) raise ResolverError('Video not found')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} html = self.net.http_GET(web_url, headers=headers).content data = json.loads(html) if data['success'] == '0': html = self.net.http_GET('http://indavideo.hu/video/%s' % media_id).content hash = re.search('emb_hash.+?value\s*=\s*"([^"]+)', html) if not hash: raise ResolverError('File not found') web_url = self.get_url(host, hash.group(1)) html = self.net.http_GET(web_url).content data = json.loads(html) if data['success'] == '1': video_file = data['data']['video_file'] if video_file == '': raise ResolverError('File removed') video_file = video_file.rsplit('/', 1)[0] + '/' sources = list(set(data['data']['flv_files'])) sources = [(i.rsplit('.', 2)[-2] + 'p', i.split('?')[0] + '?channel=main') for i in sources] sources = sorted(sources, key=lambda x: x[0])[::-1] return video_file + helpers.pick_source(sources) raise ResolverError('File not found')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) html = self.net.http_GET(web_url, headers=self.headers).content """if '"reason":"video attribute|explicit"' in html: headers = {'Referer': web_url} headers.update(self.headers) url_back = '/embed/video/%s' % (media_id) web_url = 'http://www.dailymotion.com/family_filter?enable=false&urlback=%s' % (urllib.quote_plus(url_back)) html = self.net.http_GET(url=web_url, headers=headers).content""" if '"title":"Content rejected."' in html: raise ResolverError('This video has been removed due to a copyright claim.') match = re.search('var\s+config\s*=\s*(.*?}});', html) if not match: raise ResolverError('Unable to locate config') try: js_data = json.loads(match.group(1)) except: js_data = {} sources = [] streams = js_data.get('metadata', {}).get('qualities', {}) for quality, links in streams.iteritems(): for link in links: if quality.isdigit() and link.get('type', '').startswith('application'): sources.append((quality, link['url'])) sources.sort(key=lambda x: self.__key(x), reverse=True) source=helpers.pick_source(sources) vid_url = self.net.http_GET(source, headers=self.headers).content vid_url = re.search('(http.+?m3u8)', vid_url) if vid_url: return vid_url.group(1) raise ResolverError('File not found')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) html = self.net.http_GET(web_url).content if '"reason":"video attribute|explicit"' in html: headers = {'User-Agent': common.FF_USER_AGENT, 'Referer': web_url} url_back = '/embed/video/%s' % media_id web_url = 'http://www.dailymotion.com/family_filter?enable=false&urlback=%s' % urllib.quote_plus(url_back) html = self.net.http_GET(url=web_url, headers=headers).content html = html.replace('\\', '') livesource = re.findall('"auto"\s*:\s*.+?"url"\s*:\s*"(.+?)"', html) sources = re.findall('"(\d+)"\s*:.+?"url"\s*:\s*"([^"]+)', html) if not sources and not livesource: raise ResolverError('File not found') if livesource and not sources: return self.net.http_HEAD(livesource[0]).get_url() sources = sorted(sources, key=lambda x: x[0])[::-1] source = helpers.pick_source(sources) if not '.m3u8' in source: raise ResolverError('File not found') vUrl = self.net.http_GET(source).content vUrl = re.search('(http.+?m3u8)', vUrl) if vUrl: return vUrl.group(1) raise ResolverError('File not found')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) response, video_urls = self._parse_google(web_url) if video_urls: video = helpers.pick_source(video_urls, self.get_setting('auto_pick') == 'true') else: video = None headers = {'User-Agent': common.FF_USER_AGENT} if response is not None: res_headers = response.get_headers(as_dict=True) if 'Set-Cookie' in res_headers: headers['Cookie'] = res_headers['Set-Cookie'] if not video: if ('redirector.' in web_url) or ('googleusercontent' in web_url): video = urllib2.urlopen(web_url).geturl() elif 'googlevideo.' in web_url: video = web_url + helpers.append_headers(headers) else: if ('redirector.' in video) or ('googleusercontent' in video): video = urllib2.urlopen(video).geturl() if video: if 'plugin://' in video: # google plus embedded videos may result in this return video else: return video + helpers.append_headers(headers) raise ResolverError('File not found')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) html = self.net.http_GET(web_url).content html = html.replace('\\', '') livesource = re.findall('"auto"\s*:\s*.+?"url"\s*:\s*"(.+?)"', html) sources = re.findall('"(\d+)"\s*:.+?"url"\s*:\s*"([^"]+)', html) if not sources and not livesource: raise ResolverError('File not found') if livesource and not sources: return self.net.http_HEAD(livesource[0]).get_url() sources = sorted(sources, key=lambda x: x[0])[::-1] source = helpers.pick_source(sources, self.get_setting('auto_pick') == 'true') if not '.m3u8' in source: raise ResolverError('File not found') vUrl = self.net.http_GET(source).content vUrl = re.search('(http.+?m3u8)', vUrl) if vUrl: return vUrl.group(1) raise ResolverError('File not found')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) response = self.net.http_GET(web_url) html = response.content if html: try: if 'config.playwire.com' in host: response = json.loads(html)['content']['media']['f4m'] elif 'v2' not in host: response = re.findall(r'<src>(.+?)</src>', html)[0] else: response = json.loads(html)['src'] return response response = self.net.http_GET(response).content baseURL = re.findall(r'<baseURL>\s*(.+)\s*</baseURL>', response)[0] media = re.findall(r'<media url="(\S+)".+?height="(\d+)".*?/>', response) media.sort(key=lambda x: x[1], reverse=True) sources = [('%s' % self.__replaceQuality(i[1], i[1]), '%s/%s' % (baseURL, i[0])) for i in media] source = helpers.pick_source(sources) source = source.encode('utf-8') return source except: raise ResolverError('Unable to resolve url.') raise ResolverError('No playable video found.')
def get_media_url(self, host, media_id): result = self.__auth_ip(media_id) if 'vt' in result: vt = result['vt'] del result['vt'] return helpers.pick_source(result.items()) + '?' + urllib.urlencode({'vt': vt}) + helpers.append_headers(self.headers) else: raise ResolverError('Video Token Missing')
def get_media_url(self, host, media_id): if youtube_resolver is None: return 'plugin://plugin.video.youtube/play/?video_id=' + media_id else: streams = youtube_resolver.resolve(media_id) streams_no_dash = [item for item in streams if item['container'] != 'mpd'] stream_tuples = [(item['title'], item['url']) for item in streams_no_dash] return helpers.pick_source(stream_tuples)
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'Referer': 'https://vimeo.com/', 'Origin': 'https://vimeo.com'} data = self.net.http_GET(web_url, headers).content data = json.loads(data) sources = [(vid['height'], vid['url']) for vid in data.get('request', {}).get('files', {}).get('progressive', {})] try: sources.sort(key=lambda x: x[0], reverse=True) except: pass return helpers.pick_source(sources)
def get_media_url(self, host, media_id): try: web_url = self.get_url(host, media_id) self.headers['Referer'] = web_url html = self.net.http_GET(web_url, headers=self.headers).content if isinstance(html, unicode): html = html.encode('utf-8', 'ignore') if 'Uptobox.com is not available in your country' in html: raise ResolverError('Unavailable in your country') r = re.search('(You have to wait (?:[0-9]+ minute[s]*, )*[0-9]+ second[s]*)', html) if r: raise ResolverError('Cooldown in effect') data = helpers.get_hidden(html) for _ in range(0, 3): try: html = self.net.http_POST(web_url, data, headers=self.headers).content if isinstance(html, unicode): html = html.encode('utf-8', 'ignore') stream_url = re.search('<a\shref\s*=[\'"](.+?)[\'"]\s*>\s*<span\sclass\s*=\s*[\'"]button_upload green[\'"]\s*>', html).group(1) return stream_url except: xbmc.sleep(1000) except: pass try: web_url = self.get_stream_url(host, media_id) self.headers['Referer'] = web_url html = self.net.http_GET(web_url, headers=self.headers).content if isinstance(html, unicode): html = html.encode('utf-8', 'ignore') if 'Uptobox.com is not available in your country' in html: raise ResolverError('Unavailable in your country') ''' r = re.search('(You have reached the limit of *[0-9]+ minute[s]*)', html) if r: raise Exception() ''' sources = helpers.parse_html5_source_list(html) try: sources.sort(key=lambda x: x[0], reverse=True) except: pass source = helpers.pick_source(sources) if source.startswith('//'): source = 'http:' + source return source except: pass raise ResolverError('File not found')
def get_media_url(self, host, media_id): result = self.__check_auth(media_id) if not result: result = self.__auth_ip(media_id) if result: return helpers.pick_source(result.items()) + helpers.append_headers(self.headers) raise ResolverError(i18n('no_ip_authorization'))
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} response = self.net.http_GET(web_url, headers=headers) html = response.content data = helpers.get_hidden(html) headers['Cookie'] = response.get_headers(as_dict=True).get('Set-Cookie', '') html = self.net.http_POST(response.get_url(), headers=headers, form_data=data).content sources = helpers.scrape_sources(html) return helpers.pick_source(sources) + helpers.append_headers(headers)
def get_media_url(self, host, media_id): url = self.get_url(host, media_id) net = common.Net() headers = {'User-Agent': common.RAND_UA} response = net.http_GET(url, headers=headers) response_headers = response.get_headers(as_dict=True) headers.update({'Referer': url}) cookie = response_headers.get('Set-Cookie', None) if cookie: headers.update({'Cookie': cookie}) html = response.content source_list = helpers.scrape_sources(html, generic_patterns=True) if source_list and len(source_list[0]) > 1: source_list[0][::-1] source = helpers.pick_source(source_list) return source + helpers.append_headers(headers)
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} response = self.net.http_GET(web_url, headers=headers) html = response.content if 'Not Found' in html: raise ResolverError('File Removed') headers['Referer'] = web_url cust_hdrs = json.loads(re.findall("headers':\s*([^\n]+),", html)[0]) headers.update(cust_hdrs) web_url = re.findall("requestURL = '(.*?)'", html)[0] response = self.net.http_GET(web_url, headers=headers) jdata = json.loads(response.content) vids = jdata.get('data', {}).get('details', {}).get('player', {}).get('sources', []) sources = [(vid['label'], vid['file']) for vid in vids] return helpers.pick_source(sources) + helpers.append_headers(headers)
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.RAND_UA} html = self.net.http_GET(web_url, headers=headers).content data = helpers.get_hidden(html) common.kodi.sleep(5000) headers.update({'Referer': web_url}) html = self.net.http_POST(web_url, headers=headers, form_data=data).content if html: packed = helpers.get_packed_data(html) sources = helpers.scrape_sources( packed, patterns=['''file:\s*["'](?P<url>(?!rtmp://)[^"']+)''']) data = re.findall("""_[^=]+=\[([^\]]+)\];""", html, re.DOTALL) if sources and data: data = data[2].replace('\\x', '').split(",") data = [ x.replace('"', '').replace(' ', '').decode("hex") for x in data ] key = "".join(data[7:9]) if key.startswith("embed"): key = key[6:] + key[:6] i = 0 headers.update({'Referer': web_url}) for source in sources: try: src = urlparse.urlparse(source[1]) l = list(src) b = l[2].split("/")[1:] b[0] = self.decrypt(b[0], key) l[2] = "/".join(b) sources[i] = (source[0], urlparse.urlunparse(l)) i += 1 except: i += 1 return helpers.pick_source(sources) + helpers.append_headers( headers) raise ResolverError('File not found')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) html = self.net.http_GET(web_url).content sources = [] for packed in re.finditer('(eval\(function.*?)</script>', html, re.DOTALL): packed_data = jsunpack.unpack(packed.group(1)) sources += self.__parse_sources_list(packed_data) source = helpers.pick_source(sources, self.get_setting('auto_pick') == 'true') headers = { 'User-Agent': common.FF_USER_AGENT, 'Referer': web_url, 'Cookie': self.__get_cookies(html) } return source + helpers.append_headers(headers) raise ResolverError('No playable video found.')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.RAND_UA} html = self.net.http_GET(web_url, headers=headers).content data = helpers.get_hidden(html) headers.update({'Referer': web_url}) html = self.net.http_POST(web_url, headers=headers, form_data=data).content if html: sources = helpers.scrape_sources( html, patterns=['''file:["'](?P<url>[^"']+)'''], result_blacklist=['dl', '.smil']) return helpers.pick_source(sources) + helpers.append_headers( headers) raise ResolverError('File not found')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) js_result = json.loads( self.net.http_GET(web_url, headers=self.headers).content) if js_result.get('error'): raise ResolverError(js_result.get('error').get('title')) quals = js_result.get('qualities') if quals: mbtext = self.net.http_GET(quals.get('auto')[0].get('url'), headers=self.headers).content sources = re.findall( 'NAME="(?P<label>[^"]+)",PROGRESSIVE-URI="(?P<url>[^#]+)', mbtext) return helpers.pick_source( helpers.sort_sources_list(sources)) + helpers.append_headers( self.headers) raise ResolverError('No playable video found.')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'Referer': web_url} headers.update(self.headers) html = self.net.http_GET(web_url, headers=headers).content sources = helpers.scrape_sources( html, patterns=["""file:\s*["'](?P<url>[^"']+)"""]) if sources: auth = self.__check_auth(media_id) if not auth: auth = self.__auth_ip(media_id) if auth: return helpers.pick_source(sources) + helpers.append_headers( headers) else: raise ResolverError(i18n('no_ip_authorization')) else: raise ResolverError('Unable to locate links')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.RAND_UA} html = self.net.http_GET(web_url, headers=headers).content if html: player_id = re.search('''SvplayerID\|([a-z0-9]+)''', html, re.I) if player_id: player_url = 'https://unitplay.net//CallPlayer' data = {'id': player_id.group(1)} headers.update({'Referer': web_url}) _html = self.net.http_POST(player_url, data, headers=headers).content if _html: _html = _html.decode("hex") sources = helpers.scrape_sources(_html) if sources: return helpers.pick_source(sources) + helpers.append_headers(headers) raise ResolverError("Unable to locate video")
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT, 'Referer': web_url} html = self.net.http_GET(web_url, headers=headers).content data = helpers.get_hidden(html) data['imhuman'] = 'Proceed to this video' common.kodi.sleep(5000) cookies = self.__get_cookies(html, web_url) headers.update({ 'Cookie': "; ".join("=".join((str(k), str(v))) for k, v in cookies.items()) }) html = self.net.http_POST(web_url, data, headers=headers).content sources = self.__parse_sources_list(html) source = helpers.pick_source(sources, self.get_setting('auto_pick') == 'true') return source + helpers.append_headers(headers)
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT, 'Referer': web_url} html = self.net.http_GET(web_url, headers=headers).content html += helpers.get_packed_data(html) match = re.search('playlist\s*:\s*"([^"]+)', html) if match: xml = self.net.http_GET(match.group(1), headers=headers).content count = 1 sources = [] streams = set() for match in re.finditer('''file="([^'"]*mp4)''', xml): stream_url = match.group(1) if stream_url not in streams: sources.append(('Source %s' % (count), stream_url)) streams.add(stream_url) count += 1 return helpers.pick_source(sources) + helpers.append_headers(headers)
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) response = self.net.http_GET(web_url) html = response.content if html: try: js_data = json.loads(html) sources = [(video['key'], video['url']) for video in js_data['videos']] sources = sources[::-1] source = helpers.pick_source(sources) source = source.encode('utf-8') return source + helpers.append_headers({'Cookie': response.get_headers(as_dict=True).get('Set-Cookie', '')}) except: raise ResolverError('No playable video found.') else: raise ResolverError('No playable video found.')
def get_media_url(self, host, media_id, retry=False): try: url = 'https://api.real-debrid.com/rest/1.0/unrestrict/link' headers = self.headers headers['Authorization'] = 'Bearer %s' % ( self.get_setting('token')) data = {'link': media_id} result = self.net.http_POST(url, form_data=data, headers=headers).content except urllib2.HTTPError as e: if not retry and e.code == 401: if self.get_setting('refresh'): self.refresh_token() return self.get_media_url(host, media_id, retry=True) else: self.reset_authorization() raise ResolverError( 'Real Debrid Auth Failed & No Refresh Token') else: try: js_result = json.loads(e.read()) if 'error' in js_result: msg = js_result['error'] else: msg = 'Unknown Error (1)' except: msg = 'Unknown Error (2)' raise ResolverError('Real Debrid Error: %s (%s)' % (msg, e.code)) except Exception as e: raise ResolverError( 'Unexpected Exception during RD Unrestrict: %s' % (e)) else: js_result = json.loads(result) links = [] link = self.__get_link(js_result) if link is not None: links.append(link) if 'alternative' in js_result: for alt in js_result['alternative']: link = self.__get_link(alt) if link is not None: links.append(link) return helpers.pick_source(links)
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.RAND_UA} html = self.net.http_GET(web_url, headers=headers).content if html: quals = re.findall("""href=["'].+?id=["'](\d{3,4})p""", html) source = re.search("""mp4\d+\s*=\s*["']([^"']+)""", html) if source: headers.update({'Referer': web_url}) if len(quals) > 1: sources = [(qual, re.sub('-\d{3,4}\.', '-%s.' % qual, source.group(1))) for qual in quals] try: sources.sort(key=lambda x: int(re.sub("\D", "", x[0])), reverse=True) except: common.logger.log_debug('Scrape sources sort failed |int(re.sub("\D", "", x[0])|') return helpers.pick_source(sources) + helpers.append_headers(headers) else: return source.group(1) + helpers.append_headers(headers) raise ResolverError('Unable to locate video')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} html = self.net.http_GET(web_url, headers=headers).content data = json.loads(html) if data['success'] == '0': html = self.net.http_GET('http://indavideo.hu/video/%s' % media_id).content hash = re.search('emb_hash.+?value\s*=\s*"([^"]+)', html) if not hash: raise ResolverError('File not found') web_url = self.get_url(host, hash.group(1)) html = self.net.http_GET(web_url).content data = json.loads(html) if data['success'] == '1': video_files = data['data']['video_files'] if not video_files: raise ResolverError('File removed') tokens = data['data']['filesh'] sources = [] if isinstance(video_files, dict): video_files = video_files.values() for i in video_files: match = re.search('\.(\d+)\.mp4', i) if match: sources.append((match.group(1), i)) sources = [(i[0], i[1] + '&token=%s' % tokens[i[0]]) for i in sources] try: sources = list(set(sources)) except: pass sources = sorted(sources, key=lambda x: x[0])[::-1] return helpers.pick_source(sources) raise ResolverError('File not found')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} html = self.net.http_GET(web_url, headers=headers).content sources = [] match = re.search('sources\s*:\s*\[(.*?)\]', html, re.DOTALL) if match: for match in re.finditer( '''['"]?file['"]?\s*:\s*['"]([^'"]+)['"][^}]*['"]?label['"]?\s*:\s*['"]([^'"]*)''', match.group(1), re.DOTALL): stream_url, label = match.groups() sources.append((label, stream_url)) try: sources.sort(key=lambda x: int(x[0][:-1]), reverse=True) except: pass source = helpers.pick_source(sources, self.get_setting('auto_pick') == 'true') return source + '|User-Agent=%s' % (common.FF_USER_AGENT)
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) html = self.net.http_GET(web_url, headers=self.headers).content default_url = self.__get_def_source(html) if default_url: qualities = self.__get_qualities(html) def_quality = self.__get_default(html) sources = [] for quality in qualities: if quality == def_quality: sources.append((quality, default_url)) else: stream_url = default_url.replace('.mp4?', '-%s.mp4?' % (quality)) sources.append((quality, stream_url)) try: sources.sort(key=lambda x: int(x[0][:-1]), reverse=True) except: pass return helpers.pick_source(sources)
def get_media_url(self, host, media_id): self.desktopHeaders['Referer'] = self.get_url(host, media_id) r = self.net.http_POST( url = 'https://' + host + '/api/source/' + media_id, form_data = {'r': '', 'd': 'xstreamcdn.com'}, headers = self.desktopHeaders ) self.desktopHeaders['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' self.desktopHeaders['Cookie'] = '; '.join(cookie.name+'='+cookie.value for cookie in self.net._cj) del self.desktopHeaders['X-Requested-With'] del self.desktopHeaders['Referer'] jsonData = json.loads(r.content) if jsonData: source = helpers.pick_source( [(source.get('label', 'mp4'), source['file']) for source in jsonData['data']] ) return source + helpers.append_headers(self.desktopHeaders) raise ResolverError('Unable to locate video')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} response = self.net.http_GET(web_url, headers=headers) html = response.content if re.search('>(File Not Found)<', html): raise ResolverError('File Not Found or removed') cnt = 10 match = re.search('count\s*=\s*(\d+);', html) if match: cnt = int(match.group(1)) cnt += 1 data = helpers.get_hidden(html) headers.update({'Referer': web_url}) common.kodi.sleep(cnt * 1000) html = self.net.http_POST(response.get_url(), form_data=data, headers=headers).content sources = helpers.scrape_sources(html, patterns=['''file\s*:\s*["'](?P<url>[^"']+)''']) return helpers.pick_source(sources) + helpers.append_headers(headers)
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'Referer': web_url, 'User-Agent': common.RAND_UA} api_url = 'https://www.{0}/api/source/{1}'.format(host, media_id) js_result = self.net.http_POST(api_url, form_data={'r': ''}, headers=headers).content if js_result: try: js_data = json.loads(js_result) if js_data.get('success'): sources = [(i.get('label'), i.get('file')) for i in js_data.get('data') if i.get('type') == 'mp4'] common.logger.log(sources) sources = helpers.sort_sources_list(sources) return helpers.pick_source(sources) + helpers.append_headers(headers) else: raise Exception(js_data.get('data')) except Exception as e: raise ResolverError('Error getting video: %s' % e) raise ResolverError('Video not found')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.RAND_UA} html = self.net.http_GET(web_url, headers=headers).content if html: quals = re.findall("""<a.+?id=["'](\d+)p""", html) source = re.search("""mp4\d?\s*=\s*["']([^"']+)""", html) if source: source = source.group(1) headers.update({'Referer': web_url}) if len(quals) > 1: sources = [('%sp' % i, re.sub('-\d+\.mp4', '-%s.mp4' % i, source)) for i in quals] try: sources.sort(key=lambda x: int(re.sub("\D", "", x[0])), reverse=True) except: common.logger.log_debug('Scrape sources sort failed |int(re.sub("\D", "", x[0])|') source = helpers.pick_source(sources) return source + helpers.append_headers(headers) raise ResolverError("No video found")
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} response = self.net.http_GET(web_url, headers=headers) html = response.content data = helpers.get_hidden(html) headers['Cookie'] = response.get_headers(as_dict=True).get('Set-Cookie', '') sleep_time = 10 # in seconds wait_ms = sleep_time * 1000 common.kodi.notify(header=None, msg='XvidStage requires %s second wait' % sleep_time, duration=wait_ms) common.kodi.sleep(wait_ms) html = self.net.http_POST(web_url, headers=headers, form_data=data).content if html: packed = helpers.get_packed_data(html) sources = helpers.scrape_sources(packed, result_blacklist=['tmp']) if sources: return helpers.pick_source(sources) + helpers.append_headers(headers) raise ResolverError('Unable to locate video')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = { 'User-Agent': common.CHROME_USER_AGENT, 'Referer': 'https://vidcloud.co/embed/%s' % media_id } html = self.net.http_GET(web_url, headers=headers).content if html: sources = helpers.scrape_sources( html.replace("\\n", "").replace("\\", ""), patterns=[ '''src":\s*"(?P<url>[^"]+)(?:[^}>\]]+)label":\s*"(?P<label>[^"]+)''' ], generic_patterns=False) if sources: return helpers.pick_source(sources) + helpers.append_headers( headers) raise ResolverError("Unable to locate video")
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} web_url = self.net.http_HEAD(web_url, headers=headers).get_url() headers['Referer'] = web_url tries = 0 while tries < MAX_TRIES: html = self.net.http_GET(web_url, headers=headers).content html = html.replace('\n', '') r = re.search('<iframe\s+src\s*=\s*"([^"]+)', html) if r: web_url = r.group(1) else: break tries += 1 html = self.net.http_GET(web_url, headers=headers).content sources = helpers.scrape_sources(html, result_blacklist=['youwatch.']) return helpers.pick_source(sources) + helpers.append_headers(headers)
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = { 'User-Agent': common.RAND_UA, 'Referer': 'https://flixtor.to/watch/%s' % media_id } html = self.net.http_GET(web_url, headers=headers).content if html: try: html = base64.b64decode(html.encode("rot13")) except Exception as e: raise ResolverError(e) sources = helpers.scrape_sources(html) if sources: return helpers.pick_source(sources) + helpers.append_headers( headers) raise ResolverError("Unable to locate video")
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} response = self.net.http_GET(web_url, headers=headers) html = response.content data = helpers.get_hidden(html) headers['Cookie'] = response.get_headers(as_dict=True).get( 'Set-Cookie', '') html = self.net.http_POST(web_url, headers=headers, form_data=data).content if html: packed = helpers.get_packed_data(html) sources = helpers.scrape_sources(packed, result_blacklist=['tmp']) if sources: return helpers.pick_source(sources) + helpers.append_headers( headers) raise ResolverError('Unable to locate video')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) html = self.net.http_GET(web_url).content if 'Not Found' in html: raise ResolverError('File Removed') if 'Video is processing' in html: raise ResolverError('File still being processed') match = re.search('sources\s*:\s*\[(.*?)\]', html, re.DOTALL) if match: sources = re.findall( '''['"]?file['"]?\s*:\s*['"]([^'"]+)['"][^{,]*(?:,['"]?label['"]?\s*:\s*['"]([^'"]*))?''', match.group(1)) sources = [(s[1], s[0]) for s in sources] return helpers.pick_source(sources, self.get_setting('auto_pick') == 'true') raise ResolverError('Unable to find youlol video')
def get_media_url(self, host, media_id): try: web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} html = self.net.http_GET(web_url, headers=headers).content html = helpers.add_packed_data(html) #print html sources = [] for match in re.finditer('file:\s*"([^"]+)"\s*,\s*label:\s*"([^"]+)', html): stream_url,label = match.groups() sources.append((label, stream_url)) print sources sources = sorted(sources, key=lambda x: x[0])[::-1] headers = {"Referer":"http://static.vidto.me/player7.9.3/jwplayer.flash.swf"} time.sleep(3) return helpers.pick_source(sources) + helpers.append_headers(headers) #return helpers.pick_source(sources) except: raise ResolverError("File Link Not Found")
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} try: html = self.net.http_GET(web_url, headers=headers).content except urllib2.HTTPError as e: if e.code == 404: raise ResolverError("Video not found") srcs = re.findall(r'href="(%s&q=[^"]+)' % web_url, html, re.I) if srcs: sources = [] for src in srcs: shtml = self.net.http_GET(src, headers=headers).content strurl = helpers.parse_html5_source_list(shtml) if strurl: sources.append(strurl[0]) if len(sources) > 1: try: sources.sort(key=lambda x: int(re.sub("\D", "", x[0])), reverse=True) except: common.logger.log_debug( 'Scrape sources sort failed |int(re.sub("\D", "", x[0])|' ) try: sources.sort( key=lambda x: re.sub("[^a-zA-Z]", "", x[0])) except: common.logger.log_debug( 'Scrape sources sort failed |re.sub("[^a-zA-Z]", "", x[0])|' ) else: sources = helpers.parse_html5_source_list(html) if len(sources) > 0: return helpers.pick_source(sources) + helpers.append_headers( headers) else: raise ResolverError("Video not found")
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} html = self.net.http_GET(web_url, headers=headers).content if html: try: data = helpers.get_hidden(html) headers.update({'Referer': web_url}) common.kodi.sleep(2000) _html = self.net.http_POST(web_url, headers=headers, form_data=data).content if _html: sources = helpers.scrape_sources(_html) if sources: if len(sources) > 1: sources = [source for source in sources if len(re.sub("\D", "", source[0])) <= 4] return helpers.pick_source(sources) + helpers.append_headers(headers) except Exception as e: raise ResolverError(e) raise ResolverError('Unable to locate video')
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) headers = {'User-Agent': common.FF_USER_AGENT} html = self.net.http_GET(web_url, headers=headers).content data = helpers.get_hidden(html) common.kodi.sleep(1000) headers.update({'Referer': web_url}) html = self.net.http_POST(web_url, headers=headers, form_data=data).content if html: packed = jsunpack.unpack(html) sources = helpers.scrape_sources( packed, patterns=["""file:\s*["'](?P<url>[^"']+)"""], result_blacklist=[".smil"]) if sources: return helpers.pick_source(sources) + helpers.append_headers( headers) raise ResolverError('Unable to locate video')