From 853a9224f569931e54c9e78429c4d80b54942a21 Mon Sep 17 00:00:00 2001 From: grqx_wsl <173253225+grqx@users.noreply.github.com> Date: Fri, 19 Jul 2024 22:38:21 +1200 Subject: [PATCH] apply patch from comment https://github.com/yt-dlp/yt-dlp/pull/10317#issuecomment-2202289727 --- yt_dlp/extractor/bilibili.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/yt_dlp/extractor/bilibili.py b/yt_dlp/extractor/bilibili.py index 305f649b81..0a2d197ceb 100644 --- a/yt_dlp/extractor/bilibili.py +++ b/yt_dlp/extractor/bilibili.py @@ -1742,7 +1742,7 @@ class BiliBiliSearchAllIE(SearchInfoExtractor, BilibiliBaseIE): yield self.url_result(bili_user_prefix + str(result_data['mid'])) -class BiliBiliSearchIE(SearchInfoExtractor): +class BiliBiliSearchIE(SearchInfoExtractor, BilibiliBaseIE): IE_DESC = 'Bilibili video search' _MAX_RESULTS = 100000 _SEARCH_KEY = 'bilisearch' @@ -1777,21 +1777,16 @@ class BiliBiliSearchIE(SearchInfoExtractor): def _search_results(self, query): if not self._get_cookies('https://api.bilibili.com').get('buvid3'): self._set_cookie('.bilibili.com', 'buvid3', f'{uuid.uuid4()}infoc') + headers = self.geo_verification_headers() + headers['Referer'] = 'https://www.bilibili.com/' for page_num in itertools.count(1): videos = self._download_json( - 'https://api.bilibili.com/x/web-interface/search/type', query, - note=f'Extracting results from page {page_num}', query={ - 'Search_key': query, + 'https://api.bilibili.com/x/web-interface/wbi/search/type', query, + note=f'Extracting results from page {page_num}', query=self._sign_wbi({ 'keyword': query, 'page': page_num, - 'context': '', - 'duration': 0, - 'tids_2': '', - '__refresh__': 'true', 'search_type': 'video', - 'tids': 0, - 'highlight': 1, - })['data'].get('result') + }, query), headers=headers)['data'].get('result') if not videos: break for video in videos: