def get_video_url(page_url, premium=False, user="", password="", video_password=""): logger.info("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if 'peliculonhd' in page_url: import re patron = r'/mpegTS/([^/]+)/([^\s]+)' matches = re.compile(patron, re.DOTALL).findall(data) for _id, quota in matches: old = '/mpegTS/%s/%s' % (_id, quota) gurl = 'https://lh3.googleusercontent.com/d/%s?quotaUser=%s' new = gurl % (_id, quota) data = data.replace(old, new) data = data.replace('s://lh3.googleusercontent.com', '://localhost:8781') m3u8 = os.path.join(config.get_data_path(), "op_master.m3u8") outfile = open(m3u8, 'wb') outfile.write(data) outfile.close() page_url = m3u8 from lib import servop servop.start() video_urls = [["%s [Oprem]" % page_url[-4:], page_url]] return video_urls
def get_video_url(page_url, premium=False, user="", password="", video_password=""): logger.info("(page_url='%s')" % page_url) video_urls = list() if "const source = '" in data: url = scrapertools.find_single_match(data, "const source = '([^']+)") v_type = "hls" else: url, v_type = scrapertools.find_single_match( data, '"file": "([^"]+)",\s+"type": "([^"]+)"') headers = {"referer": page_url} if v_type == "mp4": url = httptools.downloadpage(url, headers=headers, follow_redirects=False, stream=True).headers["location"] page_url = "%s|Referer=%s&User-Agent=%s" % (url, page_url, httptools.get_user_agent()) elif v_type == "hls": hls_data = httptools.downloadpage(url, headers=headers).data base_url = scrapertools.find_single_match(hls_data, "(https?://[^/]+)") hls_data = hls_data.replace(base_url, 'http://localhost:8781') m3u8 = os.path.join(config.get_data_path(), "op_master.m3u8") outfile = open(m3u8, 'wb') outfile.write(hls_data) outfile.close() page_url = m3u8 v_type = "m3u8" servop.start(base_url) else: return video_urls video_urls = [["%s [Oprem]" % v_type, page_url]] return video_urls