[BiliBiliBangumiIE] supports play_info extraction from webpage

- i.e. extracts premiums formats with logged-in cookies, haven't tested with format `12240` yet.
  * test url: https://www.bilibili.com/bangumi/play/ep829434, cookies: logged-in, non-premium
This commit is contained in:
grqx_wsl 2024-08-20 00:46:21 +12:00
parent 79bb63957d
commit 13ed574168

View file

@ -864,10 +864,16 @@ def _real_extract(self, url):
self.raise_login_required('This video is for premium members only') self.raise_login_required('This video is for premium members only')
headers['Referer'] = url headers['Referer'] = url
play_info = self._download_json(
'https://api.bilibili.com/pgc/player/web/v2/playurl', episode_id, play_info = self._search_json(
'Extracting episode', query={'fnval': 12240, 'ep_id': episode_id}, r'playurlSSRData\s*?=\s*?', webpage, 'embedded page info', episode_id,
headers=headers) end_pattern='\n', default=None)
if not play_info:
play_info = self._download_json(
'https://api.bilibili.com/pgc/player/web/v2/playurl', episode_id,
'Extracting episode', query={'fnval': 12240, 'ep_id': episode_id},
headers=headers)
premium_only = play_info.get('code') == -10403 premium_only = play_info.get('code') == -10403
play_info = traverse_obj(play_info, ('result', 'video_info', {dict})) or {} play_info = traverse_obj(play_info, ('result', 'video_info', {dict})) or {}