labali-douyin-download-user-posts
Treat this skill as a layered system, not a single script.
Layer Contract
SKILL.md(this file) is the policy layer.- Define goals, constraints, success criteria, and decision boundaries.
- Stay semantic and stable across UI changes.
references/architecture.mdis the strategy layer.- Define execution model, failure handling, and quality standards.
scripts/*.tsis the execution layer.- Scripts are execution assets, not the skill definition itself.
- Use agent-browser style browser automation with Chrome CDP session reuse.
- Keep extraction and downloading logic modular and replaceable.
Required Constraints
- Use browser automation only.
- Do not call private/undocumented Douyin APIs directly.
- Reuse manual-login session via unified Chrome CDP startup:
open -na "Google Chrome" --args --remote-debugging-port=9223 --user-data-dir="$HOME/.chrome-labali-no-proxy" --no-proxy-server. - Prefer semantic extraction from visible page state and loaded resources.
- Download target user's timeline posts and assets (text, images, optional videos).
- Export per-post
post.mdand media files. - Keep partial success: keep downloaded files even if some URLs fail.
- When
fixed_user_diris provided, reuse that exact folder and do not create a new timestamp folder. - Reuse current opened user homepage tab when it already matches target user.
- For timeline batch runs, open each post detail in a temporary tab, extract/download, then close tab and return to homepage tab.
- For each post, keep only one final video file in
videos/(prefer muxed AV or largest valid AV file).
NEVER
- Never keep multiple video files per post — select one final file (muxed AV or largest valid AV) and remove the rest.
- Never download unrelated images for a video post.
- Never report success without verifying at least one post was extracted.
Success Criteria
A run is successful only when all conditions hold:
- A user output folder exists (new timestamp folder or provided
fixed_user_dir). - At least one post is extracted from user timeline or direct video URL mode.
- Per-post folders contain
post.mdand downloaded media when available. - Video posts do not download unrelated images.
- URL output and logs retain canonical Douyin URL form.
Runtime Inputs
Use skill.yaml as the source of truth for input schema.
Operational Mode
- Default mode: guided browser flow + semantic extraction + authenticated media download.
- Links-only mode (
collect_links_only=true): only collect full detail links from works timeline and export topost_links.json+post_links.txtunder user output dir, no media download. - Startup guidance:
- launch/reuse Chrome by the unified
open -na "Google Chrome"CDP command, - connect via CDP port,
- open target user page,
- check login status,
- if required, guide user to complete manual login in the same window.
- launch/reuse Chrome by the unified
- Input guidance:
- if
user_urlis missing, prompt interactively, - if
output_diris missing, prompt interactively with default.
- if
- Pagination guidance:
- scroll user timeline continuously,
- click visible expansion controls where needed,
- stop when no more new cards appear or explicit end markers appear.
- Text guidance:
- prefer detail JSON
descfrom targetpostId, - strip platform-generated suffixes (e.g. Douyin share/promotion footers appended after the original post text).
- prefer detail JSON
- Publish time guidance:
- extract from detail JSON
create_timefirst, - fallback to visible page text parsing.
- extract from detail JSON
If failure handling or extraction decisions are unclear, load
references/architecture.md. If extraction or media selection strategy is unclear, loadreferences/plan.md.
Resources
- Architecture and standards:
references/architecture.md - Workflow map and extraction plan:
references/plan.md - Shared runtime and downloader helpers:
scripts/core.ts - Main orchestration:
scripts/executor.ts - CLI entry:
scripts/run.ts - Regression checks:
tests/test_regression.sh