fix(dy): 补上 ArgusSecurityPlugin 要求的 x-tt-argus 请求头

抖音在边缘网关新挂了 ArgusSecurityPlugin,对 aweme/detail、aweme/post 这批接口做
业务前置校验:缺少 x-tt-argus 时直接 403,响应体为
"Blocked by ArgusSecurityPlugin Uifid Not Found";只补 uifid 参数但仍没有这个头
则是 "... Signature Not Found"——后者很容易被误判成 a_bogus / verifyFp 的问题。
网关当前不校验该头取值,传固定字符串即可(实测 "1" 就够)。
参考 https://github.com/Johnserf-Seed/f2/issues/443

注意这是权宜之计:网关哪天升级到真校验该值,会重新出现 Signature Not Found,
届时需要改为页面内注入 JS 让抖音自带 SDK 补齐 Argus 头。

验证:真实 cookie 下 get_video_by_id 恢复可用。

- client.py: 默认请求头补 x-tt-argus,cookie 有 UIFID 时带 uifid 头
  (两种都没有则不发,避免被当成「有但为空」)
- 新增 tests/test_douyin_argus_header.py(不发网络请求)
This commit is contained in:
程序员阿江(Relakkes)
2026-09-19 13:25:59 +08:00
parent 8ecfa31de2
commit 380b426000
2 changed files with 97 additions and 0 deletions
+13
View File
@@ -39,6 +39,10 @@ from .exception import *
from .field import *
from .help import *
# 抖音边缘网关 ArgusSecurityPlugin 要求的请求头。网关目前不校验取值,
# 传固定字符串即可;将来若开始真校验,会重新出现 "Signature Not Found"。
DOUYIN_ARGUS_HEADER_VALUE = "1"
class DouYinClient(AbstractApiClient, ProxyRefreshMixin):
@@ -55,6 +59,15 @@ class DouYinClient(AbstractApiClient, ProxyRefreshMixin):
self.proxy = proxy
self.timeout = timeout
self.headers = headers
# 抖音边缘网关的 ArgusSecurityPlugin 会对这批接口做业务前置校验,缺少
# x-tt-argus 头时直接 403,响应体为
# "Blocked by ArgusSecurityPlugin Uifid Not Found"(补了 uifid 但没这个头则是
# "... Signature Not Found")。当前网关尚未校验该头的值,可传任意字符串;
# 一旦升级到真校验,需要改为 WebView 内注入 JS 让页面自带 SDK 补齐。
self.headers.setdefault("x-tt-argus", DOUYIN_ARGUS_HEADER_VALUE)
uifid = cookie_dict.get("UIFID") or cookie_dict.get("UIFID_TEMP", "")
if uifid:
self.headers.setdefault("uifid", uifid)
self._host = "https://www.douyin.com"
self.cookie_urls = [
"https://douyin.com",