feat(monitor): 组头上加一个跳到博主主页的按钮
Deploy VitePress site to Pages / build (push) Canceled after 0s
Deploy VitePress site to Pages / Deploy (push) Canceled after 0s

`creator_hash` 是单向的,拼不出主页地址 —— 所以这个 id 必须在采集时单独存下来。
抖音的资料接口本来就返回 sec_uid,只是之前没落库。

* `monitor_creator_stat` 加 `creator_id` 列(老数据默认空,下一次采集补上);
* 链接在 `adapters.creator_url()` 里拼,**空串是有意义的返回值**:平台不认识、
  或者没拿到 id,就返回空,界面据此不画按钮 —— 画一个点开 404 的按钮比不画糟;
* 没有作品的博主照样有链接:他恰恰是你想点进去看的那个人。

已知缺口:小红书那条路(爬虫子进程)根本不落创作者资料,所以那边没有链接。
This commit is contained in:
2026-10-11 08:52:51 +08:00
parent 65fc16ddc9
commit 44277600e4
10 changed files with 172 additions and 0 deletions
+27
View File
@@ -389,3 +389,30 @@ class TestLegacyKeyMigration:
assert "xhs_cookie" not in rows
await monitor_db.dispose_engine()
class TestCreatorUrl:
"""博主主页链接。
注意它要的是**平台上的主页 id**(抖音是 sec_uid),不是 ``creator_hash`` —— 哈希是
单向的,拼不出地址。所以这条链路上少任何一环(采集没存 id、平台上没有这个博主、
平台不认识)都必须返回空串,让界面干脆不画按钮,而不是给一个点开 404 的链接。
"""
def test_douyin(self):
assert (
adapters.creator_url("dy", "MS4wLjABAAAAabc-123")
== "https://www.douyin.com/user/MS4wLjABAAAAabc-123"
)
def test_xiaohongshu(self):
assert (
adapters.creator_url("xhs", "5f8a1b2c3d4e5f6a7b8c9d0e")
== "https://www.xiaohongshu.com/user/profile/5f8a1b2c3d4e5f6a7b8c9d0e"
)
def test_no_id_is_empty_not_a_broken_link(self):
assert adapters.creator_url("dy", "") == ""
def test_an_unknown_platform_is_empty_not_a_crash(self):
assert adapters.creator_url("nope", "abc") == ""