zarazhangrui/youtube-to-ebookGit

YouTube 视频转电子书

自动将精选视频内容生成可离线阅读的 EPUB。

使用前,准备这些

输入素材:原始素材、受众与输出格式

  1. 在下方原始文档中确认支持的 AI 工具、模型和运行依赖。
  2. 打开原仓库,按作者的安装说明完成配置;模型 API 或外部服务可能需要单独开通。
  3. 用自己的素材试运行,再检查事实、版式与输出文件。
查看原仓库安装说明 ↗

许可证:未明确声明,请查看原仓库的使用条件。

来源快照:2026-09-15。README ↗

可以这样开始

使用这个 Skill 完成「YouTube 视频转电子书」:自动将精选视频内容生成可离线阅读的 EPUB。 请先确认必要输入,再交付一份可直接使用的结果。

YouTube to Ebook

Transform YouTube videos from your favorite channels into beautifully formatted EPUB ebooks.

Features

  • Fetches latest videos from YouTube channels (automatically filters out Shorts)
  • Extracts transcripts from videos
  • Uses Claude AI to transform transcripts into polished magazine-style articles
  • Generates EPUB ebooks readable on any device
  • Optional: Email delivery with ebook attachment
  • Optional: Web dashboard for easy management

Quick Start

  1. Clone and install:

    git clone https://github.com/YOUR_USERNAME/youtube-to-ebook.git
    cd youtube-to-ebook
    pip install -r requirements.txt
    
  2. Set up API keys:

    cp .env.example .env
    # Edit .env with your keys
    
  3. Add your channels:

    # Edit channels.txt with YouTube channel handles
    @mkbhd
    @veritasium
    @3blue1brown
    
  4. Generate your ebook:

    python main.py
    

Getting API Keys

YouTube Data API (Free)

  1. Go to Google Cloud Console
  2. Create a new project
  3. Enable "YouTube Data API v3"
  4. Create credentials → API Key
  5. Copy to .env

Anthropic API

  1. Go to Anthropic Console
  2. Create an API key
  3. Copy to .env

Web Dashboard

Launch a friendly web interface:

pip install streamlit
python -m streamlit run dashboard.py

Automation (Mac)

Run automatically every week:

# Copy the plist to LaunchAgents
cp com.youtube.newsletter.plist ~/Library/LaunchAgents/

# Load it
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.youtube.newsletter.plist

Troubleshooting

"ModuleNotFoundError" when running automation

Your Mac may have multiple Python installations. The automation scripts use python3, but your packages might be installed in a different Python.

Fix: Find your Python path and update the scripts:

# Find where your Python is
which python3

# Update run_newsletter.sh and dashboard.py with the full path
# Example: /Library/Frameworks/Python.framework/Versions/3.11/bin/python3

Known Issues & Solutions

This project documents several YouTube API quirks:

ProblemSolution
Shorts not filtered by durationCheck /shorts/ URL pattern
Search API not chronologicalUse uploads playlist instead
Transcript API syntax changedUse instance method ytt_api.fetch()
Cloud servers blockedRun locally, not GitHub Actions
Names misspelled in transcriptsInclude video description in Claude context
Articles truncated mid-sentenceIncrease max_tokens in write_articles.py

See SKILL.md for detailed explanations.

Project Structure

├── main.py              # Run the full pipeline
├── get_videos.py        # Fetch videos from YouTube
├── get_transcripts.py   # Extract video transcripts
├── write_articles.py    # Transform to articles with Claude
├── send_email.py        # Create EPUB & send email
├── dashboard.py         # Streamlit web dashboard
├── video_tracker.py     # Track processed videos
├── channels.txt         # Your channel list
├── .env                 # Your API keys (not committed)
└── newsletters/         # Archive of generated ebooks

License

MIT - Use freely, modify as needed.


Built with Claude AI