X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fpornhub.py;h=529f3f7119fd4e93a8c82168d910ab4fc3d1720e;hb=0c92f1e96b004fc7a04eac0759f115a535c8e03a;hp=0724efc09963d1f84fc7b24ec99d89b58e1bdfb6;hpb=6bb05b32a990b8fb961971fcb8110d292cf953e7;p=youtube-dl diff --git a/youtube_dl/extractor/pornhub.py b/youtube_dl/extractor/pornhub.py index 0724efc09..529f3f711 100644 --- a/youtube_dl/extractor/pornhub.py +++ b/youtube_dl/extractor/pornhub.py @@ -1,48 +1,73 @@ # coding: utf-8 from __future__ import unicode_literals +import functools import itertools -import os +import operator import re from .common import InfoExtractor from ..compat import ( compat_HTTPError, - compat_urllib_parse_unquote, - compat_urllib_parse_unquote_plus, - compat_urllib_parse_urlparse, + compat_str, + compat_urllib_request, ) +from .openload import PhantomJSwrapper from ..utils import ( + determine_ext, ExtractorError, int_or_none, - js_to_json, + merge_dicts, + NO_DEFAULT, orderedSet, - sanitized_Request, + remove_quotes, str_to_int, + url_or_none, ) -from ..aes import ( - aes_decrypt_text -) -class PornHubIE(InfoExtractor): +class PornHubBaseIE(InfoExtractor): + def _download_webpage_handle(self, *args, **kwargs): + def dl(*args, **kwargs): + return super(PornHubBaseIE, self)._download_webpage_handle(*args, **kwargs) + + webpage, urlh = dl(*args, **kwargs) + + if any(re.search(p, webpage) for p in ( + r'
]+\bonload=["\']go\(\)', + r'document\.cookie\s*=\s*["\']RNKEY=', + r'document\.location\.reload\(true\)')): + url_or_request = args[0] + url = (url_or_request.get_full_url() + if isinstance(url_or_request, compat_urllib_request.Request) + else url_or_request) + phantom = PhantomJSwrapper(self, required_version='2.0') + phantom.get(url, html=webpage) + webpage, urlh = dl(*args, **kwargs) + + return webpage, urlh + + +class PornHubIE(PornHubBaseIE): IE_DESC = 'PornHub and Thumbzilla' _VALID_URL = r'''(?x) https?:// (?: - (?:[a-z]+\.)?pornhub\.com/(?:view_video\.php\?viewkey=|embed/)| + (?:[^/]+\.)?(?P