def __init__(self): self.net = Net() self.desktopHeaders = { 'User-Agent': RAND_UA, 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-US,en;q=0.5', 'DNT': '1' }
def __init__(self): self.net = Net() self.desktopHeaders = { 'User-Agent': RAND_UA, 'Accept': '*/*', 'Accept-Language': 'en-US,en;q=0.5', 'X-Requested-With': 'XMLHttpRequest', 'DNT': '1' }
def __init__(self): self.net = Net() self.net.set_user_agent(RAND_UA) self.desktopHeaders = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-US,en;q=0.5', 'Upgrade-Insecure-Requests': '1', 'DNT': '1' }
class VidToDoResolver(UrlResolver): name = 'Vidtodo' domains = ['vidtodoo.com', 'vidotodo.com', 'vidtodo.com', 'vidtodo.me'] pattern = '(?://|\.)((?:vidtodo[o]?|vidotodo)\.(?:com|me))/(?:embed-)?([0-9a-zA-Z]+)' def __init__(self): self.net = Net() self.userAgent = RAND_UA self.net.set_user_agent(self.userAgent) self.desktopHeaders = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-US,en;q=0.5', 'Upgrade-Insecure-Requests': '1', 'DNT': '1' } def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) r = self.net.http_GET(web_url, headers=self.desktopHeaders) if r._response.code == 200: sources = helpers.scrape_sources( r.content, generic_patterns=False, patterns= ('''sources.*?\[['"](?P<url>.*?)['"]''', '''sources.*?file:.*?['"](?P<url>.*?)['"](?:.*?label.*?['"](?P<label>.*?)['"])?''', '''updateSrc.*?src:.*?['"](?P<url>.*?)['"](?:.*?label.*?['"](?P<label>.*?)['"])?''' )) if sources: # Headers for requesting media (copied from Firefox). parsedUrl = urlparse(r.get_url()) kodiHeaders = { 'User-Agent': self.userAgent, 'Accept': 'video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5', 'Referer': '%s://%s/' % (parsedUrl.scheme, parsedUrl.netloc), 'Cookie': '; '.join(cookie.name + '=' + cookie.value for cookie in self.net._cj) } return helpers.pick_source(sources) + helpers.append_headers( kodiHeaders) raise ResolverError('Unable to locate video') def get_url(self, host, media_id): return self._default_get_url(host, media_id, template='https://{host}/{media_id}')
class FastplayResolver(UrlResolver): name = 'fastplay.sx' domains = ['fastplay.sx', 'fastplay.cc', 'fastplay.to'] pattern = '(?://|\.)(fastplay\.(?:sx|cc|to))/(?:flash-|embed-)?([0-9a-zA-Z]+)' def __init__(self): self.net = Net() self.userAgent = RAND_UA self.net.set_user_agent(self.userAgent) self.desktopHeaders = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-US,en;q=0.5', 'Upgrade-Insecure-Requests': '1', 'DNT': '1' } def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) r = self.net.http_GET(web_url, headers=self.desktopHeaders) sources = helpers.scrape_sources( r.content, generic_patterns=False, patterns=['''file:.*?['"](?P<url>.*?)['"](?:.*?label.*?['"](?P<label>.*?)['"])?'''] ) if sources: # Headers for requesting media (copied from Firefox). parsedUrl = urlparse(r.get_url()) kodiHeaders = { 'User-Agent': self.userAgent, 'Accept': 'video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5', 'Referer': '%s://%s/' % (parsedUrl.scheme, parsedUrl.netloc), 'Cookie': '; '.join(cookie.name + '=' + cookie.value for cookie in self.net._cj) } sources = helpers.sort_sources_list(sources) return helpers.pick_source(sources) + helpers.append_headers(kodiHeaders) raise ResolverError('Unable to locate video') def get_url(self, host, media_id): return self._default_get_url(host, media_id, template='http://fastplay.to/embed-{media_id}.html')
class VidToDoResolver(UrlResolver): name = 'Vidtodo' domains = ['vidotodo.com', 'vidtodo.com', 'vidtodo.me'] pattern = '(?://|\.)((?:vidtodo|vidotodo)\.(?:com|me))/(?:embed-)?([0-9a-zA-Z]+)' def __init__(self): self.net = Net() self.net.set_user_agent(RAND_UA) self.desktopHeaders = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-US,en;q=0.5', 'Upgrade-Insecure-Requests': '1', 'DNT': '1' } def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) r = self.net.http_GET(web_url, headers=self.desktopHeaders) if r._response.code == 200: sources = helpers.scrape_sources( r.content, generic_patterns=False, patterns=['''sources.*?\[['"](?P<url>.*?)['"]'''] ) if sources: # Headers for requesting media (copied from Firefox). parsedUrl = urlparse(r.get_url()) kodiHeaders = { 'User-Agent': self.net.get_user_agent(), 'Accept': 'video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5', 'Referer': '%s://%s/' % (parsedUrl.scheme, parsedUrl.netloc), 'Cookie': '; '.join( header.replace('Set-Cookie: ', '').split(';', 1)[0] for header in r.get_headers() if header.startswith('Set-Cookie') ) } return helpers.pick_source(sources) + helpers.append_headers(kodiHeaders) raise ResolverError('Unable to locate video') def get_url(self, host, media_id): return self._default_get_url(host, media_id, template='https://{host}/{media_id}')
class XStreamCDNResolver(UrlResolver): name = 'XStreamCDN' domains = ['xstreamcdn.com'] pattern = '(?://|\.)(xstreamcdn\.com)/v/(\w+)' # Host and media-id pattern. def __init__(self): self.net = Net() self.desktopHeaders = { 'User-Agent': RAND_UA, 'Accept': '*/*', 'Accept-Language': 'en-US,en;q=0.5', 'X-Requested-With': 'XMLHttpRequest', 'DNT': '1' } 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_url(self, host, media_id): return self._default_get_url(host, media_id, template='https://{host}/v/{media_id}')
class SpeedVidResolver(UrlResolver): name = "SpeedVid" domains = ['speedvid.net'] pattern = '(?://|\.)(speedvid\.net)/(?:embed-|p-)?(\w+)' def __init__(self): self.net = Net() self.desktopHeaders = { 'User-Agent': RAND_UA, 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-US,en;q=0.5', 'DNT': '1' } def get_media_url(self, host, media_id): web_url = self.get_url(host, media_id) try: r = self.net.http_GET(web_url, headers=self.desktopHeaders) content = r.content except HTTPError as e: r = HttpResponse(e) content = r.content if cfsolver.test_cloudflare( r, content): # Test if there's a Cloudflare challenge. submitURL = cfsolver.solve_cf_challenge( r, content) # Get the solution URL. if not submitURL: return None # Get redirected to the proper page. self.desktopHeaders['Referer'] = r.get_url() + '/' r = self.net.http_GET(submitURL, headers=self.desktopHeaders) content = r.content if r._response.code == 200: source = None pattern = re.compile('(eval\(function\(p,a,c,k.*?)\s*?</script>', re.DOTALL) for match in pattern.finditer(content): unpackedData = jsunpack.unpack(match.group(1)).replace( "\\\'", "'") tempURL = re.search('''(?:file|src):.*?['"](?P<url>.*?)['"]''', unpackedData, re.DOTALL).group(1) # Some of the links might be broken, so only use working ones. try: if self.net.http_HEAD( tempURL, headers=self.desktopHeaders)._response.code < 400: source = tempURL break except: pass # HTTPError caused by a broken link. if source: # Headers for requesting media (copied from Firefox). parsedUrl = urlparse(r.get_url()) kodiHeaders = { 'User-Agent': self.net.get_user_agent(), 'Accept': 'video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5', 'Referer': '%s://%s/' % (parsedUrl.scheme, parsedUrl.netloc), 'Accept-Language': 'en-US,en;q=0.5', 'Cookie': '; '.join(cookie.name + '=' + cookie.value for cookie in self.net._cj) } return source + helpers.append_headers(kodiHeaders) raise ResolverError('Unable to locate video') def get_url(self, host, media_id): return self._default_get_url(host, media_id, template='http://www.{host}/{media_id}')