1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-05 02:32:44 +01:00

use int_or_none, check if attrib exists, remove thumbnail

This commit is contained in:
kennell 2015-10-18 20:47:42 +02:00
parent 264b23e1a4
commit 8cc83d301d

View File

@ -73,19 +73,17 @@ def xml_to_format(fnode):
def xml_to_thumbnails(fnode):
thumbnails = list()
for node in fnode:
width_x_height = node.attrib['key']
thumbnail = {
'url': node.text,
'width': int(width_x_height.split('x')[0]),
'height': int(width_x_height.split('x')[1])
}
thumbnail = {'url': node.text}
if 'key' in node.attrib:
width_x_height = node.attrib['key']
thumbnail['width'] = int_or_none(width_x_height.split('x')[0])
thumbnail['height'] = int_or_none(width_x_height.split('x')[1])
thumbnails.append(thumbnail)
return thumbnails
thumbnail_nodes = doc.findall('.//teaserimages/teaserimage')
thumbnails = xml_to_thumbnails(thumbnail_nodes)
thumbnail = thumbnails[-1]['url']
format_nodes = doc.findall('.//formitaeten/formitaet')
formats = list(filter(
@ -98,7 +96,6 @@ def xml_to_thumbnails(fnode):
'title': title,
'description': description,
'duration': duration,
'thumbnail': thumbnail,
'thumbnails': thumbnails,
'uploader': uploader,
'uploader_id': uploader_id,