mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-07-18 19:28:31 +00:00
raise early on playinfo unavailable
This commit is contained in:
parent
bcdba19810
commit
d93663451d
@ -175,9 +175,14 @@ def _download_playinfo(self, bvid, cid, headers=None, query=None):
|
|||||||
else:
|
else:
|
||||||
note = f'Downloading video formats for cid {cid}'
|
note = f'Downloading video formats for cid {cid}'
|
||||||
|
|
||||||
return self._download_json(
|
playurl_raw = self._download_json(
|
||||||
'https://api.bilibili.com/x/player/wbi/playurl', bvid,
|
'https://api.bilibili.com/x/player/wbi/playurl', bvid,
|
||||||
query=self._sign_wbi(params, bvid), headers=headers, note=note)['data']
|
query=self._sign_wbi(params, bvid), headers=headers, note=note)
|
||||||
|
if playurl_raw.get('v_voucher'):
|
||||||
|
return playurl_raw['data']
|
||||||
|
else:
|
||||||
|
self.report_warning('Received a captcha from Bilibili while downloading play info')
|
||||||
|
return None
|
||||||
|
|
||||||
def json2srt(self, json_data):
|
def json2srt(self, json_data):
|
||||||
srt_data = ''
|
srt_data = ''
|
||||||
@ -724,11 +729,10 @@ def _real_extract(self, url):
|
|||||||
self._search_json(r'window\.__playinfo__\s*=', webpage, 'play info', video_id, default=None),
|
self._search_json(r'window\.__playinfo__\s*=', webpage, 'play info', video_id, default=None),
|
||||||
('data', {dict}))
|
('data', {dict}))
|
||||||
if not self.is_logged_in or not play_info:
|
if not self.is_logged_in or not play_info:
|
||||||
dl_play_info = self._download_playinfo(video_id, cid, headers=headers, query={'try_look': 1})
|
if dl_play_info := self._download_playinfo(video_id, cid, headers=headers, query={'try_look': 1}):
|
||||||
if not dl_play_info.get('v_voucher'):
|
|
||||||
play_info = dl_play_info
|
play_info = dl_play_info
|
||||||
else:
|
if not play_info:
|
||||||
self.report_warning('Failed to download play info, falling back to the playinfo embedded in the webpage.', video_id=video_id)
|
raise ExtractorError('Unable to download play info')
|
||||||
formats = self.extract_formats(play_info)
|
formats = self.extract_formats(play_info)
|
||||||
|
|
||||||
if video_data.get('is_upower_exclusive'):
|
if video_data.get('is_upower_exclusive'):
|
||||||
|
Loading…
Reference in New Issue
Block a user