Extensions/ComfyUI-yt_dl
ComfyUI Extension

ComfyUI-yt_dl

Download Youtube videos using ComfyUI

By if-ai·Created about a year ago·Updated 11 days ago· 2
if-ai/ComfyUI-yt_dl
Nodes1
On cloudLocal install
CategoryYouTube
Stars2
Updated11 days ago
Readme

ComfyUI-yt_dl

Download YouTube videos using ComfyUI with enhanced error handling and anti-blocking measures.

Features

  • Download YouTube videos, audio, and subtitles
  • Support for multiple quality options (highest, 144p, 360p, 720p)
  • Enhanced anti-blocking measures to handle HTTP 403 errors
  • Automatic retry mechanism with fallback strategies
  • Optional cookies support for authenticated requests
  • Support for Twitter/X videos
  • Automatically download .srt subtitles alongside video downloads (original language + English by default)
  • Web API endpoint for external integration

Installation

  1. Clone this repository into your ComfyUI/custom_nodes/ directory:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/yourusername/ComfyUI-yt_dl.git
    
  2. Install the required dependencies:

    pip install -r requirements.txt
    
  3. Restart ComfyUI

Usage

In ComfyUI Interface

  1. Look for "YouTube Download" node in the node browser
  2. Add the node to your workflow
  3. Configure:
    • URL: The YouTube video URL
    • Mode: video, audio, or subtitles
    • Quality: highest, 144p, 360p, or 720p (video mode only)
    • Subtitle Languages (optional): comma-separated list (e.g. original,en). Leave blank to use the default original,en.
  4. Connect the output to other nodes or use the PreviewAny node

Using the Menu Button

The extension adds a "YouTube DL" button to ComfyUI's top menu. Click it to:

  1. Enter a YouTube URL
  2. Select mode (video/audio/subtitles)
  3. Select quality (for video mode)
  4. Optionally set subtitle languages if you want something other than the defaults
  5. Automatically create a download node with your settings

Subtitle Languages

The downloader requests subtitles when grabbing a video. By default it downloads the original language alongside English (original,en). You can customize this by setting the Subtitle Languages input to a comma-separated list (for example pt,en, ja, or all).

⚠️ Requesting all languages can trigger YouTube rate-limiting and may slow down downloads. Prefer a small list of languages you actually need.

Troubleshooting HTTP 403 Errors

YouTube sometimes blocks download requests. This extension includes several measures to handle this:

Automatic Fixes (Applied Automatically)

  • Retry mechanisms with fallback strategies
  • Fallback to alternative player clients (android, web) on HTTP 403
  • Automatic retry when YouTube's SABR-only experiment limits a session to 360p
  • Rate limiting to avoid detection
  • Safe logging that survives a detached/closed stdout (no more BrokenPipeError)

Manual Solutions

Option 1: Use Browser Cookies

If automatic fixes don't work, try using browser cookies:

# Run the cookies extractor script
python get_cookies.py

This will attempt to extract cookies from your browser. If successful, it will save them to output/yt_dl/cookies.txt and the downloader will use them automatically.

Option 2: Manual Cookie Export

  1. Install a browser extension:
    • Chrome: "Get cookies.txt LOCALLY"
    • Firefox: "Export Cookies"
  2. Export cookies from youtube.com
  3. Save the file as output/yt_dl/cookies.txt in your ComfyUI directory

Option 3: Update yt-dlp

Make sure you have the latest version:

pip install --upgrade yt-dlp

API Endpoint

The extension provides a web API endpoint:

POST /yt_dl/api/ytdl

Request Body:

{
    "url": "https://www.youtube.com/watch?v=VIDEO_ID",
    "mode": "video",
    "quality": "highest"
}

Response:

{
    "file_path": "/path/to/downloaded/file.mp4"
}

Supported Sites

  • YouTube (primary support)
  • Twitter/X (basic support)
  • Generic sites (fallback)

Error Handling

The extension includes comprehensive error handling:

  • Automatic retry on HTTP 403 errors
  • Fallback strategies for different player clients
  • Detailed error messages in ComfyUI console
  • Graceful degradation when features aren't available

Requirements

  • yt-dlp >= 2024.8.6
  • ComfyUI

License

MIT License