$npx -y skills add programmerloverun/bilibili-to-doc --skill bilibili-to-docThis skill should be used when the user asks to "提取B站视频", "B站视频转文档", "bilibili视频提取", "将B站视频转文字", or provides a bilibili.com video URL and wants to extract its content into a structured Markdown document. Automatically downloads AI subtitles (Chinese) via yt-dlp, parses SRT, and g
| 1 | # Bilibili Video to Document (B站视频提取文档) |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Extract Bilibili video content into a structured Markdown document by: (1) downloading AI-generated subtitles via yt-dlp with browser cookies, (2) parsing the SRT subtitle file, (3) reorganizing the transcript into a logical, well-structured document with sections, tables, and code blocks. |
| 6 | |
| 7 | ## When to Use |
| 8 | |
| 9 | Trigger this skill when the user: |
| 10 | - Provides a bilibili.com video URL and asks to extract/converter it to a document |
| 11 | - "提取B站视频内容" / "B站视频转文档" / "将视频转成文章" |
| 12 | - "把这个B站视频整理成笔记" |
| 13 | - "generate document from Bilibili video" |
| 14 | |
| 15 | ## Prerequisites |
| 16 | |
| 17 | - `yt-dlp` must be installed: `pip3 install yt-dlp` |
| 18 | - Browser cookies are needed for Bilibili access (Chrome or other browser) |
| 19 | - Python 3.10+ for subtitle processing |
| 20 | |
| 21 | ## Workflow |
| 22 | |
| 23 | ### Step 1: Download Subtitles |
| 24 | |
| 25 | Use yt-dlp with browser cookies to download the AI Chinese subtitles: |
| 26 | |
| 27 | ```bash |
| 28 | yt-dlp --cookies-from-browser chrome "<BILIBILI_URL>" \ |
| 29 | --write-subs --sub-lang ai-zh \ |
| 30 | --skip-download \ |
| 31 | -o "/tmp/bilibili_output" |
| 32 | ``` |
| 33 | |
| 34 | Also get the video title: |
| 35 | |
| 36 | ```bash |
| 37 | yt-dlp --cookies-from-browser chrome "<BILIBILI_URL>" \ |
| 38 | --print "%(title)s" --skip-download 2>&1 | tail -1 |
| 39 | ``` |
| 40 | |
| 41 | If `chrome` browser cookies are not available, try `safari`, `firefox`, or `edge`. |
| 42 | |
| 43 | ### Step 2: Parse SRT and Generate Document |
| 44 | |
| 45 | Read the downloaded `.ai-zh.srt` file, then: |
| 46 | |
| 47 | 1. **Strip SRT formatting**: Remove sequence numbers, timestamps, empty lines |
| 48 | 2. **Merge consecutive lines**: Combine fragmented subtitle lines into complete sentences |
| 49 | 3. **Identify logical sections**: The AI should read through the full transcript and identify: |
| 50 | - Topic/theme divisions |
| 51 | - Step-by-step procedures |
| 52 | - Key concepts and definitions |
| 53 | - Configuration examples / code blocks |
| 54 | 4. **Structure the document** with proper heading hierarchy |
| 55 | |
| 56 | ### Step 3: Document Structure |
| 57 | |
| 58 | Generate a Markdown document following this structure (from reference template): |
| 59 | |
| 60 | ```markdown |
| 61 | # {Video Title} |
| 62 | |
| 63 | > 来源:B站视频 {BV号} | 主讲:{author} |
| 64 | |
| 65 | --- |
| 66 | |
| 67 | ## 一、{Topic Overview} |
| 68 | |
| 69 | {Summary of what the video covers} |
| 70 | |
| 71 | ## 二、{Main Content Sections} |
| 72 | |
| 73 | {Organized by logical topic divisions} |
| 74 | |
| 75 | ## N、总结 |
| 76 | |
| 77 | {Key takeaways} |
| 78 | ``` |
| 79 | |
| 80 | ### Step 4: Save Output |
| 81 | |
| 82 | Save to the user's Desktop by default: `~/Desktop/{Video_Title}.md` |
| 83 | |
| 84 | ## Document Writing Guidelines |
| 85 | |
| 86 | - **Preserve technical details**: Configuration code, SQL, JSON, YAML, shell commands should be formatted in code blocks |
| 87 | - **Use tables for comparisons**: Feature comparisons, parameter lists, pros/cons |
| 88 | - **Bullet lists for key points**: Use hierarchical bullet points for nested concepts |
| 89 | - **Add section numbers**: Use Chinese numbered sections (一、二、三...) for main divisions |
| 90 | - **Keep code accurate**: If the speaker mentions specific config/code, represent it faithfully |
| 91 | - **Add explanatory notes**: Fill in gaps where the spoken word might be ambiguous without visuals |
| 92 | - **Trim filler content**: Remove repeated phrases, verbal fillers (嗯, 啊, 这个), and self-promotion segments |
| 93 | - **Mark at the end**: Add a disclaimer that the document is AI-generated from subtitles |
| 94 | |
| 95 | ## Reference |
| 96 | |
| 97 | See `references/doc-template.md` for the full document template. |