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:
parent
54d9cc0047
commit
e17f38f5ac
@ -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'):
|
||||
|
Loading…
Reference in New Issue
Block a user