TikTok 视频分析器
Use the bundled Playwright runner to open one TikTok video detail page in a local headed browser, extract publicly visible video metadata plus any platform subtitle track, and write a Markdown report into the current working directory. Preserve the original-language transcript as the main transcript. If the transcript is neither English nor Chinese, append a complete, idiomatic English translation after the original transcript.
Preconditions
- This skill launches a local headed Chrome session. Treat it as a browser automation task, not a pure sandbox CLI task.
- For the first real extraction in a fresh thread or restricted runtime, request browser-launch approval up front.
- Use one TikTok video URL per run.
- Prefer anonymous browsing first, but allow normal browser cookies if TikTok serves richer page data that way.
- Allow a local proxy via environment variable when needed.
- Do not run Whisper or any other ASR fallback in this skill.
Install
Install the runner dependencies once:
cd "$HOME/.codex/skills/tiktok-caption-extractor/scripts"
npm install
Only if Chromium fallback is needed:
npx playwright install chromium
Command
Run the wrapper script:
"$HOME/.codex/skills/tiktok-caption-extractor/scripts/extract_video" \
--video-url "https://www.tiktok.com/@fiona_in_guangzhou/video/7480362031934115102"
Optional flags:
--slow-mo MS
--timeout-ms MS
--headless
Optional environment variables:
TIKTOK_ANALYZER_PROXY
https_proxy
http_proxy
all_proxy
Use --help on the wrapper for the latest usage text.
Workflow
- Validate the video URL and derive
video_id and creator handle from the public URL.
- Launch a local Chrome session with Playwright and light stealth settings.
- Open the TikTok video detail page, wait for the page to stabilize, dismiss obvious modals, and detect blocker states early.
- Collect page JSON from
__UNIVERSAL_DATA_FOR_REHYDRATION__, SIGI_STATE, and __NEXT_DATA__, while also recording small JSON and subtitle-like network responses.
- Build metadata from structured page data first, then use page metadata fallbacks only for fields already visible on the page.
- Extract platform subtitle track URLs or direct subtitle payloads from structured data and captured responses.
- If no platform subtitle is available, fail with
该视频没有可提取的平台字幕.
- Write the Markdown report into the current working directory.
- Check the generated
## 口播文案(语音转录) text and the runner's printed subtitle language. If the source transcript is not English and not Chinese, append an English translation section to the same Markdown file.
Translation Rule
- Always keep the original extracted transcript under
## 口播文案(语音转录); do not replace it with a translation.
- If the transcript is English or Chinese, do not add a translation section.
- If the transcript is French, Spanish, Portuguese, German, Italian, Arabic, Japanese, Korean, Russian, Thai, Vietnamese, Indonesian, or any other non-English/non-Chinese language, append this section after the original transcript:
## English Translation
<accurate, idiomatic, complete English translation of the full transcript>
- Translate the full transcript faithfully, including repeated lines, rhetorical questions, names, place names, and domain-specific terms. Keep paragraph breaks if they make the spoken content easier to read.
- Use the subtitle track language printed by the runner when it is specific, but verify against the actual transcript text. Treat
und as unknown and decide from the text itself.
- If TikTok exposes both an original-language subtitle track and an English translated track, prefer the original-language transcript for
## 口播文案(语音转录), then append the English translation separately.
Output Contract
- Output directory: current working directory.
- Output filename:
tiktok.{author}.{description}.md
- Markdown layout must match the legacy analyzer:
# TikTok 视频分析
## 基本信息
## 视频描述
## Hashtags
## 口播文案(语音转录)
- Optional translation section:
## English Translation only when the transcript is neither English nor Chinese.
Failure Handling
- If TikTok redirects to login, challenge, or other blockers before extraction succeeds, fail clearly with the blocker reason.
- If metadata is available but no platform subtitle track is found, fail clearly with
该视频没有可提取的平台字幕.
- If TikTok changes the page structure, update
scripts/extract_video.mjs instead of inventing ad hoc selectors in the conversation.
References
- Field mapping and output rules:
references/field-map.md
1---2name: tiktok-caption-extractor3description: Extract TikTok video metadata and platform-provided caption/transcript tracks from one public TikTok video URL into a Markdown report. Use when Codex receives a TikTok video link and needs to produce the same Markdown layout as the legacy TikTok analyzer, but with browser-based Playwright extraction instead of Whisper. If the transcript is neither English nor Chinese, append a complete English translation after the original transcript. If the video has no platform transcript/caption track, fail clearly instead of inventing text.4---56# TikTok 视频分析器78Use the bundled Playwright runner to open one TikTok video detail page in a local headed browser, extract publicly visible video metadata plus any platform subtitle track, and write a Markdown report into the current working directory. Preserve the original-language transcript as the main transcript. If the transcript is neither English nor Chinese, append a complete, idiomatic English translation after the original transcript.910## Preconditions1112- This skill launches a local headed Chrome session. Treat it as a browser automation task, not a pure sandbox CLI task.13- For the first real extraction in a fresh thread or restricted runtime, request browser-launch approval up front.14- Use one TikTok video URL per run.15- Prefer anonymous browsing first, but allow normal browser cookies if TikTok serves richer page data that way.16- Allow a local proxy via environment variable when needed.17- Do not run Whisper or any other ASR fallback in this skill.1819## Install2021Install the runner dependencies once:2223```bash24cd "$HOME/.codex/skills/tiktok-caption-extractor/scripts"25npm install26```2728Only if Chromium fallback is needed:2930```bash31npx playwright install chromium32```3334## Command3536Run the wrapper script:3738```bash39"$HOME/.codex/skills/tiktok-caption-extractor/scripts/extract_video" \40 --video-url "https://www.tiktok.com/@fiona_in_guangzhou/video/7480362031934115102"41```4243Optional flags:4445- `--slow-mo MS`46- `--timeout-ms MS`47- `--headless`4849Optional environment variables:5051- `TIKTOK_ANALYZER_PROXY`52- `https_proxy`53- `http_proxy`54- `all_proxy`5556Use `--help` on the wrapper for the latest usage text.5758## Workflow59601. Validate the video URL and derive `video_id` and creator handle from the public URL.612. Launch a local Chrome session with Playwright and light stealth settings.623. Open the TikTok video detail page, wait for the page to stabilize, dismiss obvious modals, and detect blocker states early.634. Collect page JSON from `__UNIVERSAL_DATA_FOR_REHYDRATION__`, `SIGI_STATE`, and `__NEXT_DATA__`, while also recording small JSON and subtitle-like network responses.645. Build metadata from structured page data first, then use page metadata fallbacks only for fields already visible on the page.656. Extract platform subtitle track URLs or direct subtitle payloads from structured data and captured responses.667. If no platform subtitle is available, fail with `该视频没有可提取的平台字幕`.678. Write the Markdown report into the current working directory.689. Check the generated `## 口播文案(语音转录)` text and the runner's printed subtitle language. If the source transcript is not English and not Chinese, append an English translation section to the same Markdown file.6970## Translation Rule7172- Always keep the original extracted transcript under `## 口播文案(语音转录)`; do not replace it with a translation.73- If the transcript is English or Chinese, do not add a translation section.74- If the transcript is French, Spanish, Portuguese, German, Italian, Arabic, Japanese, Korean, Russian, Thai, Vietnamese, Indonesian, or any other non-English/non-Chinese language, append this section after the original transcript:7576```markdown77## English Translation78<accurate, idiomatic, complete English translation of the full transcript>79```8081- Translate the full transcript faithfully, including repeated lines, rhetorical questions, names, place names, and domain-specific terms. Keep paragraph breaks if they make the spoken content easier to read.82- Use the subtitle track language printed by the runner when it is specific, but verify against the actual transcript text. Treat `und` as unknown and decide from the text itself.83- If TikTok exposes both an original-language subtitle track and an English translated track, prefer the original-language transcript for `## 口播文案(语音转录)`, then append the English translation separately.8485## Output Contract8687- Output directory: current working directory.88- Output filename: `tiktok.{author}.{description}.md`89- Markdown layout must match the legacy analyzer:90 - `# TikTok 视频分析`91 - `## 基本信息`92 - `## 视频描述`93 - `## Hashtags`94 - `## 口播文案(语音转录)`95- Optional translation section:96 - `## English Translation` only when the transcript is neither English nor Chinese.9798## Failure Handling99100- If TikTok redirects to login, challenge, or other blockers before extraction succeeds, fail clearly with the blocker reason.101- If metadata is available but no platform subtitle track is found, fail clearly with `该视频没有可提取的平台字幕`.102- If TikTok changes the page structure, update `scripts/extract_video.mjs` instead of inventing ad hoc selectors in the conversation.103104## References105106- Field mapping and output rules: `references/field-map.md`