From feaefd8ec64b62b7072a7f1c3da8be873f36fcc6 Mon Sep 17 00:00:00 2001 From: Mozi <29089388+pzhlkj6612@users.noreply.github.com> Date: Tue, 20 Aug 2024 07:57:44 +0000 Subject: [PATCH] pythonic way to get the format_index --- yt_dlp/downloader/niconico.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/yt_dlp/downloader/niconico.py b/yt_dlp/downloader/niconico.py index 265f6b2e30..17a8f8f91b 100644 --- a/yt_dlp/downloader/niconico.py +++ b/yt_dlp/downloader/niconico.py @@ -181,11 +181,7 @@ def real_download(self, filename, info_dict): ie = NiconicoIE(self.ydl) video_id = info_dict['id'] - - # Get format index - for format_index, fmt in enumerate(info_dict['formats']): - if fmt['format_id'] == info_dict['format_id']: - break + format_index = next((i for i, fmt in enumerate(info_dict['formats']) if fmt['format_id'] == info_dict['format_id'])) # Get video info total_duration = 0