Extractor Basics
Extractors are classes that inherit fromInfoExtractor and implement the _real_extract method to extract video information from URLs.
Minimal Extractor Example
Required Fields
Every extractor must define:Class Attributes
string
required
Internal name for the extractor (auto-generated from class name if not provided)
regex
required
Regular expression matching the URLs this extractor can handle
Return Dictionary
The_real_extract method must return a dictionary with at least:
string
required
Unique video identifier
string
required
Video title (use empty string if unavailable, not None)
string
Direct video URL (required if
formats not provided)array
List of format dictionaries (required if
url not provided)InfoExtractor Base Class
Fromyt_dlp/extractor/common.py:107-116:
Common Metadata Fields
Basic Information
Format Dictionaries
When providing multiple formats:Additional Metadata
Helpful InfoExtractor Methods
Downloading Content
Extracting Data
URL Handling
Advanced Features
Handling Multiple Videos (Playlists)
Extracting HLS/DASH Formats
Authentication
Geo-restriction Handling
Testing Your Extractor
Adding Test Cases
Running Tests
Registering Your Extractor
As a Plugin
Create a plugin package (recommended):Contributing to yt-dlp
To contribute your extractor to the main repository:- Add your extractor to
yt_dlp/extractor/ - Import it in
yt_dlp/extractor/_extractors.py - Follow the contributing guidelines
Best Practices
Use Helper Methods
Leverage InfoExtractor’s built-in methods instead of reimplementing common functionality.
Handle Errors Gracefully
Use
default parameters and try-except blocks to handle missing data.Provide Multiple Formats
When possible, extract all available quality options and let yt-dlp’s format selection handle the rest.
Add Comprehensive Tests
Include test cases for different video types, edge cases, and error conditions.