|
@ -921,39 +921,49 @@ class InfoExtractor(object): |
|
|
|
|
|
|
|
|
formats = [] |
|
|
formats = [] |
|
|
rtmp_count = 0 |
|
|
rtmp_count = 0 |
|
|
for video in smil.findall('./body/switch/video'): |
|
|
|
|
|
src = video.get('src') |
|
|
|
|
|
if not src: |
|
|
|
|
|
continue |
|
|
|
|
|
bitrate = int_or_none(video.get('system-bitrate') or video.get('systemBitrate'), 1000) |
|
|
|
|
|
width = int_or_none(video.get('width')) |
|
|
|
|
|
height = int_or_none(video.get('height')) |
|
|
|
|
|
proto = video.get('proto') |
|
|
|
|
|
if not proto: |
|
|
|
|
|
if base: |
|
|
|
|
|
if base.startswith('rtmp'): |
|
|
|
|
|
proto = 'rtmp' |
|
|
|
|
|
elif base.startswith('http'): |
|
|
|
|
|
proto = 'http' |
|
|
|
|
|
ext = video.get('ext') |
|
|
|
|
|
if proto == 'm3u8': |
|
|
|
|
|
formats.extend(self._extract_m3u8_formats(src, video_id, ext)) |
|
|
|
|
|
elif proto == 'rtmp': |
|
|
|
|
|
rtmp_count += 1 |
|
|
|
|
|
streamer = video.get('streamer') or base |
|
|
|
|
|
formats.append({ |
|
|
|
|
|
'url': streamer, |
|
|
|
|
|
'play_path': src, |
|
|
|
|
|
'ext': 'flv', |
|
|
|
|
|
'format_id': 'rtmp-%d' % (rtmp_count if bitrate is None else bitrate), |
|
|
|
|
|
'tbr': bitrate, |
|
|
|
|
|
'width': width, |
|
|
|
|
|
'height': height, |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
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'): |
|
|
|
|
|
fmts, rtmp_count = self._parse_smil_video(video, base, rtmp_count) |
|
|
|
|
|
formats.extend(fmts) |
|
|
|
|
|
|
|
|
self._sort_formats(formats) |
|
|
self._sort_formats(formats) |
|
|
|
|
|
|
|
|
return formats |
|
|
return formats |
|
|
|
|
|
|
|
|
|
|
|
def _parse_smil_video(self, video, base, rtmp_count): |
|
|
|
|
|
src = video.get('src') |
|
|
|
|
|
if not src: |
|
|
|
|
|
return ([], rtmp_count) |
|
|
|
|
|
bitrate = int_or_none(video.get('system-bitrate') or video.get('systemBitrate'), 1000) |
|
|
|
|
|
width = int_or_none(video.get('width')) |
|
|
|
|
|
height = int_or_none(video.get('height')) |
|
|
|
|
|
proto = video.get('proto') |
|
|
|
|
|
if not proto: |
|
|
|
|
|
if base: |
|
|
|
|
|
if base.startswith('rtmp'): |
|
|
|
|
|
proto = 'rtmp' |
|
|
|
|
|
elif base.startswith('http'): |
|
|
|
|
|
proto = 'http' |
|
|
|
|
|
ext = video.get('ext') |
|
|
|
|
|
if proto == 'm3u8': |
|
|
|
|
|
return (self._extract_m3u8_formats(src, video_id, ext), rtmp_count) |
|
|
|
|
|
elif proto == 'rtmp': |
|
|
|
|
|
rtmp_count += 1 |
|
|
|
|
|
streamer = video.get('streamer') or base |
|
|
|
|
|
return ([{ |
|
|
|
|
|
'url': streamer, |
|
|
|
|
|
'play_path': src, |
|
|
|
|
|
'ext': 'flv', |
|
|
|
|
|
'format_id': 'rtmp-%d' % (rtmp_count if bitrate is None else bitrate), |
|
|
|
|
|
'tbr': bitrate, |
|
|
|
|
|
'width': width, |
|
|
|
|
|
'height': height, |
|
|
|
|
|
}], rtmp_count) |
|
|
|
|
|
|
|
|
def _live_title(self, name): |
|
|
def _live_title(self, name): |
|
|
""" Generate the title for a live video """ |
|
|
""" Generate the title for a live video """ |
|
|
now = datetime.datetime.now() |
|
|
now = datetime.datetime.now() |
|
|