Compare commits

..

2 Commits

Author SHA1 Message Date
bashonly
4a93df5043
Update yt_dlp/extractor/bilibili.py 2023-09-21 11:14:48 +00:00
ClosedPort22
6b76817cc6
[bilibili] update 2023-09-21 20:00:49 +09:00

View File

@ -47,25 +47,20 @@ class BilibiliBaseIE(InfoExtractor):
for r in traverse_obj(play_info, ('support_formats', lambda _, v: v['quality']))
}
audios = traverse_obj(play_info, ('dash', 'audio', ...))
audios = traverse_obj(play_info, ('dash', (None, 'dolby'), 'audio', ..., {dict}))
flac_audio = traverse_obj(play_info, ('dash', 'flac', 'audio'))
if flac_audio:
audios.append(flac_audio)
# dolby audio (if exists)
audios.extend(traverse_obj(play_info, ('dash', 'dolby', 'audio', ...)))
formats = [{
'url': traverse_obj(audio, 'baseUrl', 'base_url', 'url'),
'ext': mimetype2ext(traverse_obj(audio, 'mimeType', 'mime_type')),
'acodec': (audio.get('codecs') or '').lower() or None,
'acodec': traverse_obj(audio, ('codecs', {str.lower})),
'vcodec': 'none',
'tbr': float_or_none(audio.get('bandwidth'), scale=1000),
'filesize': int_or_none(audio.get('size')),
'format_id': str_or_none(audio.get('id')),
} for audio in audios]
# ref: https://github.com/SocialSisterYi/bilibili-API-collect/blob/92b30f354ab21b97fe52357161fd04e2ca687c97/docs/video/videostream_url.md
id_to_dr = {126: 'DV', 125: 'HDR10'}.get
formats.extend({
'url': traverse_obj(video, 'baseUrl', 'base_url', 'url'),
'ext': mimetype2ext(traverse_obj(video, 'mimeType', 'mime_type')),
@ -74,7 +69,7 @@ class BilibiliBaseIE(InfoExtractor):
'height': int_or_none(video.get('height')),
'vcodec': video.get('codecs'),
'acodec': 'none' if audios else None,
'dynamic_range': id_to_dr(video.get('id')) or 'SDR',
'dynamic_range': {126: 'DV', 125: 'HDR10'}.get(int_or_none(video.get('id'))),
'tbr': float_or_none(video.get('bandwidth'), scale=1000),
'filesize': int_or_none(video.get('size')),
'quality': int_or_none(video.get('id')),