技能圖譜SKILLSGROVE
技能圖譜/短影片與自媒體/valtterimelkko/agent-workflow-skills/youtube-caption

youtube-caption

安裝

$npx skills add https://github.com/valtterimelkko/agent-workflow-skills --skill youtube-caption
$git clone --depth 1 https://github.com/valtterimelkko/agent-workflow-skills.git /tmp/agent-workflow-skills && mkdir -p ~/.claude/skills && cp -r /tmp/agent-workflow-skills/skills/youtube-caption ~/.claude/skills/youtube-caption
請幫我安裝這個 Agent Skill:https://github.com/valtterimelkko/agent-workflow-skills/tree/9a694c0ef1e57c18fbecf43d69d3a2386018994d/skills/youtube-caption ,先閱讀它的 SKILL.md 和指令碼,確認安全後再安裝到我的技能目錄。

簡介

原文描述 · MITFetch YouTube video captions/transcripts and metadata. Use when you need to download video transcripts, extract captions from YouTube URLs, get video descriptions and metadata, or process YouTube video text content. Supports residential proxy for reliable caption and metadata fetching (credentials can be auto-loaded from environment or a shell startup file).
以下 SKILL.md 內容轉載自 valtterimelkko/agent-workflow-skills(提交 9a694c0),依據 MIT 許可證轉載正文(文字未改動;僅省略檔案頭後設資料、將圖片顯示為連結,超長內容會截斷);版權歸 2026 Valtteri Melkko 所有。許可證:LICENSE。僅展示說明檔案,附帶指令碼請在原倉庫檢視。

YouTube Caption Fetcher

Download captions/transcripts and metadata from any YouTube video using the youtube-transcript-api library with optional residential proxy support.

Prerequisites

Required Python package:

pip install youtube-transcript-api

Residential Proxy Credentials (auto-loaded from environment or a shell startup file):

# Reddit proxy for YouTube caption and metadata fetching
export YOUTUBE_PROXY_URL="http://username:password@host:port"
# legacy fallback also supported:
export REDDIT_PROXY_URL="http://username:password@host:port"

The skill automatically fetches these credentials from the environment or a shell startup file when caption or metadata fetching requires proxy support.

Quick Start

Fetch captions and metadata:

python3 ./scripts/fetch_caption.py --url "https://www.youtube.com/watch?v=VIDEO_ID"

Fetch only metadata (uses proxy):

python3 ./scripts/fetch_caption.py --url "https://youtu.be/VIDEO_ID" --metadata-only

Fetch captions only (uses proxy):

python3 ./scripts/fetch_caption.py --url "https://www.youtube.com/watch?v=VIDEO_ID" --captions-only

Parameters

Parameter Required Default Description
--url or -u Yes - YouTube video URL (supports various formats)
--metadata-only No false Fetch only video metadata (uses proxy)
--captions-only No false Fetch only captions (uses proxy)
--language or -l No en Language code for captions (e.g., en, es, fr)
--output or -o No - Save output to JSON file

Output Format

Returns JSON with both captions and metadata:

{
  "success": true,
  "video_id": "dQw4w9WgXcQ",
  "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "metadata": {
    "title": "Video Title",
    "description": "Full video description...",
    "channel": "Channel Name",
    "channel_id": "UC...",
    "published_at": "2025-01-15T10:00:00Z",
    "duration": "10:30",
    "duration_seconds": 630,
    "view_count": 1000000,
    "thumbnail": "https://i.ytimg.com/vi/...",
    "links_in_description": [
      "https://example.com/link1",
      "https://example.com/link2"
    ]
  },
  "captions": {
    "text": "Full transcript text...",
    "language": "en",
    "is_generated": true,
    "word_count": 1500,
    "duration_seconds": 630
  }
}

How It Works

  1. Caption fetching: Uses youtube-transcript-api with residential proxy (to avoid IP blocks)
  2. Metadata fetching: Uses urllib with residential proxy (to bypass YouTube bot detection)
  3. Proxy credentials: Automatically loaded from the environment or a shell startup file (YOUTUBE_PROXY_URL, or legacy REDDIT_PROXY_URL)

Error Handling

Error Cause Solution
TranscriptsDisabled Video has captions disabled Try another video
NoTranscriptFound No captions in requested language Try --language with different code
VideoUnavailable Video is private/deleted Check video URL
ProxyError Proxy connection failed Check proxy credentials in your environment or shell startup file

Usage Examples

Get full video data:

python3 ./scripts/fetch_caption.py --url "https://www.youtube.com/watch?v=VIDEO_ID" -o output.json

Get captions in Spanish:

python3 ./scripts/fetch_caption.py --url "https://youtu.be/VIDEO_ID" --language es

Extract just the transcript text:

python3 ./scripts/fetch_caption.py --url "URL" --captions-only | jq -r '.captions.text'

Get metadata with links from description:

python3 ./scripts/fetch_caption.py --url "URL" --metadata-only | jq '.metadata.links_in_description'

Notes

  • Proxy is used for both caption AND metadata fetching to bypass YouTube bot detection
  • Supports auto-generated and manual captions
  • Falls back gracefully if captions are unavailable
  • Metadata includes links_in_description array extracted from the video description
檢視許可證全文(MIT)
MIT License

Copyright (c) 2026 Valtteri Melkko

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.