mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 06:35:12 +00:00 
			
		
		
		
	[ie/bilibili] Fix chapters and subtitles extraction (#11099)
Closes #11089 Authored by: bashonly
This commit is contained in:
		| @@ -46,6 +46,7 @@ from ..utils import ( | ||||
| 
 | ||||
| 
 | ||||
| class BilibiliBaseIE(InfoExtractor): | ||||
|     _HEADERS = {'Referer': 'https://www.bilibili.com/'} | ||||
|     _FORMAT_ID_RE = re.compile(r'-(\d+)\.m4s\?') | ||||
|     _WBI_KEY_CACHE_TIMEOUT = 30  # exact expire timeout is unclear, use 30s for one session | ||||
|     _wbi_key_cache = {} | ||||
| @@ -192,7 +193,7 @@ class BilibiliBaseIE(InfoExtractor): | ||||
|         video_info = self._download_json( | ||||
|             'https://api.bilibili.com/x/player/v2', video_id, | ||||
|             query={'aid': aid, 'cid': cid} if aid else {'bvid': video_id, 'cid': cid}, | ||||
|             note=f'Extracting subtitle info {cid}') | ||||
|             note=f'Extracting subtitle info {cid}', headers=self._HEADERS) | ||||
|         if traverse_obj(video_info, ('data', 'need_login_subtitle')): | ||||
|             self.report_warning( | ||||
|                 f'Subtitles are only available when logged in. {self._login_hint()}', only_once=True) | ||||
| @@ -207,7 +208,7 @@ class BilibiliBaseIE(InfoExtractor): | ||||
|     def _get_chapters(self, aid, cid): | ||||
|         chapters = aid and cid and self._download_json( | ||||
|             'https://api.bilibili.com/x/player/v2', aid, query={'aid': aid, 'cid': cid}, | ||||
|             note='Extracting chapters', fatal=False) | ||||
|             note='Extracting chapters', fatal=False, headers=self._HEADERS) | ||||
|         return traverse_obj(chapters, ('data', 'view_points', ..., { | ||||
|             'title': 'content', | ||||
|             'start_time': 'from', | ||||
| @@ -1021,8 +1022,6 @@ class BiliBiliBangumiSeasonIE(BilibiliBaseIE): | ||||
| 
 | ||||
| 
 | ||||
| class BilibiliCheeseBaseIE(BilibiliBaseIE): | ||||
|     _HEADERS = {'Referer': 'https://www.bilibili.com/'} | ||||
| 
 | ||||
|     def _extract_episode(self, season_info, ep_id): | ||||
|         episode_info = traverse_obj(season_info, ( | ||||
|             'episodes', lambda _, v: v['id'] == int(ep_id)), get_all=False) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 bashonly
					bashonly