bilibili-subtitle
huiguangx/bilibili-subtitle
Claude Code skill: fetch Bilibili video subtitles for summarization and analysis
Instalação
npx convez-ai huiguangx/bilibili-subtitle1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.
Métricas
README
A tradução para o português deste README ainda está na fila.
bilibili-subtitle
A Claude Code skill that fetches Bilibili (B站) video subtitles so Claude can summarize, translate, or analyze the content instead of saying "I can't watch videos."
What it does
Give Claude a Bilibili link or BVID, and it will:
- Hit Bilibili's public
view+player/v2APIs to find available subtitle tracks - Pick the best track (UP-uploaded human captions > AI captions, Chinese > others)
- Download the subtitle JSON, join the lines, and hand the plain text back to Claude
- Claude reads the transcript and answers the user's actual question
No yt-dlp, no ffmpeg, no transcription. Just stdlib Python and Bilibili's own caption data.
Why this exists
LLMs can't ingest video. But most Bilibili videos that people share for content (lectures, podcasts, interviews, tutorials) already have captions — either uploaded by the UP or auto-generated by Bilibili. This skill closes that gap.
Install
Drop the folder into your Claude Code skills directory:
~/.claude/skills/bilibili-subtitle/ # macOS / Linux
%USERPROFILE%\.claude\skills\bilibili-subtitle\ # Windows
That's it — Claude Code picks it up automatically. Requires Python 3 on your PATH.
First-time setup: SESSDATA
Most B 站 videos only have AI-generated subtitles, and Bilibili requires a logged-in cookie to access them. One-time setup:
- Log into bilibili.com in your browser
- Open DevTools → Application → Cookies →
https://www.bilibili.com - Copy the value of the
SESSDATAcookie - Save it:
python ~/.claude/skills/bilibili-subtitle/fetch_subtitle.py set-cookie '<your-SESSDATA>'
The cookie lands in config.json next to the script. config.json is gitignored — never commit it. Treat SESSDATA as you'd treat your B 站 password: anyone holding it can act as you on Bilibili.
If a video has UP-uploaded human subtitles, you don't need SESSDATA at all.
Usage
Once installed, just paste a Bilibili URL into Claude Code and ask about it:
https://www.bilibili.com/video/BVxxxxxxxxxx/ 总结一下
Claude will run the skill, read the transcript, and reply with what's actually in the video.
You can also call the script directly:
python fetch_subtitle.py BVxxxxxxxxxx # plain transcript
python fetch_subtitle.py BVxxxxxxxxxx --timestamps # with [hh:mm:ss] prefixes
python fetch_subtitle.py BVxxxxxxxxxx --lang zh-CN # force a specific track
python fetch_subtitle.py show-config # show stored cookie (masked)
Stdout = transcript, stderr = metadata (title, available languages, which track was picked).
Limitations
- No transcription fallback. If a video has zero subtitles (no human, no AI), the skill exits with an error. Adding Whisper would mean shipping
yt-dlp+ffmpeg+ a model, which is out of scope. - Single-part videos only. Multi-part videos (
?p=2) default to the first part'scid. Extending to specific parts is straightforward — PRs welcome. - SESSDATA expires. When it does, the script will return empty subtitle lists for AI-only videos. Re-grab the cookie and
set-cookieagain. - WBI signing not implemented. A few endpoints (notably the AI summary endpoint) require WBI-signed requests. This skill sticks to the unsigned
viewandplayer/v2endpoints, which is enough for subtitles.
Privacy and security
config.json(containing your SESSDATA) is in.gitignoreand must never be committed.- The script makes outbound requests only to
api.bilibili.comand*.bilivideo.cn(the subtitle CDN). It does not send your cookie anywhere else. - Treat fetched transcripts as untrusted external content — don't blindly execute anything they suggest.
License
MIT — see LICENSE.