mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-04-29 12:05:55 +00:00
Compare commits
7 Commits
314145548a
...
8bf65ed2d3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8bf65ed2d3 | ||
|
|
63a3011150 | ||
|
|
06a5a3768f | ||
|
|
9944c0c7aa | ||
|
|
1442658d9a | ||
|
|
76400685fd | ||
|
|
4f28e9a93b |
@ -164,18 +164,14 @@ class BilibiliBaseIE(InfoExtractor):
|
||||
params['w_rid'] = hashlib.md5(f'{query}{self._get_wbi_key(video_id)}'.encode()).hexdigest()
|
||||
return params
|
||||
|
||||
def _download_playinfo(self, bvid, cid, headers=None, fatal=True, qn=None):
|
||||
def _download_playinfo(self, bvid, cid, headers=None, qn=None):
|
||||
params = {'bvid': bvid, 'cid': cid, 'fnval': 4048}
|
||||
if qn:
|
||||
params['qn'] = qn
|
||||
play_info_obj = self._download_json(
|
||||
return self._download_json(
|
||||
'https://api.bilibili.com/x/player/wbi/playurl', bvid,
|
||||
query=self._sign_wbi(params, bvid), headers=headers, fatal=fatal,
|
||||
note=f'Downloading video formats for cid {cid} {qn or ""}')
|
||||
if fatal:
|
||||
return play_info_obj['data']
|
||||
else:
|
||||
return play_info_obj.get('data')
|
||||
query=self._sign_wbi(params, bvid), headers=headers,
|
||||
note=f'Downloading video formats for cid {cid} {qn or ""}')['data']
|
||||
|
||||
def json2srt(self, json_data):
|
||||
srt_data = ''
|
||||
@ -642,11 +638,6 @@ class BiliBiliIE(BilibiliBaseIE):
|
||||
headers['Referer'] = url
|
||||
|
||||
initial_state = self._search_json(r'window\.__INITIAL_STATE__\s*=', webpage, 'initial state', video_id)
|
||||
is_festival = 'videoData' not in initial_state
|
||||
if is_festival:
|
||||
video_data = initial_state['videoInfo']
|
||||
else:
|
||||
video_data = initial_state['videoData']
|
||||
|
||||
if traverse_obj(initial_state, ('error', 'trueCode')) == -403:
|
||||
self.raise_login_required()
|
||||
@ -655,6 +646,19 @@ class BiliBiliIE(BilibiliBaseIE):
|
||||
'This video may be deleted or geo-restricted. '
|
||||
'You might want to try a VPN or a proxy server (with --proxy)', expected=True)
|
||||
|
||||
is_festival = 'videoData' not in initial_state
|
||||
if is_festival:
|
||||
video_data = initial_state['videoInfo']
|
||||
else:
|
||||
video_data = initial_state['videoData']
|
||||
|
||||
if video_data.get('is_upower_exclusive'):
|
||||
high_level = traverse_obj(initial_state, ('elecFullInfo', 'show_info', 'high_level'))
|
||||
raise ExtractorError(
|
||||
'This is a supporter-only video: '
|
||||
f'{join_nonempty("title", "sub_title", from_dict=high_level, delim=",")}. '
|
||||
f'{self._login_hint()}', expected=True)
|
||||
|
||||
video_id, title = video_data['bvid'], video_data.get('title')
|
||||
|
||||
# Bilibili anthologies are similar to playlists but all videos share the same video ID as the anthology itself.
|
||||
@ -682,24 +686,9 @@ class BiliBiliIE(BilibiliBaseIE):
|
||||
|
||||
play_info = (
|
||||
traverse_obj(
|
||||
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}))
|
||||
or self._download_playinfo(video_id, cid, headers=headers, fatal=False))
|
||||
if not play_info:
|
||||
raise ExtractorError('Failed to extract play info')
|
||||
|
||||
if video_data.get('is_upower_exclusive'):
|
||||
# Supporter-only, also indicated by
|
||||
# `not traverse_obj(play_info, ('support_formats', ..., 'codecs'))`
|
||||
# Ref: https://github.com/ytdl-org/youtube-dl/issues/32722#issuecomment-1950045012
|
||||
high_level = traverse_obj(initial_state, ('elecFullInfo', 'show_info', 'high_level'))
|
||||
# Should we inline the title and the subtitle?
|
||||
support_title = traverse_obj(high_level, 'title', default='')
|
||||
support_subtitle = traverse_obj(high_level, 'sub_title', default='')
|
||||
raise ExtractorError(
|
||||
f'This is a supporter-only video: {support_title},{support_subtitle}. '
|
||||
f'{self._login_hint()}', expected=True)
|
||||
or self._download_playinfo(video_id, cid, headers=headers))
|
||||
|
||||
festival_info = {}
|
||||
if is_festival:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user