- re.sub(r'm3u8|hlsvod|hls|f4m', 'mp4', secure_m3u8),
- video_id, 'Downloading mp4 JSON')
- mp4_url_basename = url_basename(mp4_url)
- for m3u8_format in m3u8_formats:
- mobj = re.search('/([^/]+)/index\.m3u8', m3u8_format['url'])
- if mobj:
- http_format = m3u8_format.copy()
- http_format.update({
- 'url': mp4_url.replace(mp4_url_basename, mobj.group(1)),
- 'format_id': m3u8_format['format_id'].replace('hls', 'http'),
- 'protocol': 'http',
- })
- formats.append(http_format)
+ re.sub(r'm3u8|hlsvod|hls|f4m', 'mp4s', secure_m3u8),
+ video_id, 'Downloading mp4 JSON', fatal=False)
+ if mp4_data:
+ for format_id, format_url in mp4_data.get('data', {}).items():
+ if not isinstance(format_url, compat_str):
+ continue
+ height = int_or_none(format_id)
+ if height is not None and m3u8_formats_dict.get(height):
+ f = m3u8_formats_dict[height].copy()
+ f.update({
+ 'format_id': f['format_id'].replace('hls', 'http'),
+ 'protocol': 'http',
+ })
+ else:
+ f = {
+ 'format_id': 'http-%s' % format_id,
+ 'height': int_or_none(format_id),
+ }
+ f['url'] = format_url
+ formats.append(f)