1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-26 18:34:32 +01:00

[kika] Cleanup

Closes #6957.
This commit is contained in:
Jaime Marquínez Ferrándiz 2015-10-31 16:32:35 +01:00
parent 8c1aa28c27
commit c3040bd00a

View File

@ -16,8 +16,8 @@ class KikaIE(InfoExtractor):
'id': '19636', 'id': '19636',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Baumhaus vom 30. Oktober 2015', 'title': 'Baumhaus vom 30. Oktober 2015',
'description': None 'description': None,
} },
}, },
{ {
'url': 'http://www.kika.de/sendungen/einzelsendungen/weihnachtsprogramm/videos/video8182.html', 'url': 'http://www.kika.de/sendungen/einzelsendungen/weihnachtsprogramm/videos/video8182.html',
@ -26,8 +26,8 @@ class KikaIE(InfoExtractor):
'id': '8182', 'id': '8182',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Beutolomäus und der geheime Weihnachtswunsch', 'title': 'Beutolomäus und der geheime Weihnachtswunsch',
'description': 'md5:b69d32d7b2c55cbe86945ab309d39bbd' 'description': 'md5:b69d32d7b2c55cbe86945ab309d39bbd',
} },
}, },
{ {
'url': 'http://www.kika.de/baumhaus/sendungen/video19636_zc-fea7f8a0_zs-4bf89c60.html', 'url': 'http://www.kika.de/baumhaus/sendungen/video19636_zc-fea7f8a0_zs-4bf89c60.html',
@ -36,8 +36,8 @@ class KikaIE(InfoExtractor):
'id': '19636', 'id': '19636',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Baumhaus vom 30. Oktober 2015', 'title': 'Baumhaus vom 30. Oktober 2015',
'description': None 'description': None,
} },
}, },
{ {
'url': 'http://www.kika.de/sendungen/einzelsendungen/weihnachtsprogramm/einzelsendung2534.html', 'url': 'http://www.kika.de/sendungen/einzelsendungen/weihnachtsprogramm/einzelsendung2534.html',
@ -46,9 +46,9 @@ class KikaIE(InfoExtractor):
'id': '8182', 'id': '8182',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Beutolomäus und der geheime Weihnachtswunsch', 'title': 'Beutolomäus und der geheime Weihnachtswunsch',
'description': 'md5:b69d32d7b2c55cbe86945ab309d39bbd' 'description': 'md5:b69d32d7b2c55cbe86945ab309d39bbd',
} },
} },
] ]
def _real_extract(self, url): def _real_extract(self, url):
@ -59,7 +59,6 @@ class KikaIE(InfoExtractor):
xml_re = r'sectionArticle[ "](?:(?!sectionA[ "])(?:.|\n))*?dataURL:\'(?:/[a-z-]+?)*?/video(\d+)-avCustom\.xml' xml_re = r'sectionArticle[ "](?:(?!sectionA[ "])(?:.|\n))*?dataURL:\'(?:/[a-z-]+?)*?/video(\d+)-avCustom\.xml'
video_id = self._search_regex(xml_re, webpage, "xml_url", default=None) video_id = self._search_regex(xml_re, webpage, "xml_url", default=None)
if not video_id: if not video_id:
# Video is not available online
err_msg = 'Video %s is not available online' % broadcast_id err_msg = 'Video %s is not available online' % broadcast_id
raise ExtractorError(err_msg, expected=True) raise ExtractorError(err_msg, expected=True)
@ -74,38 +73,29 @@ class KikaIE(InfoExtractor):
broadcast_elem = xml_tree.find('broadcast') broadcast_elem = xml_tree.find('broadcast')
description = broadcast_elem.find('broadcastDescription').text description = broadcast_elem.find('broadcastDescription').text
except AttributeError: except AttributeError:
# No description available
description = None description = None
# duration string format is mm:ss (even if it is >= 1 hour, e.g. 78:42) # duration string format is mm:ss (even if it is >= 1 hour, e.g. 78:42)
tmp = xml_tree.find('duration').text.split(':') tmp = xml_tree.find('duration').text.split(':')
duration = int(tmp[0]) * 60 + int(tmp[1]) duration = int(tmp[0]) * 60 + int(tmp[1])
formats_list = [] formats = [{
for elem in xml_tree.find('assets'): 'url': elem.find('progressiveDownloadUrl').text,
format_dict = {} 'ext': elem.find('mediaType').text.lower(),
format_dict['url'] = elem.find('progressiveDownloadUrl').text 'format': elem.find('profileName').text,
format_dict['ext'] = elem.find('mediaType').text.lower() 'width': int(elem.find('frameWidth').text),
format_dict['format'] = elem.find('profileName').text 'height': int(elem.find('frameHeight').text),
format_dict['width'] = int(elem.find('frameWidth').text) 'abr': int(elem.find('bitrateAudio').text),
format_dict['height'] = int(elem.find('frameHeight').text) 'vbr': int(elem.find('bitrateVideo').text),
format_dict['resolution'] = '%dx%d' % (format_dict['width'], 'filesize': int(elem.find('fileSize').text),
format_dict['height']) } for elem in xml_tree.find('assets')]
format_dict['abr'] = int(elem.find('bitrateAudio').text) self._sort_formats(formats)
format_dict['vbr'] = int(elem.find('bitrateVideo').text)
format_dict['tbr'] = format_dict['abr'] + format_dict['vbr']
format_dict['filesize'] = int(elem.find('fileSize').text)
formats_list.append(format_dict)
# Sort by resolution (=quality)
formats_list.sort(key=lambda x: x['width'] * x['height'])
return { return {
'id': video_id, 'id': video_id,
'title': title, 'title': title,
'description': description, 'description': description,
'formats': formats_list, 'formats': formats,
'duration': duration, 'duration': duration,
'webpage_url': webpage_url 'webpage_url': webpage_url,
} }