feat(monitor): 粘贴视频链接换出博主主页
运营手上常常只有一条作品的分享链接,可监控任务认的是主页里的 sec_uid。 - 从整段分享文案里抠链接(链接前后都是字,按行切切不开),短链先展开, 再从中取作品 id,最后用详情接口换 author.sec_uid - 一次最多 20 条,串行 + 0.4 秒间隔;单条失败只在那一条上报错,不连累整批 - normalize_aweme 补上 creator_id:哈希拼不出主页地址,顺带让以后入库的 抖音作品也带主页链接 - 监控页左上角「视频转主页」,支持逐条复制和一键复制全部(http 下没有 navigator.clipboard,走 execCommand 兜底)
This commit is contained in:
@@ -12,7 +12,7 @@ import asyncio
|
||||
import httpx
|
||||
import pytest
|
||||
|
||||
from api.monitor import douyin_api
|
||||
from api.monitor import adapters, douyin_api
|
||||
|
||||
|
||||
class TestCookieParsing:
|
||||
@@ -105,6 +105,26 @@ class TestNormalizeAweme:
|
||||
# 指标按 store 的形态落成字符串,交给 ingest 的 parse_count 解析。
|
||||
assert record["liked_count"] == "3"
|
||||
assert record["collected_count"] == "2"
|
||||
# 这条 payload 里没有 sec_uid:主页 id 就空着,不许拿 uid 冒充。
|
||||
assert record["creator_id"] == ""
|
||||
|
||||
def test_creator_id_is_the_sec_uid_not_the_uid(self):
|
||||
"""主页链接只能由 sec_uid 拼出来 —— uid 是数字、creator_hash 是单向哈希。"""
|
||||
record = douyin_api.normalize_aweme(
|
||||
{
|
||||
"aweme_id": "1",
|
||||
"author": {
|
||||
"uid": "776719710825195",
|
||||
"sec_uid": "MS4wLjABAAAAcmv4-Oaxe7FN4bdQECz1knSBzKb50uhnykbLIArdkk7",
|
||||
"nickname": "AA建材王总",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
assert record["creator_id"] == "MS4wLjABAAAAcmv4-Oaxe7FN4bdQECz1knSBzKb50uhnykbLIArdkk7"
|
||||
assert adapters.creator_url("dy", record["creator_id"]).startswith(
|
||||
"https://www.douyin.com/user/"
|
||||
)
|
||||
|
||||
def test_hashtags_come_from_text_extra_not_the_truncated_desc(self):
|
||||
"""`desc` 会在话题列表中途被截断,后半段话题只在 `text_extra` 里。
|
||||
|
||||
Reference in New Issue
Block a user