diff options
author | Sergey M․ <dstftw@gmail.com> | 2019-12-31 23:43:43 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2019-12-31 23:43:43 +0700 |
commit | 0164cd5dacf76b0fd295e82412fda60e7c60df61 (patch) | |
tree | 3debc41e4ed1d1e9260000d1d6ffd3b5ee753a0d /youtube_dl | |
parent | f41347260c2c2cf723bc2bb8a5c11f67a22175d5 (diff) |
[pornhub] Improve locked videos detection (closes #22449, closes #22780)
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/extractor/pornhub.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/youtube_dl/extractor/pornhub.py b/youtube_dl/extractor/pornhub.py index 75ed69cde..b3251ccd9 100644 --- a/youtube_dl/extractor/pornhub.py +++ b/youtube_dl/extractor/pornhub.py @@ -17,6 +17,7 @@ from ..utils import ( determine_ext, ExtractorError, int_or_none, + NO_DEFAULT, orderedSet, remove_quotes, str_to_int, @@ -227,9 +228,9 @@ class PornHubIE(PornHubBaseIE): else: thumbnail, duration = [None] * 2 - def extract_js_vars(webpage, pattern, fatal=True): + def extract_js_vars(webpage, pattern, default=NO_DEFAULT): assignments = self._search_regex( - pattern, webpage, 'encoded url', fatal=fatal) + pattern, webpage, 'encoded url', default=default) if not assignments: return {} @@ -270,11 +271,15 @@ class PornHubIE(PornHubBaseIE): FORMAT_PREFIXES = ('media', 'quality') js_vars = extract_js_vars( webpage, r'(var\s+(?:%s)_.+)' % '|'.join(FORMAT_PREFIXES), - fatal=False) + default=None) if js_vars: for key, format_url in js_vars.items(): if any(key.startswith(p) for p in FORMAT_PREFIXES): add_video_url(format_url) + if not video_urls and re.search( + r'<[^>]+\bid=["\']lockedPlayer', webpage): + raise ExtractorError( + 'Video %s is locked' % video_id, expected=True) if not video_urls: js_vars = extract_js_vars( |