mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-01-07 17:16:08 +00:00
[redditr] Fix review issues and extract source thumbnail (closes #27503)
This commit is contained in:
parent
d1d0612160
commit
4046ffe1e1
|
@ -8,8 +8,8 @@ from ..utils import (
|
||||||
int_or_none,
|
int_or_none,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
try_get,
|
try_get,
|
||||||
url_or_none,
|
|
||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
|
url_or_none,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,7 +57,8 @@ class RedditRIE(InfoExtractor):
|
||||||
'id': 'zv89llsvexdz',
|
'id': 'zv89llsvexdz',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'That small heart attack.',
|
'title': 'That small heart attack.',
|
||||||
'thumbnail': r're:^https?://.*\.jpg$',
|
'thumbnail': r're:^https?://.*\.(?:jpg|png)',
|
||||||
|
'thumbnails': 'count:4',
|
||||||
'timestamp': 1501941939,
|
'timestamp': 1501941939,
|
||||||
'upload_date': '20170805',
|
'upload_date': '20170805',
|
||||||
'uploader': 'Antw87',
|
'uploader': 'Antw87',
|
||||||
|
@ -120,16 +121,27 @@ class RedditRIE(InfoExtractor):
|
||||||
age_limit = None
|
age_limit = None
|
||||||
|
|
||||||
thumbnails = []
|
thumbnails = []
|
||||||
images = try_get(
|
|
||||||
data, lambda x: x['preview']['images'][0]['resolutions']) or []
|
def add_thumbnail(src):
|
||||||
for image in images:
|
if not isinstance(src, dict):
|
||||||
url = url_or_none(unescapeHTML(image['url']))
|
return
|
||||||
if url is not None:
|
thumbnail_url = url_or_none(src.get('url'))
|
||||||
thumbnails.append({
|
if not thumbnail_url:
|
||||||
'url': url,
|
return
|
||||||
'width': int_or_none(image['width']),
|
thumbnails.append({
|
||||||
'height': int_or_none(image['height']),
|
'url': unescapeHTML(thumbnail_url),
|
||||||
})
|
'width': int_or_none(src.get('width')),
|
||||||
|
'height': int_or_none(src.get('height')),
|
||||||
|
})
|
||||||
|
|
||||||
|
for image in try_get(data, lambda x: x['preview']['images']) or []:
|
||||||
|
if not isinstance(image, dict):
|
||||||
|
continue
|
||||||
|
add_thumbnail(image.get('source'))
|
||||||
|
resolutions = image.get('resolutions')
|
||||||
|
if isinstance(resolutions, list):
|
||||||
|
for resolution in resolutions:
|
||||||
|
add_thumbnail(resolution)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'_type': 'url_transparent',
|
'_type': 'url_transparent',
|
||||||
|
|
Loading…
Reference in a new issue