pythonic way to get the format_index

This commit is contained in:
Mozi 2024-08-20 07:57:44 +00:00
parent dcefdfe508
commit feaefd8ec6

View file

@ -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