douyin-video-downloader Skill
This skill is a local Node.js tool for downloading Douyin videos and direct audio.
Features
- Get Douyin video information
- List available video quality/bitrate candidates
- Download MP4 at specified quality
- Download cover image concurrently with video, defaulting to medium size
- Support standalone cover download
- Download direct audio from the Douyin music detail API
- Batch download direct audio from a collection database
- Use a local SQLite collection database to record users, list pages, videos, statistics, and music info
- Automatically open user profiles and reuse the local browser login state to collect lists
- Export JSON/CSV from the collection database, or batch download videos from it
- Default to using watermark-free playback URLs where possible
Usage
First, determine {SKILL_DIR} as the directory containing this SKILL.md.
View video info, qualities, and cover candidates
node {SKILL_DIR}/douyin-video.js info "Douyin share link" --cover-size medium
Download with default quality
node {SKILL_DIR}/douyin-video.js download "Douyin share link" -o ./videos
Default selects best, the highest quality candidate the script can identify.
Video download will also download the cover image, and write video, cover, and metadata paths into a metadata JSON.
Download with specified quality
node {SKILL_DIR}/douyin-video.js download "Douyin share link" --quality best -o ./videos
node {SKILL_DIR}/douyin-video.js download "Douyin share link" --quality 720p -o ./videos
node {SKILL_DIR}/douyin-video.js download "Douyin share link" --quality 0 -o ./videos
--quality supports:
best: highest qualitylowest: lowest quality720p/1080pand similar quality labels- Numeric index: use the candidate index from the
infooutput ratio,format,gear_nameand other candidate label partial matches
Download with specified cover size
node {SKILL_DIR}/douyin-video.js download "Douyin share link" --cover-size medium -o ./videos
node {SKILL_DIR}/douyin-video.js download "Douyin share link" --cover-size origin -o ./videos
node {SKILL_DIR}/douyin-video.js download "Douyin share link" --cover-size 0 -o ./videos
node {SKILL_DIR}/douyin-video.js cover "Douyin share link" --cover-size medium -o ./videos
--cover-size supports:
medium: default, medium sizesmall: smaller cover candidatelarge/best: selects larger cover based on returned width/heightorigin: original cover fieldraw: raw/unprocessed cover fielddynamic/animated: dynamic cover candidategaussian/blur: blurred cover candidate- Numeric index: use the cover candidate index from the
infooutput none: do not download cover
Download direct audio
node {SKILL_DIR}/douyin-video.js audio "Douyin share link" -o ./audios
The audio command first resolves the video's music.mid/id, then requests the Douyin music detail API to get music.play_url and downloads the original audio file. It will error if there is no direct audio URL; it will not extract audio from MP4.
Video, cover, and audio commands merge into the same metadata JSON; subsequent audio execution will not overwrite previous video or cover file paths.
Create SQLite collection database
node {SKILL_DIR}/douyin-video.js db-init --db ./douyin_collection.sqlite
The collection database includes:
users: user profilescrawl_pages: each list page API responsevideos: video titles, links, covers, duration, publish time, etc.video_stats: like, comment, favorite, share, view, download, and other statistics fieldsmusic: music ID, title, author, duration, direct audio URL, etc.video_downloads: success/failure status, file path, and error info for subsequent batch downloadsmedia_downloads: success/failure status, file path, and error info for media files (audio, etc.)
Import user video list API JSON
User profile lists typically require login state and Douyin web signature parameters. First, open the user profile in a browser and log in, then save the /aweme/v1/web/aweme/post/ API response body as a JSON file, and import it:
node {SKILL_DIR}/douyin-video.js db-import-post-json \
--db ./douyin_collection.sqlite \
--input ./post_1036.json \
--limit 100
Default rule: collect only the first 100 video entries for a given user list. You can import multiple paginated JSONs; the same aweme_id will be overwritten/updated, not duplicated. After reaching 100 entries, subsequent paginated imports will only record the list page response without inserting new videos.
After collection is complete, you must inform the user and ask if they want to start downloading. Do not auto-download all videos after collection.
Auto collect user profile
node {SKILL_DIR}/douyin-video.js collect-user "Douyin user profile URL" \
--db ./douyin_collection.sqlite \
-o ./collection \
--account default \
--limit 100
collect-user will:
- Use a fixed browser profile; with
--accountspecified, use~/.agents/douyin-video-downloader/accounts/<account>/browser-profile - Prefer to reuse existing login state; if
sessionid/sid_guardis valid, fetch directly - If login state is invalid, open a browser and prompt the user to scan a QR code to log in
- Continue fetching
/aweme/v1/web/aweme/post/after user logs in - Save raw API JSON, import into SQLite, and export JSON/CSV
- After collection, only indicate completion; do not auto-download
Check login status
node {SKILL_DIR}/douyin-video.js check-login --account default
check-login will open or reuse the account's browser profile and check if the Douyin login cookie is valid. Returns 0 if logged in; returns 2 if not logged in, and prompts the user to scan a QR code in the opened browser. This command only checks login status; it does not collect or download.
Optional parameters:
--account default
--browser-session douyin-video-downloader
--profile-dir ~/.agents/douyin-video-downloader/browser-profile
--login-timeout 180
--reuse-session
--account is the recommended account isolation method. When --profile-dir is not specified, the account name automatically maps to a dedicated browser profile; when --browser-session is not specified, the account name is also used to generate a stable session name. --browser-session is normalized to a shorter, safe name to avoid overly long Playwright CLI socket paths. If there is an existing logged-in browser session, add --reuse-session to directly reuse it without reopening the browser.
If the machine does not have a Playwright CLI runtime environment, the command will prompt to install dependencies; it will not auto-install.
Export collection database
node {SKILL_DIR}/douyin-video.js db-export --db ./douyin_collection.sqlite -o ./videos.json
node {SKILL_DIR}/douyin-video.js db-export --db ./douyin_collection.sqlite -o ./videos.csv --format csv
Batch download videos from collection database
node {SKILL_DIR}/douyin-video.js db-download-batch \
--db ./douyin_collection.sqlite \
-o ./videos \
--quality best \
--cover-size medium \
--delay-seconds 5 \
--confirm-every 10 \
--download-limit 100
Batch download processes videos in the order of list page URLs in the collection database: after the first URL download completes, wait at least 5 seconds, then open the second URL. Download URLs, covers, and metadata are preferentially generated from the saved list API raw_json in SQLite; only fall back to re-parsing the video page if original data is missing. Each video downloads the default medium cover concurrently; use --cover-size to select a different cover size. After every 10 successful downloads, you must ask the user if they want to continue; only proceed after user confirmation. --download-limit is the total download cap for this command. Successfully downloaded videos are recorded in the video_downloads table; subsequent downloads of the same quality will skip them.
Batch download audio from collection database
node {SKILL_DIR}/douyin-video.js db-download-audio-batch \
--db ./douyin_collection.sqlite \
-o ./audios \
--delay-seconds 5 \
--download-limit 100
Batch audio download preferentially uses the music.play_url direct audio URL from the collection database; it does not extract audio from video. Download status is recorded in the media_downloads table; already downloaded audio is skipped. Wait at least 5 seconds between each audio download. --download-limit is the total download cap for this command.
Notes
- Download and collection capabilities depend on Douyin page structure, web APIs, and CDN address rules; parsing logic may need updates after platform changes.
- User profile list APIs typically require a logged-in browser context; this skill does not include login bypass logic.
- Audio download only uses the direct audio URL from the Douyin music detail API; it will not use ffmpeg to extract audio from video.
- List collection and video download are two independent steps; batch download is not performed without user confirmation.
- Download progress is output every 5% by default; add
--quietfor quieter operation.