Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 7d49502

Browse files
committed
[bild] Make more robust and improve hls extraction
1 parent 03e3b4e commit 7d49502

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

youtube_dl/extractor/expotv.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,25 @@ def _real_extract(self, url):
3434
player_key = self._search_regex(
3535
r'<param name="playerKey" value="([^"]+)"', webpage, 'player key')
3636
config = self._download_json(
37-
'http://client.expotv.com/video/config/%s/%s' % (video_id, player_key),
38-
video_id,
39-
note='Downloading video configuration')
37+
'http://client.expotv.com/video/config/%s/%s' % (video_id, player_key),
38+
video_id, 'Downloading video configuration')
4039

4140
formats = []
4241
for fcfg in config['sources']:
43-
if fcfg['type'] == 'm3u8':
44-
formats.extend(self._extract_m3u8_formats(fcfg['file'], video_id))
42+
media_url = fcfg.get('file')
43+
if not media_url:
44+
continue
45+
if fcfg.get('type') == 'm3u8':
46+
formats.extend(self._extract_m3u8_formats(
47+
media_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls'))
4548
else:
4649
formats.append({
47-
'url': fcfg['file'],
50+
'url': media_url,
4851
'height': int_or_none(fcfg.get('height')),
4952
'format_id': fcfg.get('label'),
5053
'ext': self._search_regex(
51-
r'filename=.*\.([a-z0-9_A-Z]+)&', fcfg['file'],
52-
'file extension', default=None),
54+
r'filename=.*\.([a-z0-9_A-Z]+)&', media_url,
55+
'file extension', default=None) or fcfg.get('type'),
5356
})
5457
self._sort_formats(formats)
5558

0 commit comments

Comments
 (0)