From dfb855b42da32807ffac243f1e763f480c4d44ba Mon Sep 17 00:00:00 2001 From: pukkandan Date: Mon, 20 Jun 2022 14:08:32 +0530 Subject: [PATCH] [extractor/BiliIntl] Fix subtitle extraction Closes #3123 Authored by: HobbyistDev --- yt_dlp/extractor/bilibili.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yt_dlp/extractor/bilibili.py b/yt_dlp/extractor/bilibili.py index 6879ca2e7c..d695d9b499 100644 --- a/yt_dlp/extractor/bilibili.py +++ b/yt_dlp/extractor/bilibili.py @@ -789,7 +789,8 @@ def _call_api(self, endpoint, *args, **kwargs): def json2srt(self, json): data = '\n\n'.join( f'{i + 1}\n{srt_subtitles_timecode(line["from"])} --> {srt_subtitles_timecode(line["to"])}\n{line["content"]}' - for i, line in enumerate(json['body']) if line.get('content')) + for i, line in enumerate(traverse_obj(json, ( + 'body', lambda _, l: l['content'] and l['from'] and l['to'])))) return data def _get_subtitles(self, *, ep_id=None, aid=None):