What is yt-dlp-ejs?
yt-dlp-ejs is a Python package that provides external JavaScript support for yt-dlp. It solves YouTube player challenges (n-parameter and signature decryption) by bundling JavaScript solvers that work across multiple runtimes.Use Case: This library is primarily used by yt-dlp to decrypt YouTube video URLs by solving JavaScript challenges embedded in YouTube’s player code.
Quick Example
Here’s a complete example showing how to use yt-dlp-ejs to access the JavaScript solver bundles:Access the solver bundles
The library provides two main functions to access JavaScript solver code:Both functions return the minified JavaScript code as a string.
How It Works
The JavaScript solver processes YouTube player code to extract decryption functions:Input Processing
The solver accepts input with:
- Player code (raw YouTube player JavaScript) or preprocessed player
- Request type (
nfor throttling parameter,sigfor signature) - Challenges (encrypted strings to decrypt)
Solver Execution
The solver:
- Preprocesses the player code (if needed)
- Extracts the relevant decryption functions
- Applies them to each challenge
- Returns the decrypted results
Complete Working Example
Here’s a practical example that demonstrates accessing the solver bundles:Integration with yt-dlp
While yt-dlp-ejs can be used standalone, it’s designed to work seamlessly with yt-dlp:yt-dlp automatically detects and uses yt-dlp-ejs when it’s installed in the same environment. No additional configuration is needed.
- Calls
yt_dlp_ejs.yt.solver.core()oryt_dlp_ejs.yt.solver.lib()to get the solver JavaScript - Executes the solver in a JavaScript runtime (Deno, Bun, or Node.js)
- Passes the YouTube player code and challenges to the solver
- Receives decrypted parameters back from the solver
- Uses the decrypted parameters to construct working video URLs
Supported Runtimes
The JavaScript solvers support multiple runtimes:Deno
Modern TypeScript runtime with built-in security
Bun
Fast all-in-one JavaScript runtime and toolkit
Node.js
Traditional JavaScript runtime (requires version 22.6+)
Next Steps
API Reference
Explore the complete API documentation
Architecture
Learn how the solver works internally
