# -*- coding: utf-8 -*- # ----------------------------------------------------------- # support functions that are needed by many channels, to no repeat the same code import base64 import inspect import os import re import sys from lib.guessit import guessit PY3 = False if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int if PY3: from concurrent import futures else: from concurrent_py2 import futures try: import urllib.request as urllib import urllib.parse as urlparse from urllib.parse import urlencode except ImportError: import urllib, urlparse from urllib import urlencode from channelselector import thumb from core import httptools, scrapertools, servertools, tmdb, channeltools from core.item import Item from lib import unshortenit from platformcode import logger, config from specials import autoplay def hdpass_get_servers(item): def get_hosts(url, quality): ret = [] page = httptools.downloadpage(url, CF=False).data mir = scrapertools.find_single_match(page, patron_mir) for mir_url, srv in scrapertools.find_multiple_matches(mir, patron_option): mir_url = scrapertools.decodeHtmlentities(mir_url) log(mir_url) it = Item(channel=item.channel, action="play", fulltitle=item.fulltitle, quality=quality, show=item.show, thumbnail=item.thumbnail, contentType=item.contentType, title=srv, server=srv, url= mir_url) if not servertools.get_server_parameters(srv.lower()): # do not exists or it's empty it = hdpass_get_url(it)[0] ret.append(it) return ret # Carica la pagina itemlist = [] if 'hdpass' in item.url or 'hdplayer' in item.url: url = item.url else: data = httptools.downloadpage(item.url, CF=False).data.replace('\n', '') patron = r']+><\/iframe>' url = scrapertools.find_single_match(data, patron) url = url.replace("&download=1", "") if 'hdpass' not in url and 'hdplayer' not in url: return itemlist if not url.startswith('http'): url = 'https:' + url data = httptools.downloadpage(url, CF=False).data patron_res = '
(.*?)
(.*?)
([^<]+?)' res = scrapertools.find_single_match(data, patron_res) with futures.ThreadPoolExecutor() as executor: thL = [] for res_url, res_video in scrapertools.find_multiple_matches(res, patron_option): res_url = scrapertools.decodeHtmlentities(res_url) thL.append(executor.submit(get_hosts, res_url, res_video)) for res in futures.as_completed(thL): if res.result(): itemlist.extend(res.result()) return server(item, itemlist=itemlist) def hdpass_get_url(item): patron_media = r'