Communitygithub.com

chemny/douyin-video-downloader

A local-first skill for downloading Douyin videos, covers, direct audio, and user profile video lists.

What is douyin-video-downloader?

This Node.js skill provides a comprehensive toolkit for downloading videos, covers, and direct audio from Douyin (TikTok China). It prioritizes watermark-free playback addresses by default and supports flexible quality selection (best, 720p, 1080p, or indexed). The skill stores metadata and download records in a local SQLite database, enabling batch operations, deduplication, and JSON/CSV exports. Key features include automatically opening the user's browser with preserved login state for collecting profile video lists, separate commands for downloading audio (from the music API, not extracted from video), and batch processing with configurable delays and confirmation prompts. Designed for developer tools like Claude Code, Cursor, or Codex, it requires Node.js and uses Playwright for browser automation, but avoids auto-installing dependencies. The skill emphasizes user consent—batch downloads only proceed after explicit confirmation—and gracefully handles missing audio URLs or unsupported quality targets.

Works with✓Claude Code~Codex CLI~Cursor
npx skills add chemny/douyin-video-downloader

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

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 quality
  • lowest: lowest quality
  • 720p / 1080p and similar quality labels
  • Numeric index: use the candidate index from the info output
  • ratio, format, gear_name and 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 size
  • small: smaller cover candidate
  • large / best: selects larger cover based on returned width/height
  • origin: original cover field
  • raw: raw/unprocessed cover field
  • dynamic / animated: dynamic cover candidate
  • gaussian / blur: blurred cover candidate
  • Numeric index: use the cover candidate index from the info output
  • 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 profiles
  • crawl_pages: each list page API response
  • videos: video titles, links, covers, duration, publish time, etc.
  • video_stats: like, comment, favorite, share, view, download, and other statistics fields
  • music: music ID, title, author, duration, direct audio URL, etc.
  • video_downloads: success/failure status, file path, and error info for subsequent batch downloads
  • media_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 --account specified, use ~/.agents/douyin-video-downloader/accounts/<account>/browser-profile
  • Prefer to reuse existing login state; if sessionid / sid_guard is 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 --quiet for quieter operation.

Related Skills