mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-07-28 05:35:43 +00:00
[ie/BiliBiliBangumi] Fix extractor (#13800)
Closes #13795 Authored by: bashonly
This commit is contained in:
parent
d3edc5d52a
commit
b15aa8d772
@ -907,13 +907,26 @@ class BiliBiliBangumiIE(BilibiliBaseIE):
|
|||||||
'Extracting episode', query={'fnval': 12240, 'ep_id': episode_id},
|
'Extracting episode', query={'fnval': 12240, 'ep_id': episode_id},
|
||||||
headers=headers))
|
headers=headers))
|
||||||
|
|
||||||
geo_blocked = traverse_obj(play_info, (
|
# play_info can be structured in at least three different ways, e.g.:
|
||||||
('result', ('raw', 'data')), 'plugins',
|
# 1.) play_info['result']['video_info'] and play_info['code']
|
||||||
lambda _, v: v['name'] == 'AreaLimitPanel',
|
# 2.) play_info['raw']['data']['video_info'] and play_info['code']
|
||||||
'config', 'is_block', {bool}, any))
|
# 3.) play_info['data']['result']['video_info'] and play_info['data']['code']
|
||||||
premium_only = play_info.get('code') == -10403
|
# So we need to transform any of the above into a common structure
|
||||||
|
status_code = play_info.get('code')
|
||||||
|
if 'raw' in play_info:
|
||||||
|
play_info = play_info['raw']
|
||||||
|
if 'data' in play_info:
|
||||||
|
play_info = play_info['data']
|
||||||
|
if status_code is None:
|
||||||
|
status_code = play_info.get('code')
|
||||||
|
if 'result' in play_info:
|
||||||
|
play_info = play_info['result']
|
||||||
|
|
||||||
video_info = traverse_obj(play_info, (('result', ('raw', 'data')), 'video_info', {dict}, any)) or {}
|
geo_blocked = traverse_obj(play_info, (
|
||||||
|
'plugins', lambda _, v: v['name'] == 'AreaLimitPanel', 'config', 'is_block', {bool}, any))
|
||||||
|
premium_only = status_code == -10403
|
||||||
|
|
||||||
|
video_info = traverse_obj(play_info, ('video_info', {dict})) or {}
|
||||||
formats = self.extract_formats(video_info)
|
formats = self.extract_formats(video_info)
|
||||||
|
|
||||||
if not formats:
|
if not formats:
|
||||||
@ -923,8 +936,8 @@ class BiliBiliBangumiIE(BilibiliBaseIE):
|
|||||||
self.raise_login_required('This video is for premium members only')
|
self.raise_login_required('This video is for premium members only')
|
||||||
|
|
||||||
if traverse_obj(play_info, ((
|
if traverse_obj(play_info, ((
|
||||||
('result', 'play_check', 'play_detail'), # 'PLAY_PREVIEW' vs 'PLAY_WHOLE'
|
('play_check', 'play_detail'), # 'PLAY_PREVIEW' vs 'PLAY_WHOLE' vs 'PLAY_NONE'
|
||||||
(('result', ('raw', 'data')), 'play_video_type'), # 'preview' vs 'whole' vs 'none'
|
'play_video_type', # 'preview' vs 'whole' vs 'none'
|
||||||
), any, {lambda x: x in ('PLAY_PREVIEW', 'preview')})):
|
), any, {lambda x: x in ('PLAY_PREVIEW', 'preview')})):
|
||||||
self.report_warning(
|
self.report_warning(
|
||||||
'Only preview format is available, '
|
'Only preview format is available, '
|
||||||
|
Loading…
x
Reference in New Issue
Block a user