0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-30 03:33:02 +00:00

Merge pull request #7225 from kennell/master

[zdf] Extract thumbnails
This commit is contained in:
Sergey M. 2015-10-19 01:30:14 +06:00
commit 334b5c3b72

View file

@ -70,6 +70,22 @@ def xml_to_format(fnode):
'_available': is_available, '_available': is_available,
} }
def xml_to_thumbnails(fnode):
thumbnails = list()
for node in fnode:
thumbnail = {'url': node.text}
if 'key' in node.attrib:
m = re.match('^([0-9]+)x([0-9]+)$', node.attrib['key'])
if m:
thumbnail['width'] = int(m.group(1))
thumbnail['height'] = int(m.group(2))
thumbnails.append(thumbnail)
return thumbnails
thumbnail_nodes = doc.findall('.//teaserimages/teaserimage')
thumbnails = xml_to_thumbnails(thumbnail_nodes)
format_nodes = doc.findall('.//formitaeten/formitaet') format_nodes = doc.findall('.//formitaeten/formitaet')
formats = list(filter( formats = list(filter(
lambda f: f['_available'], lambda f: f['_available'],
@ -81,6 +97,7 @@ def xml_to_format(fnode):
'title': title, 'title': title,
'description': description, 'description': description,
'duration': duration, 'duration': duration,
'thumbnails': thumbnails,
'uploader': uploader, 'uploader': uploader,
'uploader_id': uploader_id, 'uploader_id': uploader_id,
'upload_date': upload_date, 'upload_date': upload_date,