Skip to content

Fix YouTube "Unable to extract uploader id" Error in Discord.py

Problem Statement

When using youtube_dl with Discord.py to play YouTube audio in voice channels, you may suddenly encounter the error:
Error: Unable to extract uploader id

This occurs when:

  • Your Discord music bot previously worked but now fails with all YouTube videos
  • Updating youtube_dl doesn't resolve the issue
  • The error appears without additional diagnostic information
  • YouTube has changed its metadata structure, breaking legacy extraction methods

yt-dlp is an actively maintained fork of youtube_dl with better YouTube compatibility.

Step 1: Install yt-dlp

bash
pip uninstall youtube_dl  # Remove old package  
pip install --force-reinstall yt-dlp

Step 2: Update Your Python Code

Replace the youtube_dl import and initialization:

python
# Replace:  
# import youtube_dl  
# ytdl = youtube_dl.YoutubeDL(ytdl_format_options)  

# With:  
import yt_dlp as youtube_dl  
ytdl = youtube_dl.YoutubeDL(ytdl_format_options)

Step 3: Add Error-Resilient Options

Modify your ytdl_format_options to include:

python
ytdl_format_options = {  
    # ... (your existing options) ...  
    'ignoreerrors': True,  # Skip problematic videos  
    'extractor_args': {'youtube': {'skip': ['dash']}},  
    'extractor_retries': 10,  # Auto-retry on failures  
}

Why This Works

  • yt-dlp addresses YouTube's anti-scraping changes more quickly
  • Retry logic handles transient network/metadata issues
  • Error suppression prevents bot crashes during parsing errors

Alternative Solutions

Temporary Fixes

These may break with future YouTube updates:

Patch youtube_dl Extractor (Linux/macOS)

  1. Locate youtube.py in package path:
    bash
    find / -name youtube.py 2>/dev/null | grep youtube_dl/extractor
  2. Modify line ~1794 (add fatal=False):
    python
    # Original  
    'uploader_id': self._search_regex(... 'uploader id')   
    
    # Modified  
    'uploader_id': self._search_regex(... 'uploader id', fatal=False)

Reinstall from Latest Source

bash
pip install --upgrade --force-reinstall \  
    "git+https://github.com/ytdl-org/youtube-dl.git"

Homebrew Fix (macOS)

bash
brew uninstall youtube-dl  
brew install --HEAD youtube-dl

Key Maintenance Tips

  1. Update monthly: Video platforms frequently change their APIs
  2. Monitor logs: Enable logging to detect new issues early
python
ytdl_format_options = {  
    ...  
    'quiet': False,  # Disable quiet mode for logs  
    'logger': MyLogger(),  # Custom logger  
}
  1. Implement fallbacks: Use dash and manifest extractor args for resiliency

Long-Term Recommendation

Migrate fully to yt-dlp for ongoing support:

bash
pip uninstall youtube_dl  
pip install yt-dlp[default]

Use yt_dlp directly instead of aliasing as youtube_dl for full feature access.