home · contact · privacy
Catch "requested_format" key error in yt_dlp info dicts. master
authorChristian Heller <c.heller@plomlompom.de>
Wed, 15 Oct 2025 08:43:07 +0000 (10:43 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 15 Oct 2025 08:43:07 +0000 (10:43 +0200)
src/ytplom/misc.py

index b59ea7f34e1536b127ae885ba0e8e75cbd3921b9..92cd728c9ac2c34a01eea39cf48c9c62abefe486 100644 (file)
@@ -940,7 +940,10 @@ class DownloadsManager:
                 try:
                     info = ydl.sanitize_info(ydl.extract_info(url,
                                                               download=False))
-                    for f in info['requested_formats']:
+                    key_formats = 'requested_formats'
+                    if key_formats not in info:
+                        raise YoutubeDLError(f'no "{key_formats}" in info')
+                    for f in info[key_formats]:
                         sizes[f[TOK_FO_ID]] = [False, 1]
                         if TOK_FS_AP in f:
                             sizes[f[TOK_FO_ID]] = [True, f[TOK_FS_AP]]