def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) logger.log_debug('HugeFiles: get_link: %s' % (web_url)) html = self.net.http_GET(web_url).content r = re.findall('File Not Found', html) if r: raise ResolverError('File Not Found or removed') # Grab data values data = helpers.get_hidden(html) data.update(captcha_lib.do_captcha(html)) logger.log_debug('HugeFiles - Requesting POST URL: %s with data: %s' % (web_url, data)) html = self.net.http_POST(web_url, data).content # Re-grab data values data = helpers.get_hidden(html) data['referer'] = web_url headers = {'User-Agent': common.EDGE_USER_AGENT} logger.log_debug('HugeFiles - Requesting POST URL: %s with data: %s' % (web_url, data)) request = urllib_request.Request(web_url, data=urllib_parse.urlencode(data), headers=headers) try: stream_url = urllib_request.urlopen(request).geturl() except: return logger.log_debug('Hugefiles stream Found: %s' % stream_url) return stream_url
def __get_html_and_headers(url, headers=None): if headers is None: headers = get_default_headers(url) try: net = common.Net() cookie_jar_result = net.set_cookies(COOKIE_FILE) response = net.http_GET(url, headers=headers) cookie_jar_result = net.save_cookies(COOKIE_FILE) contents = response.content redirect = response.get_url() if ('reddit' in redirect) and ('over18' in redirect): post_headers = {} post_headers.update({ 'User-Agent': common.FF_USER_AGENT, 'Content-Type': 'application/x-www-form-urlencoded' }) data = get_hidden(contents) data.update({'over18': 'yes'}) cookie_jar_result = net.set_cookies(COOKIE_FILE) response = net.http_POST(response.get_url(), form_data=data, headers=post_headers) cookie_jar_result = net.save_cookies(COOKIE_FILE) contents = response.content log_utils.log('GET request updated headers: |{0!s}|'.format(headers), log_utils.LOGDEBUG) return {'contents': contents, 'headers': headers} except: return {'contents': '', 'headers': headers}
def get_media_url(self, host, media_id): #print web_url 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) data['confirm.y'] = random.randint(0, 120) data['confirm.x'] = random.randint(0, 120) headers['Referer'] = web_url post_url = web_url + '#' html = self.net.http_POST(post_url, form_data=data, headers=headers).content.encode('utf-8') ## sources = helpers.parse_sources_list(html) ## try: sources.sort(key=lambda x: x[0], reverse=True) ## except: pass ## return helpers.pick_source(sources) sourc = [] legenda = [] try: le = re.compile('"file":"([^"]+)","label":".+?","kind":"captions"').findall(html) for l in le: legenda.append(l.replace('\/', '/')) except: pass match = re.search('''['"]?sources['"]?\s*:\s*\[(.*?)\]''', html, re.DOTALL) if match: sourc = [(match[1], match[0].replace('\/', '/')) for match in re.findall('''['"]?file['"]?\s*:\s*['"]([^'"]+)['"][^}]*['"]?label['"]?\s*:\s*['"]([^'"]*)''', match.group(1), re.DOTALL)] return sourc,legenda
def do_solvemedia_captcha(captcha_url): common.logger.log_debug('SolveMedia Captcha: %s' % captcha_url) if captcha_url.startswith('//'): captcha_url = 'http:' + captcha_url html = net.http_GET(captcha_url).content data = { 'adcopy_challenge': '' # set to blank just in case not found; avoids exception on return } data.update(helpers.get_hidden(html), include_submit=False) captcha_img = os.path.join(common.profile_path, IMG_FILE) try: os.remove(captcha_img) except: pass # Check for alternate puzzle type - stored in a div alt_frame = re.search('<div><iframe src="(/papi/media[^"]+)', html) if alt_frame: html = net.http_GET("http://api.solvemedia.com%s" % alt_frame.group(1)).content alt_puzzle = re.search(r'<div\s+id="typein">\s*<img\s+src="data:image/png;base64,([^"]+)', html, re.DOTALL) if alt_puzzle: open(captcha_img, 'wb').write(alt_puzzle.group(1).decode('base64')) else: open(captcha_img, 'wb').write(net.http_GET("http://api.solvemedia.com%s" % re.search('<img src="(/papi/media[^"]+)"', html).group(1)).content) solution = get_response(captcha_img) data['adcopy_response'] = solution html = net.http_POST('http://api.solvemedia.com/papi/verify.noscript', data) return {'adcopy_challenge': data['adcopy_challenge'], 'adcopy_response': 'manual_challenge'}
def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) rurl = 'https://{0}/'.format(host) headers = {'User-Agent': common.FF_USER_AGENT, 'Referer': rurl} html = self.net.http_GET(web_url, headers=headers).content r = re.search("href='([^']+).+?GET LINK", html) if r: g = self.net.http_GET(r.group(1), headers=headers) html = g.content gp = urllib_parse.urlparse(g.get_url()) data = helpers.get_hidden(html) headers.update({ 'Origin': '{0}://{1}'.format(gp.scheme, gp.netloc), 'Referer': g.get_url(), 'X-Requested-With': 'XMLHttpRequest' }) purl = re.findall('<form.+?action="([^"]+)', html)[0] if purl.startswith('/'): purl = '{0}://{1}{2}'.format(gp.scheme, gp.netloc, purl) common.kodi.sleep(5000) html = self.net.http_POST(purl, form_data=data, headers=headers).content jd = json.loads(html) if jd.get('status') == "success": headers.pop('X-Requested-With') return jd.get('url') + helpers.append_headers(headers) 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, 'Origin': 'https://www.{0}'.format(host), 'Referer': web_url} html = self.net.http_GET(web_url, headers=headers).content data = helpers.get_hidden(html) data.update({"method_free": "Download Gratuito >>"}) html = self.net.http_POST(web_url, form_data=data, headers=headers).content tries = 0 while tries < MAX_TRIES: data = helpers.get_hidden(html) data.update({"method_free": "Download Gratuito >>"}) data.update(captcha_lib.do_captcha(html)) common.kodi.sleep(15000) html = self.net.http_POST(web_url, form_data=data, headers=headers).content r = re.search(r'''id="direct_link".+?href="([^"]+)''', html, re.DOTALL) if r: # headers.update({'verifypeer': 'false'}) return r.group(1).replace(' ', '%20') + helpers.append_headers(headers) tries += 1 raise ResolverError('Unable to locate link')
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 tries = 0 while tries < MAX_TRIES: data = helpers.get_hidden(html) data.update(captcha_lib.do_captcha(html)) html = self.net.http_POST(web_url, data, headers=headers).content r = re.search(r'''class="downloadbtn"[^>]+onClick\s*=\s*\"window\.open\('([^']+)''', html) if r: return r.group(1) + helpers.append_headers(headers) common.kodi.sleep(1000) tries = tries + 1 raise ResolverError('Unable to locate link')