Skip to content

Commit 1e9d62a

Browse files
committed
fix(api): 更新数据接口请求参数
修复 API 模式搜索接口结果为空报错的问题 Closes #560
1 parent efd02db commit 1e9d62a

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

docs/Release_Notes.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
**更新内容:**
22

3-
1. 服务器模式默认启用局域网访问
3+
1. 修复 API 模式搜索接口结果为空报错的问题
4+
2. 服务器模式默认启用局域网访问
5+
3. 更新数据接口请求参数

src/application/main_server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,8 @@ async def handle_search(self, extract):
644644
list,
645645
):
646646
return self.success_response(
647-
extract, data, None if any(data) else _("搜索结果为空!")
647+
extract,
648+
*(data, None) if any(data) else (None, _("搜索结果为空!")),
648649
)
649650
return self.failed_response(extract)
650651

src/config/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Settings:
9393
"browser_info": {
9494
"User-Agent": USERAGENT,
9595
"pc_libra_divert": "Windows",
96-
"browser_language": "zh-SG",
96+
"browser_language": "zh-CN",
9797
"browser_platform": "Win32",
9898
"browser_name": "Chrome",
9999
"browser_version": "139.0.0.0",
@@ -106,7 +106,7 @@ class Settings:
106106
"browser_info_tiktok": {
107107
"User-Agent": USERAGENT,
108108
"app_language": "zh-Hans",
109-
"browser_language": "zh-SG",
109+
"browser_language": "zh-CN",
110110
"browser_name": "Mozilla",
111111
"browser_platform": "Win32",
112112
"browser_version": "5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36",

src/interface/search.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,15 @@ def _generate_params_general(
249249
self,
250250
) -> dict:
251251
params = self.params | {
252+
"pc_search_top_1_params": '{"enable_ai_search_top_1":1}',
252253
"search_channel": self.channel.channel,
253254
"enable_history": "1",
254255
"keyword": self.keyword,
255256
"search_source": "tab_search",
256257
"query_correct_type": "1",
257258
"is_filter_search": "0",
258259
"from_group_id": "",
260+
"disable_rs": "0",
259261
"offset": self.cursor,
260262
"count": self.count,
261263
"need_filter_settings": "0",
@@ -276,13 +278,15 @@ def _generate_params_video(
276278
self,
277279
) -> dict:
278280
params = self.params | {
281+
"pc_search_top_1_params": '{"enable_ai_search_top_1":1}',
279282
"search_channel": self.channel.channel,
280283
"enable_history": "1",
281284
"keyword": self.keyword,
282285
"search_source": "tab_search",
283286
"query_correct_type": "1",
284287
"is_filter_search": "0",
285288
"from_group_id": "",
289+
"disable_rs": "0",
286290
"offset": self.cursor,
287291
"count": self.count,
288292
"need_filter_settings": "0",
@@ -329,12 +333,14 @@ def _generate_params_live(
329333
self,
330334
) -> dict:
331335
params = self.params | {
336+
"pc_search_top_1_params": '{"enable_ai_search_top_1":1}',
332337
"search_channel": self.channel.channel,
333338
"keyword": self.keyword,
334339
"search_source": "tab_search",
335340
"query_correct_type": "1",
336341
"is_filter_search": "0",
337342
"from_group_id": "",
343+
"disable_rs": "0",
338344
"offset": self.cursor,
339345
"count": self.count,
340346
"need_filter_settings": "0",

src/interface/template.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ class API:
3535
"update_version_code": "170400",
3636
"pc_client_type": "1",
3737
"pc_libra_divert": "Windows",
38+
"support_h265": "1",
39+
"support_dash": "1",
3840
"version_code": "290100",
3941
"version_name": "29.1.0",
4042
"cookie_enabled": "true",
4143
"screen_width": "1536",
4244
"screen_height": "864",
43-
"browser_language": "zh-SG",
45+
"browser_language": "zh-CN",
4446
"browser_platform": "Win32",
4547
"browser_name": "Chrome",
4648
"browser_version": "139.0.0.0",

0 commit comments

Comments
 (0)