Skip to content

Commit

Permalink
[extractor/biliIntl] Code refactor and add lang_key in log output (yt…
Browse files Browse the repository at this point in the history
  • Loading branch information
itachi-19 committed May 20, 2023
1 parent bcaf20c commit 75e965a
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions yt_dlp/extractor/bilibili.py
Expand Up @@ -895,22 +895,21 @@ def _get_subtitles(self, *, ep_id=None, aid=None):

for sub in sub_json.get('video_subtitle') or []:
srt_sub = sub.get('srt')
srt_sub_url = srt_sub.get('url')
if not srt_sub_url:
continue
sub_data = self._download_json(
srt_sub_url, ep_id or aid, errnote='Unable to download subtitles', fatal=False,
note='Downloading subtitles%s' % f' for {sub["lang"]}' if sub.get('lang') else '')
if not sub_data:
continue
subtitles.setdefault(sub.get('lang_key', 'en'), []).append({
'ext': 'srt',
'data': self.json2srt(sub_data)
})

ass_sub = sub.get('ass')
sub_formats = subtitles.setdefault(sub.get('lang_key', 'en'), [])

if srt_sub:
sub_data = self._download_json(
srt_sub.get('url'), ep_id or aid, errnote='Unable to download subtitles', fatal=False,
note='Downloading subtitles%s' % f' for {sub["lang"]} ({sub["lang_key"]})' if sub.get('lang') else '')
if sub_data:
sub_formats.append({
'ext': 'srt',
'data': self.json2srt(sub_data)
})

if ass_sub:
subtitles.setdefault(sub.get('lang_key', 'en'), []).append({
sub_formats.append({
'ext': 'ass',
'url': ass_sub.get('url')
})
Expand Down

0 comments on commit 75e965a

Please sign in to comment.