]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/pornhub.py
[extractors] Use new framework for existing embeds (#4307)
[yt-dlp.git] / yt_dlp / extractor / pornhub.py
index 023b5f3b9701738e7790cf681c242056ed67cf63..6afaf5e6e7f5fd3c451f9b4549caf243629c2cb8 100644 (file)
@@ -3,29 +3,26 @@
 import math
 import operator
 import re
+import urllib.request
 
 from .common import InfoExtractor
-from ..compat import (
-    compat_HTTPError,
-    compat_str,
-    compat_urllib_request,
-)
 from .openload import PhantomJSwrapper
+from ..compat import compat_HTTPError, compat_str
 from ..utils import (
+    NO_DEFAULT,
+    ExtractorError,
     clean_html,
     determine_ext,
-    ExtractorError,
     format_field,
     int_or_none,
     merge_dicts,
-    NO_DEFAULT,
     orderedSet,
     remove_quotes,
     remove_start,
     str_to_int,
     update_url_query,
-    urlencode_postdata,
     url_or_none,
+    urlencode_postdata,
 )
 
 
@@ -50,7 +47,7 @@ def dl(*args, **kwargs):
                 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)
+                   if isinstance(url_or_request, urllib.request.Request)
                    else url_or_request)
             phantom = PhantomJSwrapper(self, required_version='2.0')
             phantom.get(url, html=webpage)
@@ -131,6 +128,7 @@ class PornHubIE(PornHubBaseIE):
                         )
                         (?P<id>[\da-z]+)
                     ''' % PornHubBaseIE._PORNHUB_HOST_RE
+    _EMBED_REGEX = [r'<iframe[^>]+?src=["\'](?P<url>(?:https?:)?//(?:www\.)?pornhub(?:premium)?\.(?:com|net|org)/embed/[\da-z]+)']
     _TESTS = [{
         'url': 'http://www.pornhub.com/view_video.php?viewkey=648719015',
         'md5': 'a6391306d050e4547f62b3f485dd9ba9',
@@ -260,12 +258,6 @@ class PornHubIE(PornHubBaseIE):
         'only_matching': True,
     }]
 
-    @staticmethod
-    def _extract_urls(webpage):
-        return re.findall(
-            r'<iframe[^>]+?src=["\'](?P<url>(?:https?:)?//(?:www\.)?pornhub(?:premium)?\.(?:com|net|org)/embed/[\da-z]+)',
-            webpage)
-
     def _extract_count(self, pattern, webpage, name):
         return str_to_int(self._search_regex(pattern, webpage, '%s count' % name, default=None))