aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorJChris246 <chris.401@live.com>2020-12-12 10:17:59 -0400
committerSergey M․ <dstftw@gmail.com>2020-12-26 21:17:11 +0700
commitb57b27ff8f442c134dd7e6245c4bfea829d770af (patch)
treeb6f92264bc6bba9b7d9e7dbd4d0bbf18e359d855 /youtube_dl
parentbbe8cc6662ce870b2efee5d2a3fceab39e1a3c2c (diff)
[pornhub] Fix lq formats extraction (closes #27386)
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/extractor/pornhub.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/youtube_dl/extractor/pornhub.py b/youtube_dl/extractor/pornhub.py
index 9ad92a8ec..3b6498964 100644
--- a/youtube_dl/extractor/pornhub.py
+++ b/youtube_dl/extractor/pornhub.py
@@ -288,15 +288,25 @@ class PornHubIE(PornHubBaseIE):
video_urls.append((v_url, None))
video_urls_set.add(v_url)
+ def parse_quality_items(js_str):
+ if (url_or_none(js_str)):
+ return js_str
+ media_definitions = self._parse_json(js_str, video_id, fatal=False)
+ if isinstance(media_definitions, list):
+ for definition in media_definitions:
+ if not isinstance(definition, dict):
+ continue
+ add_video_url(definition.get('url'))
+
if not video_urls:
- FORMAT_PREFIXES = ('media', 'quality')
+ FORMAT_PREFIXES = ('media', 'quality', 'qualityItems')
js_vars = extract_js_vars(
webpage, r'(var\s+(?:%s)_.+)' % '|'.join(FORMAT_PREFIXES),
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)
+ add_video_url(parse_quality_items(format_url))
if not video_urls and re.search(
r'<[^>]+\bid=["\']lockedPlayer', webpage):
raise ExtractorError(