mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 14:45:14 +00:00 
			
		
		
		
	[extractor/bilibili] Fix for downloading wrong subtitles (#6358)
Closes #6357 Authored by: LXYan2333
This commit is contained in:
		| @@ -81,7 +81,7 @@ class BilibiliBaseIE(InfoExtractor): | |||||||
|                          f'{line["content"]}\n\n') |                          f'{line["content"]}\n\n') | ||||||
|         return srt_data |         return srt_data | ||||||
| 
 | 
 | ||||||
|     def _get_subtitles(self, video_id, initial_state, cid): |     def _get_subtitles(self, video_id, aid, cid): | ||||||
|         subtitles = { |         subtitles = { | ||||||
|             'danmaku': [{ |             'danmaku': [{ | ||||||
|                 'ext': 'xml', |                 'ext': 'xml', | ||||||
| @@ -89,7 +89,8 @@ class BilibiliBaseIE(InfoExtractor): | |||||||
|             }] |             }] | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         for s in traverse_obj(initial_state, ('videoData', 'subtitle', 'list')) or []: |         video_info_json = self._download_json(f'https://api.bilibili.com/x/player/v2?aid={aid}&cid={cid}', video_id) | ||||||
|  |         for s in traverse_obj(video_info_json, ('data', 'subtitle', 'subtitles', ...)): | ||||||
|             subtitles.setdefault(s['lan'], []).append({ |             subtitles.setdefault(s['lan'], []).append({ | ||||||
|                 'ext': 'srt', |                 'ext': 'srt', | ||||||
|                 'data': self.json2srt(self._download_json(s['subtitle_url'], video_id)) |                 'data': self.json2srt(self._download_json(s['subtitle_url'], video_id)) | ||||||
| @@ -331,7 +332,7 @@ class BiliBiliIE(BilibiliBaseIE): | |||||||
|             'timestamp': traverse_obj(initial_state, ('videoData', 'pubdate')), |             'timestamp': traverse_obj(initial_state, ('videoData', 'pubdate')), | ||||||
|             'duration': float_or_none(play_info.get('timelength'), scale=1000), |             'duration': float_or_none(play_info.get('timelength'), scale=1000), | ||||||
|             'chapters': self._get_chapters(aid, cid), |             'chapters': self._get_chapters(aid, cid), | ||||||
|             'subtitles': self.extract_subtitles(video_id, initial_state, cid), |             'subtitles': self.extract_subtitles(video_id, aid, cid), | ||||||
|             '__post_extractor': self.extract_comments(aid), |             '__post_extractor': self.extract_comments(aid), | ||||||
|             'http_headers': {'Referer': url}, |             'http_headers': {'Referer': url}, | ||||||
|         } |         } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 LXYan2333
					LXYan2333