From: Christian Heller Date: Wed, 15 Oct 2025 08:43:07 +0000 (+0200) Subject: Catch "requested_format" key error in yt_dlp info dicts. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/static/%7B%7Bdb.prefix%7D%7D/do_day?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=ytplom Catch "requested_format" key error in yt_dlp info dicts. --- diff --git a/src/ytplom/misc.py b/src/ytplom/misc.py index b59ea7f..92cd728 100644 --- a/src/ytplom/misc.py +++ b/src/ytplom/misc.py @@ -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]]