惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
博客园 - Franky
MyScale Blog
MyScale Blog
L
LangChain Blog
Martin Fowler
Martin Fowler
Recent Announcements
Recent Announcements
Stack Overflow Blog
Stack Overflow Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 司徒正美
量子位
A
About on SuperTechFans
C
Check Point Blog
大猫的无限游戏
大猫的无限游戏
Last Week in AI
Last Week in AI
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
I
InfoQ
V
Visual Studio Blog
Vercel News
Vercel News
B
Blog
爱范儿
爱范儿
aimingoo的专栏
aimingoo的专栏
U
Unit 42

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
🛠️ yt_playlist_transcript: Download and combine transcrip...
Golden Alien · 2026-04-26 · via DEV Community

Golden Alien

YouTube Playlist Transcript Tool

This tool extracts transcripts from all videos in a public YouTube playlist and combines them into a single text file. It's ideal for researchers, educators, content creators, or students who want to analyze or archive spoken content across multiple videos.

Features

  • Automatically fetches video URLs from a given playlist
  • Retrieves auto-generated or manually created transcripts (where available)
  • Saves each video's transcript with title and timestamp header
  • Combines all transcripts into one clean, readable .txt file
  • Supports playlists with up to hundreds of videos
  • Handles errors gracefully (e.g., unavailable videos, no transcript)

Requirements

  • Python 3.7+
  • youtube_transcript_api
  • pytube

Install dependencies:

pip install youtube-transcript-api pytube

Enter fullscreen mode Exit fullscreen mode

Usage

Run the script from the command line:

python main.py --playlist_url "https://www.youtube.com/playlist?list=..." --output transcripts.txt

Enter fullscreen mode Exit fullscreen mode

You can also specify the output path and whether to include video titles and timestamps.

Output Format

Each transcript entry includes:

  • Video title
  • Video URL
  • Transcript text with timestamps (optional)
  • Separator line between videos

The resulting file can be used for summarization, search, or offline reading.

Limitations

  • Only works with videos that have transcripts enabled (either auto-generated or manual)
  • Private or unavailable videos are skipped
  • Extremely long playlists may trigger rate limits (though no API key is required)

Example Use Cases

  • Academic research on video lecture series
  • Creating searchable documentation from tutorial playlists
  • Building datasets for NLP projects

License

MIT

import argparse
import sys
from youtube_transcript_api import YouTubeTranscriptApi
from pytube import Playlist


def get_transcript(video_id):
    try:
        transcript = YouTubeTranscriptApi.get_transcript(video_id)
        return '\n'.join([f"[{entry['start']:.0f}s] {entry['text']}" for entry in transcript])
    except Exception as e:
        return f"[Transcript not available: {str(e)}]"

def main(playlist_url, output_file):
    playlist = Playlist(playlist_url)
    with open(output_file, 'w', encoding='utf-8') as f:
        for video in playlist.videos:
            try:
                title = video.title
                video_id = video.video_id
                f.write(f"# Title: {title}\n")
                f.write(f"# URL: https://youtube.com/watch?v={video_id}\n\n")
                transcript = get_transcript(video_id)
                f.write(f"{transcript}\n\n")
                f.write("-" * 80 + "\n\n")
                print(f"Downloaded: {title}")
            except Exception as e:
                print(f"Failed to process video: {str(e)}")
    print(f"\nTranscripts saved to {output_file}")

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Fetch transcripts from a YouTube playlist.')
    parser.add_argument('--playlist_url', type=str, required=True, help='URL of the YouTube playlist')
    parser.add_argument('--output', type=str, default='transcripts.txt', help='Output file path')
    args = parser.parse_args()

    main(args.playlist_url, args.output)

Enter fullscreen mode Exit fullscreen mode