feat(monitor): 作品模式也采博主粉丝数,从作品详情的 author 里拿
超级编导导入的是作品模式任务,从不问 user/profile,所以这些任务里每个博主 的粉丝数都是空的 —— 而运营要看的就是「这批号多大」。(之前只补了主页链接。) 详情返回的 author 里现成有 follower_count / total_favorited / following_count,白拿的,不需要多发请求。aweme_count 实测是 null,作品数 留 None —— 为一个数字给每个博主多打一次资料接口不划算。 字段缺失时留 None 而不是 0:「粉丝 0」和「没采到」不是一回事。author 是 精简版(字段全缺)时不写快照行,免得界面上出现「有采集时间、没有数字」。
This commit is contained in:
@@ -126,6 +126,38 @@ class TestNormalizeAweme:
|
||||
"https://www.douyin.com/user/"
|
||||
)
|
||||
|
||||
def test_the_authors_account_stats_ride_along(self):
|
||||
"""作品详情里的 author 带着粉丝数 —— 作品模式靠它填博主的账号指标。"""
|
||||
record = douyin_api.normalize_aweme(
|
||||
{
|
||||
"aweme_id": "1",
|
||||
"author": {
|
||||
"uid": "776719710825195",
|
||||
"follower_count": 1444,
|
||||
"total_favorited": 9751,
|
||||
# 实测详情里 aweme_count 是 null
|
||||
"aweme_count": None,
|
||||
"following_count": 0,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
assert record["creator_fans"] == 1444
|
||||
assert record["creator_total_favorited"] == 9751
|
||||
assert record["creator_works"] is None
|
||||
assert record["creator_following"] == 0
|
||||
|
||||
def test_missing_author_counts_stay_none_not_zero(self):
|
||||
"""0 会被界面显示成「粉丝 0」;事实是没采到,必须留 None。"""
|
||||
record = douyin_api.normalize_aweme(
|
||||
{"aweme_id": "1", "author": {"uid": "1", "nickname": "x"}}
|
||||
)
|
||||
|
||||
assert record["creator_fans"] is None
|
||||
assert record["creator_total_favorited"] is None
|
||||
assert record["creator_works"] is None
|
||||
assert record["creator_following"] is None
|
||||
|
||||
def test_hashtags_come_from_text_extra_not_the_truncated_desc(self):
|
||||
"""`desc` 会在话题列表中途被截断,后半段话题只在 `text_extra` 里。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user