fix: 修复抖音筛选发布时间和排序失效问题

This commit is contained in:
xueyueben 2024-06-13 11:46:25 +08:00
parent 2e367a0414
commit 576c8e8d9f
2 changed files with 12 additions and 6 deletions

View File

@ -2,6 +2,7 @@ import asyncio
import copy import copy
import urllib.parse import urllib.parse
from typing import Any, Callable, Dict, List, Optional from typing import Any, Callable, Dict, List, Optional
import json
import execjs import execjs
import httpx import httpx
@ -119,14 +120,19 @@ class DOUYINClient(AbstractApiClient):
params = { params = {
"keyword": urllib.parse.quote(keyword), "keyword": urllib.parse.quote(keyword),
"search_channel": search_channel.value, "search_channel": search_channel.value,
"sort_type": sort_type.value,
"publish_time": publish_time.value,
"search_source": "normal_search", "search_source": "normal_search",
"query_correct_type": "1", "query_correct_type": 1,
"is_filter_search": "0", "is_filter_search": 0,
"offset": offset, "offset": offset,
"count": 10 # must be set to 10 "count": 10 # must be set to 10
} }
if sort_type != SearchSortType.GENERAL or publish_time != PublishTimeType.UNLIMITED:
params["filter_selected"] = urllib.parse.quote(json.dumps({
"sort_type": str(sort_type.value),
"publish_time": str(publish_time.value)
}))
params["is_filter_search"] = 1
params["search_source"] = "tab_search"
referer_url = "https://www.douyin.com/search/" + keyword referer_url = "https://www.douyin.com/search/" + keyword
referer_url += f"?publish_time={publish_time.value}&sort_type={sort_type.value}&type=general" referer_url += f"?publish_time={publish_time.value}&sort_type={sort_type.value}&type=general"
headers = copy.copy(self.headers) headers = copy.copy(self.headers)

View File

@ -20,5 +20,5 @@ class PublishTimeType(Enum):
"""publish time type""" """publish time type"""
UNLIMITED = 0 # 不限 UNLIMITED = 0 # 不限
ONE_DAY = 1 # 一天内 ONE_DAY = 1 # 一天内
ONE_WEEK = 2 # 一周内 ONE_WEEK = 7 # 一周内
SIX_MONTH = 3 # 半年内 SIX_MONTH = 180 # 半年内