def get_video_url(page_url, url_referer=''): logger.info("url=" + page_url) video_urls = [] data = httptools.downloadpage(page_url).data # ~ logger.debug(data) packed = scrapertools.find_multiple_matches(data, "(?s)eval(.*?)\s*</script>") for pack in packed: try: unpacked = jsunpack.unpack(pack) except: unpacked = '' # ~ logger.debug(unpacked) if 'sources:[' in unpacked: data = unpacked break # ~ logger.debug(data) bloque = scrapertools.find_single_match(data, 'sources:\s*\[(.*?)\]') matches = scrapertools.find_multiple_matches(bloque, '\{file:"([^"]+)"([^}]*)') for url, extra in matches: lbl = scrapertools.find_single_match(extra, 'label:"([^"]+)') if not lbl: lbl = url[-4:] if lbl == '.mpd': if platformtools.is_mpd_enabled(): video_urls.append([lbl, url, 0, '', True]) else: video_urls.append([lbl, url + '|Referer=https://vidia.tv/']) return video_urls
def get_video_url(page_url, url_referer=''): logger.info("url=" + page_url) video_urls = [] if 'embed-' not in page_url: page_url = page_url.replace('upstream.to/', 'upstream.to/embed-') + '.html' data = httptools.downloadpage(page_url).data # ~ logger.debug(data) if 'sources:' not in data: packed = scrapertools.find_single_match(data, "eval\((function\(p,a,c,k,e,d.*?)\)\s*</script>") if not packed: return video_urls data = jsunpack.unpack(packed) # ~ logger.debug(data) bloque = scrapertools.find_single_match(data, 'sources:\s*\[(.*?)\]') matches = scrapertools.find_multiple_matches(bloque, '\{file:"([^"]+)"([^}]*)') for url, extra in matches: lbl = scrapertools.find_single_match(extra, 'label:"([^"]+)') if not lbl: lbl = url[-4:] if lbl == '.mpd': if platformtools.is_mpd_enabled(): video_urls.append([lbl, url+'|Referer=https://upstream.to/', 0, '', True]) else: video_urls.append([lbl, url+'|Referer=https://upstream.to/']) if len(video_urls) == 0: url = scrapertools.find_single_match(bloque, '"(http.*?)"') if url and 'm3u8' in url: data = httptools.downloadpage(url, headers={'Referer': page_url}).data # ~ logger.debug(data) matches = scrapertools.find_multiple_matches(data, 'RESOLUTION=\d+x(\d+).*?(http.*?\.m3u8)') if matches: for res, url in matches: if '/iframes' in url: continue video_urls.append([res+'p', url]) elif url and 'mp4' in url: video_urls.append(['mp4', url]) return video_urls
def extract_videos(video_id): url = 'https://www.youtube.com/get_video_info?video_id=%s&eurl=https://youtube.googleapis.com/v/%s&ssl_stream=1' % ( video_id, video_id) data = httptools.downloadpage(url).data # ~ logger.debug(data) video_urls = [] params = dict(urlparse.parse_qsl(data)) # ~ logger.debug(params) if params.get('hlsvp'): video_urls.append(["LIVE .m3u8", params['hlsvp']]) return video_urls if params.get('player_response'): video_urls = extract_from_player_response(params) if len(video_urls) > 0: return video_urls if params.get('dashmpd') and platformtools.is_mpd_enabled(): if params.get('use_cipher_signature', '') != 'True': video_urls.append(['mpd HD', params['dashmpd'], 0, '', True]) youtube_page_data = httptools.downloadpage( "http://www.youtube.com/watch?v=%s" % video_id).data # ~ logger.debug(youtube_page_data) params = extract_flashvars(youtube_page_data) # ~ logger.debug(params) if params.get('player_response'): video_urls = extract_from_player_response(params, youtube_page_data) if len(video_urls) > 0: return video_urls if not params.get('url_encoded_fmt_stream_map'): params = dict(urlparse.parse_qsl(data)) # ~ logger.debug(params) if params.get('url_encoded_fmt_stream_map'): data_flashvars = params["url_encoded_fmt_stream_map"].split(",") for url_desc in data_flashvars: url_desc_map = dict(urlparse.parse_qsl(url_desc)) # ~ logger.debug(url_desc_map) if not url_desc_map.get("url") and not url_desc_map.get("stream"): continue try: lbl = label_from_itag(int(url_desc_map["itag"])) if not lbl: continue if url_desc_map.get("url"): url = urllib.unquote(url_desc_map["url"]) elif url_desc_map.get("conn") and url_desc_map.get("stream"): url = urllib.unquote(url_desc_map["conn"]) if url.rfind("/") < len(url) - 1: url += "/" url += urllib.unquote(url_desc_map["stream"]) elif url_desc_map.get( "stream") and not url_desc_map.get("conn"): url = urllib.unquote(url_desc_map["stream"]) if url_desc_map.get("sig"): url += "&signature=" + url_desc_map["sig"] elif url_desc_map.get("s"): sig = url_desc_map["s"] # ~ logger.debug(sig) if not js_signature and not js_signature_checked: obtener_js_signature(youtube_page_data) if not js_signature: continue url += "&sig=" + urllib.quote(js_signature([sig]), safe='') url = url.replace(",", "%2C") video_urls.append([lbl, url]) except: import traceback logger.info(traceback.format_exc()) video_urls.reverse() return video_urls
def play(item): logger.info() itemlist = [] post = { 'action': 'action_player_series', 'term_id': item.dterm, 'ide': item.dopt } data = httptools.downloadpage(host + 'wp-admin/admin-ajax.php', post=post, raise_weberror=False).data # ~ logger.debug(data) url = scrapertools.find_single_match(data, '<iframe[^>]* src="([^"]+)') if not url: return itemlist url = url.replace('&', '&') data = httptools.downloadpage(url, headers={ 'Referer': item.url }, raise_weberror=False).data # ~ logger.debug(data) url = scrapertools.find_single_match(data, '<iframe[^>]* src="([^"]+)') if not url: return itemlist if 'embed.cload' in url: data = httptools.downloadpage(url, headers={ 'Referer': host }, raise_weberror=False).data # ~ logger.debug(data) if '<div class="g-recaptcha"' in data or 'Solo los humanos pueden ver' in data: headers = { 'Referer': host, 'User-Agent': 'Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X)' } data = httptools.downloadpage(item.url, headers=headers, raise_weberror=False).data # ~ logger.debug(data) new_url = scrapertools.find_single_match( data, '<div id="option-players".*?src="([^"]+)"') if new_url: new_url = new_url.replace('/cinemaupload.com/', '/embed.cload.video/') data = httptools.downloadpage(new_url, raise_weberror=False).data # ~ logger.debug(data) url = scrapertools.find_single_match(data, 'file:\s*"([^"]+)') if url: if '/manifest.mpd' in url: if platformtools.is_mpd_enabled(): itemlist.append(['mpd', url, 0, '', True]) itemlist.append([ 'm3u8', url.replace('/users/', 'hls/users/', 1).replace('/manifest.mpd', '/index.m3u8') ]) else: itemlist.append(['m3u8', url]) else: if 'dailymotion' in url: url = 'https://www.dailymotion.com/' + url.split('/')[-1] servidor = servertools.get_server_from_url(url) if servidor and servidor != 'directo': url = servertools.normalize_url(servidor, url) itemlist.append(item.clone(url=url, server=servidor)) return itemlist