feat: add history replay and work filters

This commit is contained in:
2026-09-07 12:09:49 +08:00
parent dafa335bb5
commit 07524a36cd
16 changed files with 1739 additions and 142 deletions
+11 -19
View File
@@ -6,7 +6,9 @@ import json
import sys
from datetime import datetime
from pathlib import Path
from typing import Any, cast
from account_log import visible
from cdp_explicit import ( # pyright: ignore[reportMissingImports]
add_cdp_args,
configure,
@@ -62,24 +64,14 @@ def parse_user_response(value) -> dict:
return {**user, "uid": str(uid)}
def compact_user(user: dict) -> dict:
"""保留个人信息常用字段,避免把手机号等敏感字段写入文件。"""
avatars = (user.get("avatar_300x300") or user.get("avatar_thumb") or {}).get(
"url_list"
) or []
return {
"uid": user.get("uid"),
"sec_uid": user.get("sec_uid"),
"nickname": user.get("nickname"),
"douyin_id": user.get("short_id") or user.get("unique_id"),
"signature": user.get("signature", ""),
"following_count": user.get("following_count", 0),
"follower_count": user.get("follower_count", 0),
"total_favorited": user.get("total_favorited", 0),
"aweme_count": user.get("aweme_count", 0),
"gender": user.get("gender", 0),
"avatar_url": avatars[0] if avatars else None,
}
def business_user(user: dict) -> dict:
"""Return full platform business data while retaining credential protection."""
result = cast(dict[str, Any], visible(user))
avatar = result.get("avatar_300x300") or result.get("avatar_thumb") or {}
avatars = avatar.get("url_list") if isinstance(avatar, dict) else []
result["douyin_id"] = result.get("short_id") or result.get("unique_id") or ""
result["avatar_url"] = avatars[0] if avatars else result.get("avatar_url") or ""
return result
def main() -> int:
@@ -89,7 +81,7 @@ def main() -> int:
args = parser.parse_args()
configure(args)
try:
user = compact_user(get_user_from_browser())
user = business_user(get_user_from_browser())
args.output.write_text(
json.dumps(
{"fetched_at": datetime.now().astimezone().isoformat(), "user": user},