convez.ai
Skill
huiguangx

bilibili-subtitle

huiguangx/bilibili-subtitle

Ver no GitHub
InicialPluginScore · de 0 a 100

Claude Code skill: fetch Bilibili video subtitles for summarization and analysis

Instalação

$npx convez-ai huiguangx/bilibili-subtitle

1 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

Estrelas
0
Forks
0
Acompanhando
0
Saúde
42%
Último commit
há 5 meses
Versão
—
Issues abertas
0
Contribuidores
1

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:

  1. Hit Bilibili's public view + player/v2 APIs to find available subtitle tracks
  2. Pick the best track (UP-uploaded human captions > AI captions, Chinese > others)
  3. Download the subtitle JSON, join the lines, and hand the plain text back to Claude
  4. 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:

  1. Log into bilibili.com in your browser
  2. Open DevTools → Application → Cookies → https://www.bilibili.com
  3. Copy the value of the SESSDATA cookie
  4. 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's cid. 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-cookie again.
  • WBI signing not implemented. A few endpoints (notably the AI summary endpoint) require WBI-signed requests. This skill sticks to the unsigned view and player/v2 endpoints, which is enough for subtitles.

Privacy and security

  • config.json (containing your SESSDATA) is in .gitignore and must never be committed.
  • The script makes outbound requests only to api.bilibili.com and *.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.

Ver o original no GitHub

Bom para

Relacionados