feat(monitor): 从超级编导按创建时间导入作品链接
Deploy VitePress site to Pages / build (push) Canceled after 0s
Deploy VitePress site to Pages / Deploy (push) Canceled after 0s

超级编导的数据中心里已经有每条分发作品的抖音链接,不用再一条条粘。按
「分发活动创建时间」选一段区间 → 预览作品/博主/播放数据 → 一键建成作品
模式的监控任务,建完默认立刻采一轮,主页信息第一轮就补全。

- 活动列表不支持日期过滤(传了也被静默忽略),只能全量拉下来本地按
  created_at 筛;边界按东八区算 —— 容器跑 UTC,按 localtime 会整体错开
  8 小时。
- data_center 必须带 video_status=-1,不带默认 0,接口返回空列表。
- share_url 是双斜杠形态,建任务时只取裸作品 id;video_link 的 id 提取
  也顺带认双斜杠了。
- 作品模式不拉创作者资料、没有账号快照,组头的主页链接一直出不来。
  作品上新增 creator_id(author.sec_uid),优先快照、再用作品兜底。
- token 存设置页(secret),不进仓库。
This commit is contained in:
2026-10-24 16:27:42 +08:00
parent 19b45908e3
commit 32cb9b1952
17 changed files with 1280 additions and 17 deletions
+27 -2
View File
@@ -33,7 +33,9 @@ async def client(tmp_path):
await monitor_db.dispose_engine()
async def _seed(platform: str = "xhs", task_name: str = "任务") -> int:
async def _seed(
platform: str = "xhs", task_name: str = "任务", creator_id: str = ""
) -> int:
"""一个任务 + 一条作品,博主固定用 CREATOR_HASH / NICKNAME。"""
async with monitor_db.get_session() as session:
task = MonitorTask(
@@ -48,7 +50,8 @@ async def _seed(platform: str = "xhs", task_name: str = "任务") -> int:
MonitorNote(
task_id=task.id, note_id=f"{platform}-n1", title="作品",
note_url="", cover="", creator_hash=CREATOR_HASH,
creator_name=NICKNAME, source_kind="", published_at=None,
creator_name=NICKNAME, creator_id=creator_id, source_kind="",
published_at=None,
first_seen_run_id=1, first_seen_at=0,
last_seen_run_id=1, last_seen_at=0,
)
@@ -358,6 +361,28 @@ class TestCreatorProfileLink:
assert (await _creators(client, "xhs"))[0]["creator_url"] == ""
@pytest.mark.asyncio
async def test_a_work_id_is_enough_without_a_snapshot(self, client):
"""作品模式 / 超级编导导入不拉创作者资料,快照一行都没有。
这种任务里主页 id 只能从作品上取 —— 作品详情里的 ``author.sec_uid`` 已经落库了。
没有这层兜底的话,整类任务里没有博主能点进主页。
"""
await _seed(platform="dy", creator_id="MS4wLjABAAAAfromwork")
creators = await _creators(client, "dy")
assert creators[0]["creator_url"].endswith("/user/MS4wLjABAAAAfromwork")
@pytest.mark.asyncio
async def test_the_snapshot_id_wins_over_the_work_id(self, client):
task_id = await _seed(platform="dy", creator_id="MS4wLjABAAAAfromwork")
await _add_stat(task_id, run_id=1, fans=1, creator_id="MS4wLjABAAAAfresh")
assert (await _creators(client, "dy"))[0]["creator_url"].endswith(
"/user/MS4wLjABAAAAfresh"
)
@pytest.mark.asyncio
async def test_a_creator_with_no_works_still_gets_the_link(self, client):
"""**没有作品的博主照样能跳过去** —— 他恰恰是你想点进去看看发的什么的那个人。"""