From af6eeb067e9952cbb25f7ccb614752af57066c8b Mon Sep 17 00:00:00 2001 From: dirkf Date: Fri, 6 Nov 2026 01:53:42 +0000 Subject: [PATCH] Final tweaks Co-authored-by: dirkf --- youtube_dl/extractor/extractors.py | 2 +- youtube_dl/extractor/infomaniak.py | 46 ++++++++++++++---------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 95d35e8c7..8334a43da 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -526,8 +526,8 @@ from .imgur import ( ) from .ina import InaIE from .inc import IncIE -from .infomaniak import InfomaniakVod2IE from .indavideo import IndavideoEmbedIE +from .infomaniak import InfomaniakVod2IE from .infoq import InfoQIE from .instagram import ( InstagramIE, diff --git a/youtube_dl/extractor/infomaniak.py b/youtube_dl/extractor/infomaniak.py index 331416332..504d2639c 100644 --- a/youtube_dl/extractor/infomaniak.py +++ b/youtube_dl/extractor/infomaniak.py @@ -32,7 +32,7 @@ class InfomaniakVod2IE(InfoExtractor): def _real_extract(self, url): share_id = self._match_id(url) share = self._download_json( - 'https://api.infomaniak.com/2/vod/res/shares/%s.json' % share_id, + 'https://api.infomaniak.com/2/vod/res/shares/%s.json' % (share_id,), share_id) entries = [] for media in traverse_obj(share, ( @@ -41,24 +41,21 @@ class InfomaniakVod2IE(InfoExtractor): source = media['source'] formats = [] - hls_url = source.get('hls') - if hls_url: - formats.extend(self._extract_m3u8_formats( - hls_url, media_id, 'mp4', entry_protocol='m3u8_native', - m3u8_id='hls', fatal=False)) - - mpd_url = source.get('dash') - if mpd_url: - formats.extend(self._extract_mpd_formats( - mpd_url, media_id, mpd_id='dash', fatal=False)) - - best_url = source.get('best') - if best_url: - formats.append({ - 'url': best_url, - 'format_id': 'http', - 'preference': 10, - }) + for src, src_url in traverse_obj(('hls', 'dash', 'best'), ( + lambda _, v: source.get(v), T(lambda x: (x, source[x])))): + if src == 'hls': + formats.extend(self._extract_m3u8_formats( + src_url, media_id, 'mp4', entry_protocol='m3u8_native', + m3u8_id=src, fatal=False)) + elif src == 'dash': + formats.extend(self._extract_mpd_formats( + src_url, media_id, mpd_id=src, fatal=False)) + elif src == 'best': + formats.append({ + 'url': src_url, + 'format_id': 'http', + 'preference': 10, + }) self._sort_formats(formats) @@ -72,20 +69,21 @@ class InfomaniakVod2IE(InfoExtractor): 'formats': formats, })) - if len(entries) == 1: + n_entries = len(entries) + if n_entries == 1: return merge_dicts({ 'id': share_id, 'display_id': share_id, }, entries[0], rev=True) - missing_id = sum(1 for e in entries if not e.get('id')) entries = [e for e in entries if e.get('id')] - if missing_id: + n_entries -= len(entries) + if n_entries > 0: self.report_warning( 'Share contains multiple media entries, but %d item(s) are missing an id and will be skipped. ' - 'If this looks incorrect, please report the URL.' % missing_id, + 'If this looks incorrect, please report the URL.' % n_entries, share_id, only_once=True) - if not entries: + elif not entries: # Keep the error message actionable for site support requests raise ExtractorError('Unable to find any media in share JSON', expected=True)