Merge pull request #299 from 522109452/fix_dy_filter

fix: 修复抖音筛选发布时间和排序失效问题
This commit is contained in:
程序员阿江-Relakkes 2024-06-13 21:11:19 +08:00 committed by GitHub
commit a84e96d473
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 6 deletions

View File

@ -2,6 +2,7 @@ import asyncio
import copy
import urllib.parse
from typing import Any, Callable, Dict, List, Optional
import json
import execjs
import httpx
@ -119,14 +120,19 @@ class DOUYINClient(AbstractApiClient):
params = {
"keyword": urllib.parse.quote(keyword),
"search_channel": search_channel.value,
"sort_type": sort_type.value,
"publish_time": publish_time.value,
"search_source": "normal_search",
"query_correct_type": "1",
"is_filter_search": "0",
"query_correct_type": 1,
"is_filter_search": 0,
"offset": offset,
"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 += f"?publish_time={publish_time.value}&sort_type={sort_type.value}&type=general"
headers = copy.copy(self.headers)

View File

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