1
0
Fork 0
mirror of https://gitlab.com/dstftw/youtube-dl.git synced 2020-11-16 09:42:26 +00:00

[extractor/common] Extract the first of a seq of videos in a .smil file

This commit is contained in:
Antti Ajanki 2015-02-22 10:16:51 +02:00
parent 37f885650c
commit 637570326b

View file

@ -921,10 +921,23 @@ class InfoExtractor(object):
formats = [] formats = []
rtmp_count = 0 rtmp_count = 0
if smil.findall('./body/seq/video'):
video = smil.findall('./body/seq/video')[0]
fmts, rtmp_count = self._parse_smil_video(video, base, rtmp_count)
formats.extend(fmts)
else:
for video in smil.findall('./body/switch/video'): for video in smil.findall('./body/switch/video'):
fmts, rtmp_count = self._parse_smil_video(video, base, rtmp_count)
formats.extend(fmts)
self._sort_formats(formats)
return formats
def _parse_smil_video(self, video, base, rtmp_count):
src = video.get('src') src = video.get('src')
if not src: if not src:
continue return ([], rtmp_count)
bitrate = int_or_none(video.get('system-bitrate') or video.get('systemBitrate'), 1000) bitrate = int_or_none(video.get('system-bitrate') or video.get('systemBitrate'), 1000)
width = int_or_none(video.get('width')) width = int_or_none(video.get('width'))
height = int_or_none(video.get('height')) height = int_or_none(video.get('height'))
@ -937,11 +950,11 @@ class InfoExtractor(object):
proto = 'http' proto = 'http'
ext = video.get('ext') ext = video.get('ext')
if proto == 'm3u8': if proto == 'm3u8':
formats.extend(self._extract_m3u8_formats(src, video_id, ext)) return (self._extract_m3u8_formats(src, video_id, ext), rtmp_count)
elif proto == 'rtmp': elif proto == 'rtmp':
rtmp_count += 1 rtmp_count += 1
streamer = video.get('streamer') or base streamer = video.get('streamer') or base
formats.append({ return ([{
'url': streamer, 'url': streamer,
'play_path': src, 'play_path': src,
'ext': 'flv', 'ext': 'flv',
@ -949,10 +962,7 @@ class InfoExtractor(object):
'tbr': bitrate, 'tbr': bitrate,
'width': width, 'width': width,
'height': height, 'height': height,
}) }], rtmp_count)
self._sort_formats(formats)
return formats
def _live_title(self, name): def _live_title(self, name):
""" Generate the title for a live video """ """ Generate the title for a live video """