Record important information to long-term memory for learning user preferences, successful patterns, and error lessons. When you need to remember user preferences, save successful patterns, or record lessons from errors.
日本語の概要は準備中です。原文の説明を表示しています。
Extract subtitles and transcripts from Bilibili and YouTube videos. Use when the user wants to get subtitles from B站 (Bilibili) or YouTube, extract Chinese/Japanese video transcripts, watch member-only Bilibili content, or perform Q&A on video content. Supports dual-platform subtitle extraction with yt-dlp.
インストールする前に、エージェントに与えられる指示の中身を確認できます。
从 Bilibili(B站)和 YouTube 视频中提取字幕/转录文本,支持多语言、会员视频和内容问答。
yt-dlp is a feature-rich command-line audio/video downloader that also extracts subtitles.
Via pip (recommended):
pip install yt-dlp
Via package manager:
# macOS
brew install yt-dlp
# Ubuntu/Debian
sudo apt install yt-dlp
# Windows (scoop)
scoop install yt-dlp
Verify installation:
yt-dlp --version
Some subtitle formats require ffmpeg for conversion:
# macOS
brew install ffmpeg
# Ubuntu/Debian
sudo apt install ffmpeg
# Windows (scoop)
scoop install ffmpeg
Bilibili member-only (大会员) content requires authentication cookies.
Method 1: Export cookies from browser
Install a browser extension like "Get cookies.txt LOCALLY" and export cookies for bilibili.com:
# Use the exported cookies file
yt-dlp --cookies cookies.txt "https://www.bilibili.com/video/BV..."
Method 2: Use browser cookies directly
# yt-dlp can read cookies from your browser
yt-dlp --cookies-from-browser chrome "https://www.bilibili.com/video/BV..."
yt-dlp --cookies-from-browser firefox "https://www.bilibili.com/video/BV..."
yt-dlp --cookies-from-browser edge "https://www.bilibili.com/video/BV..."
Security note: Cookie files contain your login session. Do not share them or commit them to version control.
| Format | Example |
|---|---|
| Standard BV | https://www.bilibili.com/video/BV1xx411c7mD |
| With page | https://www.bilibili.com/video/BV1xx411c7mD?p=2 |
| Short link | https://b23.tv/aBcDeFg |
| Bangumi | https://www.bilibili.com/bangumi/play/ep12345 |
| Old AV format | https://www.bilibili.com/video/av12345 |
| Mobile | https://m.bilibili.com/video/BV1xx411c7mD |
| Format | Example |
|---|---|
| Standard | https://www.youtube.com/watch?v=VIDEO_ID |
| Short | https://youtu.be/VIDEO_ID |
| Embed | https://www.youtube.com/embed/VIDEO_ID |
| Shorts | https://www.youtube.com/shorts/VIDEO_ID |
List available subtitles:
yt-dlp --list-subs "https://www.bilibili.com/video/BV..."
Download subtitles only (no video):
# Download all available subtitles
yt-dlp --write-sub --skip-download "https://www.bilibili.com/video/BV..."
# Download auto-generated subtitles as well
yt-dlp --write-sub --write-auto-sub --skip-download "https://www.bilibili.com/video/BV..."
# Download specific language (Chinese)
yt-dlp --write-sub --sub-lang zh-CN --skip-download "https://www.bilibili.com/video/BV..."
# Convert to SRT format
yt-dlp --write-sub --sub-lang zh-CN --convert-subs srt --skip-download "https://www.bilibili.com/video/BV..."
Member-only videos (require cookies):
yt-dlp --cookies-from-browser chrome --write-sub --skip-download "https://www.bilibili.com/video/BV..."
List available subtitles:
yt-dlp --list-subs "https://www.youtube.com/watch?v=VIDEO_ID"
Download subtitles:
# English subtitles
yt-dlp --write-sub --sub-lang en --skip-download "https://www.youtube.com/watch?v=VIDEO_ID"
# Auto-generated subtitles
yt-dlp --write-auto-sub --sub-lang en --skip-download "https://www.youtube.com/watch?v=VIDEO_ID"
# Multiple languages
yt-dlp --write-sub --sub-lang "en,zh-Hans,ja" --skip-download "URL"
# Convert to plain text (SRT format)
yt-dlp --write-auto-sub --sub-lang en --convert-subs srt --skip-download "URL"
yt-dlp downloads subtitles in various formats. Here's how to parse common ones:
import re
import json
def parse_srt(filepath: str) -> list[dict]:
"""Parse SRT subtitle file into structured segments."""
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
segments = []
blocks = content.strip().split('\n\n')
for block in blocks:
lines = block.strip().split('\n')
if len(lines) >= 3:
time_match = re.match(
r'(\d{2}):(\d{2}):(\d{2}),(\d{3}) --> (\d{2}):(\d{2}):(\d{2}),(\d{3})',
lines[1]
)
if time_match:
h, m, s = int(time_match[1]), int(time_match[2]), int(time_match[3])
start_sec = h * 3600 + m * 60 + s
text = ' '.join(lines[2:]).strip()
# Remove HTML tags from auto-generated subs
text = re.sub(r'<[^>]+>', '', text)
if text:
segments.append({
'start': start_sec,
'text': text
})
return segments
def parse_json3(filepath: str) -> list[dict]:
"""Parse YouTube JSON3 subtitle format."""
with open(filepath, 'r', encoding='utf-8') as f:
data = json.load(f)
segments = []
for event in data.get('events', []):
start_ms = event.get('tStartMs', 0)
segs = event.get('segs', [])
text = ''.join(s.get('utf8', '') for s in segs).strip()
if text and text != '\n':
segments.append({
'start': start_ms / 1000,
'text': text
})
return segments
def segments_to_text(segments: list[dict]) -> str:
"""Convert segments to plain text with timestamps."""
lines = []
for seg in segments:
minutes = int(seg['start'] // 60)
seconds = int(seg['start'] % 60)
lines.append(f"[{minutes:02d}:{seconds:02d}] {seg['text']}")
return '\n'.join(lines)
Once you have the transcript text, generate summaries or answer questions about the content.
For summarization, combine all subtitle text and apply a structured prompt:
Based on the following video transcript, provide:
1. **概要** (Executive Summary): 2-3 sentences in the video's language
2. **要点** (Key Points): Bulleted list with timestamps [MM:SS]
3. **详细笔记** (Detailed Notes): Organized by topic sections
4. **问答** (Q&A): Answer any specific questions the user has
Transcript:
{full_transcript_text}
For Q&A, search the transcript for relevant segments first, then answer based on context.
User says: "提取这个B站视频的字幕: https://www.bilibili.com/video/BV..."
yt-dlp --list-subs to check available subtitlesyt-dlp --write-sub --sub-lang zh-CN --convert-subs srt --skip-download URLUser says: "这是大会员视频,帮我提取字幕"
--cookies-from-browser chrome (or user's preferred browser)User says: "Get both English and Chinese subtitles from this YouTube video"
en and zh-Hans subtitlesUser says: "视频里有没有提到关于 X 的内容?"
User provides a playlist or series URL:
yt-dlp --flat-playlist to list all videosUser shares a bangumi URL:
--list-subs to show all available languages# 📝 Subtitles: [Video Title]
**Platform**: Bilibili / YouTube
**Language**: 中文 (zh-CN)
**Duration**: ~XX minutes
**Subtitle Type**: Manual / Auto-generated
---
[00:00] 大家好,欢迎来到今天的视频
[00:05] 今天我们要讨论的话题是...
[00:12] 首先我们来看一下背景
...
# 📋 Video Summary: [Title]
## 概要
[2-3 sentence summary in the video's language]
## 要点
- **[00:00]** 开场介绍和主题说明
- **[02:15]** 第一个核心观点
- **[08:30]** 关键论据和数据
- **[15:00]** 实际演示
- **[22:45]** 总结与下一步
## 详细笔记
### 第一部分: [主题] (00:00 - 05:30)
[详细内容笔记]
### 第二部分: [主题] (05:30 - 12:00)
[详细内容笔记]
Problem: Some Bilibili content is restricted to mainland China.
Solutions:
yt-dlp --proxy socks5://127.0.0.1:1080 URL--geo-bypass flag: yt-dlp --geo-bypass URL--geo-bypass-country CNyt-dlp --geo-bypass-country CN --write-sub --skip-download "URL"
Problem: yt-dlp returns an error or empty subtitles for 大会员 videos.
Solution: Always check if the video requires 大会员 access. If so, cookies are mandatory:
# If this fails:
yt-dlp --list-subs "URL"
# ERROR: This video requires premium membership
# Try with cookies:
yt-dlp --cookies-from-browser chrome --list-subs "URL"
If browser cookie extraction fails (common on Linux), export cookies manually to a cookies.txt file.
Problem: Many Bilibili videos, especially older ones or user-generated content, have no subtitles at all.
Solution: Inform the user clearly. Unlike YouTube, Bilibili does not always generate auto-subtitles. The video may only have hardcoded (burned-in) subtitles which require OCR — beyond the scope of this skill.
Problem: Bilibili frequently changes its API, causing older yt-dlp versions to fail.
Solution: Always ensure yt-dlp is up to date:
pip install -U yt-dlp
# or
yt-dlp -U
Problem: Different videos return subtitles in different formats (SRT, VTT, JSON3, ASS).
Solution: Use --convert-subs srt to normalize all subtitles to SRT format:
yt-dlp --write-sub --convert-subs srt --skip-download "URL"
Problem: Rapid successive requests may get temporarily blocked.
Solutions:
--sleep-requests 2--sleep-interval 5 for playlists--max-downloads 10Problem: Bilibili short links (b23.tv) may not resolve properly.
Solution: yt-dlp handles most redirects automatically, but if it fails:
# Manually resolve the short link first
curl -sI "https://b23.tv/aBcDeFg" | grep -i location
| Platform | Language | Code |
|---|---|---|
| Bilibili | 中文 | zh-CN, zh |
| Bilibili | English | en |
| Bilibili | 日本語 | ja |
| YouTube | English | en |
| YouTube | 中文(简体) | zh-Hans |
| YouTube | 中文(繁体) | zh-Hant |
| YouTube | 日本語 | ja |
| YouTube | 한국어 | ko |
# Bilibili
yt-dlp --list-subs "https://www.bilibili.com/video/BV..."
# YouTube
yt-dlp --list-subs "https://www.youtube.com/watch?v=..."
The output shows both manual and auto-generated subtitle tracks with their language codes.
| Feature | Bilibili | YouTube |
|---|---|---|
| Auto-generated subtitles | Rare | Common |
| Manual subtitles | Common (CC) | Common |
| Multi-language subs | Some (bangumi) | Many |
| Cookie auth needed | 大会员 content | Age-restricted |
| Geo-restrictions | Some content CN-only | Varies |
| Subtitle formats | SRT, JSON | SRT, VTT, JSON3 |
| Playlist support | Yes (multi-page) | Yes |
| Rate limiting | Moderate | Moderate |
まだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
Record important information to long-term memory for learning user preferences, successful patterns, and error lessons. When you need to remember user preferences, save successful patterns, or record lessons from errors.
日本語の概要は準備中です。原文の説明を表示しています。
Click page elements by CSS selector or text content. When you need to click buttons, links, or select options. PREREQUISITE - must use browser_navigate to open target page first.
日本語の概要は準備中です。原文の説明を表示しています。
Extract page content and element text from current webpage. When you need to read page information, get element values, scrape data, or verify page content.
日本語の概要は準備中です。原文の説明を表示しています。
List all open browser tabs with their index, URL and title. When you need to check what pages are open, manage multiple tabs, or find a specific tab to switch to.
日本語の概要は準備中です。原文の説明を表示しています。
Navigate browser to specified URL to open a webpage. When you need to open webpages or start web automation. PREREQUISITE - must call before browser_click/type operations. Auto-starts browser if not running.
日本語の概要は準備中です。原文の説明を表示しています。
Open new browser tab and navigate to URL (keeps current page open). When you need to open additional page without closing current, or multi-task across pages. PREREQUISITE - must confirm browser is running first.
日本語の概要は準備中です。原文の説明を表示しています。