1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-07-17 18:58:35 +00:00

Use traverse_obj more and set und as default if subtitle language not found

This avoids some fatal errors

Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
This commit is contained in:
flanter21 2025-07-16 16:17:16 +03:00 committed by GitHub
parent 54d9cc0047
commit e17f38f5ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -130,11 +130,10 @@ def _real_extract(self, url):
fmt['filesize'] = filesize
subtitles = {}
for current_subs in video_info.get('subtitles'):
lang_code = current_subs.get('lang')
subtitles.setdefault(lang_code, []).append({
'name': str_or_none(current_subs.get('label')),
'url': url_or_none(current_subs['url']),
for subs in traverse_obj(video_info, ('subtitles', lambda _, v: url_or_none(v['url']))):
subtitles.setdefault(subs.get('lang') or 'und', []).append({
'name': traverse_obj(subs, ('label', {str})),
'url': subs['url'],
})
for current_chat in video_info.get('chats'):