[ie/loom] Fix m3u8 formats extraction (#10760)

Closes #10737
Authored by: kclauhk
This commit is contained in:
kclauhk 2024-09-28 06:28:22 +08:00 committed by GitHub
parent 63da31b3b2
commit 7509d692b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -92,9 +92,9 @@ class LoomIE(InfoExtractor):
}, },
'params': {'videopassword': 'seniorinfants2'}, 'params': {'videopassword': 'seniorinfants2'},
}, { }, {
# embed, transcoded-url endpoint sends empty JSON response # embed, transcoded-url endpoint sends empty JSON response, split video and audio HLS formats
'url': 'https://www.loom.com/embed/ddcf1c1ad21f451ea7468b1e33917e4e', 'url': 'https://www.loom.com/embed/ddcf1c1ad21f451ea7468b1e33917e4e',
'md5': '8488817242a0db1cb2ad0ea522553cf6', 'md5': 'b321d261656848c184a94e3b93eae28d',
'info_dict': { 'info_dict': {
'id': 'ddcf1c1ad21f451ea7468b1e33917e4e', 'id': 'ddcf1c1ad21f451ea7468b1e33917e4e',
'ext': 'mp4', 'ext': 'mp4',
@ -104,6 +104,7 @@ class LoomIE(InfoExtractor):
'timestamp': 1657216459, 'timestamp': 1657216459,
'duration': 181, 'duration': 181,
}, },
'params': {'format': 'bestvideo'}, # Test video-only fixup
'expected_warnings': ['Failed to parse JSON'], 'expected_warnings': ['Failed to parse JSON'],
}] }]
_WEBPAGE_TESTS = [{ _WEBPAGE_TESTS = [{
@ -293,7 +294,11 @@ def get_formats(format_url, format_id, quality):
format_url = format_url.replace('-split.m3u8', '.m3u8') format_url = format_url.replace('-split.m3u8', '.m3u8')
m3u8_formats = self._extract_m3u8_formats( m3u8_formats = self._extract_m3u8_formats(
format_url, video_id, 'mp4', m3u8_id=f'hls-{format_id}', fatal=False, quality=quality) format_url, video_id, 'mp4', m3u8_id=f'hls-{format_id}', fatal=False, quality=quality)
# Sometimes only split video/audio formats are available, need to fixup video-only formats
is_not_premerged = 'none' in traverse_obj(m3u8_formats, (..., 'vcodec'))
for fmt in m3u8_formats: for fmt in m3u8_formats:
if is_not_premerged and fmt.get('vcodec') != 'none':
fmt['acodec'] = 'none'
yield { yield {
**fmt, **fmt,
'url': update_url(fmt['url'], query=query), 'url': update_url(fmt['url'], query=query),