mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-13 14:37:43 +01:00
[toggle] Improve formats extraction robustness
This commit is contained in:
parent
8f097af4ec
commit
989e9f8ead
@ -124,12 +124,15 @@ def _real_extract(self, url):
|
|||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for video_file in info.get('Files', []):
|
for video_file in info.get('Files', []):
|
||||||
ext = determine_ext(video_file['URL'])
|
video_url, vid_format = video_file.get('URL'), video_file.get('Format')
|
||||||
vid_format = video_file['Format'].replace(' ', '')
|
if not video_url or not vid_format:
|
||||||
|
continue
|
||||||
|
ext = determine_ext(video_url)
|
||||||
|
vid_format = vid_format.replace(' ', '')
|
||||||
# if geo-restricted, m3u8 is inaccessible, but mp4 is okay
|
# if geo-restricted, m3u8 is inaccessible, but mp4 is okay
|
||||||
if ext == 'm3u8':
|
if ext == 'm3u8':
|
||||||
m3u8_formats = self._extract_m3u8_formats(
|
m3u8_formats = self._extract_m3u8_formats(
|
||||||
video_file['URL'], video_id, ext='mp4', m3u8_id=vid_format,
|
video_url, video_id, ext='mp4', m3u8_id=vid_format,
|
||||||
note='Downloading %s m3u8 information' % vid_format,
|
note='Downloading %s m3u8 information' % vid_format,
|
||||||
errnote='Failed to download %s m3u8 information' % vid_format,
|
errnote='Failed to download %s m3u8 information' % vid_format,
|
||||||
fatal=False)
|
fatal=False)
|
||||||
@ -139,7 +142,7 @@ def _real_extract(self, url):
|
|||||||
# wvm are drm-protected files
|
# wvm are drm-protected files
|
||||||
formats.append({
|
formats.append({
|
||||||
'ext': ext,
|
'ext': ext,
|
||||||
'url': video_file['URL'],
|
'url': video_url,
|
||||||
'format_id': vid_format,
|
'format_id': vid_format,
|
||||||
'preference': self._FORMAT_PREFERENCES.get(ext + '-' + vid_format) or -1,
|
'preference': self._FORMAT_PREFERENCES.get(ext + '-' + vid_format) or -1,
|
||||||
'format_note': 'DRM-protected video' if ext == 'wvm' else None
|
'format_note': 'DRM-protected video' if ext == 'wvm' else None
|
||||||
|
Loading…
Reference in New Issue
Block a user