A high-performance YouTube signature decryption service built with Deno, designed for seamless integration with Lavalink and other music bots.
- High Performance: Built with Deno for optimal speed and memory usage
- Lavalink Compatible: Dedicated endpoints for Lavalink YouTube source integration
- Real-time Monitoring: Live stats and performance metrics
- Advanced Caching: Multi-layer caching with TTL and LRU eviction
- Worker Pool: Parallel processing with configurable concurrency
- Comprehensive Metrics: Prometheus metrics for monitoring and observability
- Rate Limiting: Configurable rate limiting to prevent abuse
- CORS Support: Full CORS support for web-based clients
- Docker Ready: Production-ready Docker configuration
- Health Monitoring: Built-in health checks and status endpoints
- Deno 2.5.4 or later
-
Clone the repository
git clone https://github.com/ryanwtf88/yt-cipher.git cd yt-cipher -
Set environment variables (optional)
export API_TOKEN="your_custom_api_token" # Change from default YOUR_API_TOKEN export SERVER_PORT=3000 # Optional: default port
-
Run the server
deno run --allow-net --allow-read --allow-write --allow-env --allow-sys server.ts
-
Verify installation
curl http://localhost:3000/health
| Variable | Default | Description |
|---|---|---|
SERVER_PORT |
3000 |
Server port |
SERVER_HOST |
0.0.0.0 |
Server host |
API_TOKEN |
YOUR_API_TOKEN |
API authentication token (change this!) |
MAX_THREADS |
16 |
Worker pool concurrency |
WORKER_TASK_TIMEOUT |
60000 |
Worker task timeout (ms) |
WORKER_MAX_RETRIES |
5 |
Maximum worker retries |
RATE_LIMIT_WINDOW_MS |
60000 |
Rate limit window (1 min) |
RATE_LIMIT_MAX_REQUESTS |
999999999 |
Max requests per window |
LOG_LEVEL |
warn |
Logging level (debug, info, warn, error) |
LOG_FORMAT |
text |
Log format (text, json) |
| Variable | Default | Description |
|---|---|---|
PLAYER_CACHE_SIZE |
10000 |
Player cache max size |
PLAYER_CACHE_TTL |
7200000 |
Player cache TTL (2 hours) |
SOLVER_CACHE_SIZE |
5000 |
Solver cache max size |
SOLVER_CACHE_TTL |
7200000 |
Solver cache TTL (2 hours) |
PREPROCESSED_CACHE_SIZE |
15000 |
Preprocessed cache max size |
PREPROCESSED_CACHE_TTL |
14400000 |
Preprocessed cache TTL (4 hours) |
STS_CACHE_SIZE |
10000 |
STS cache max size |
STS_CACHE_TTL |
3600000 |
STS cache TTL (1 hour) |
- GET
/- Interactive API Documentation (Swagger UI) - GET
/health- Health check with real-time monitoring - GET
/status- Detailed system status with performance metrics - GET
/info- Server information and capabilities - GET
/metrics- Prometheus metrics with real-time data
Decrypt YouTube signature and n parameter.
Request:
{
"encrypted_signature": "encrypted_signature_string",
"n_param": "encrypted_n_param_string",
"player_url": "https://www.youtube.com/s/player/player_id/player.js"
}Response:
{
"decrypted_signature": "decrypted_signature_string",
"decrypted_n_sig": "decrypted_n_param_string",
"success": true,
"timestamp": "2024-01-01T00:00:00.000Z",
"processing_time_ms": 150
}Extract signature timestamp from player script.
Request:
{
"player_url": "https://www.youtube.com/s/player/player_id/player.js"
}Response:
{
"sts": "12345",
"success": true,
"timestamp": "2024-01-01T00:00:00.000Z",
"processing_time_ms": 100
}Resolve YouTube stream URL with decrypted parameters.
Request:
{
"stream_url": "https://example.com/video?c=WEB&cver=2.0&s=encrypted_signature&n=encrypted_n_param",
"player_url": "https://www.youtube.com/s/player/player_id/player.js",
"encrypted_signature": "encrypted_signature_string",
"signature_key": "sig",
"n_param": "encrypted_n_param_string"
}Response:
{
"resolved_url": "https://example.com/video?c=WEB&cver=2.0&sig=decrypted_signature&n=decrypted_n_param",
"success": true,
"timestamp": "2024-01-01T00:00:00.000Z",
"processing_time_ms": 200
}yt-cipher is fully compatible with Lavalink YouTube source integration using the standard API endpoints. It implements the RemoteCipherManager interface required by Lavalink's YouTube source plugin.
The service provides the following endpoints that Lavalink expects:
- POST /decrypt_signature - Decrypts YouTube signatures and N parameters
- POST /get_sts - Extracts signature timestamps from player scripts
- POST /resolve_url - Resolves YouTube stream URLs with decrypted parameters
All endpoints return responses in the format expected by Lavalink:
{
"decrypted_signature": "decrypted_value",
"decrypted_n_sig": "decrypted_n_value",
"sts": "timestamp_value",
"resolved_url": "https://resolved-url.com",
"success": true,
"timestamp": "2024-01-01T00:00:00.000Z",
"processing_time_ms": 150
}Set the API token for authentication:
export API_TOKEN="your_custom_api_token"YoutubeSourceOptions options = new YoutubeSourceOptions()
.setRemoteCipherUrl("http://localhost:3000", "your_custom_api_token");
YoutubeAudioSourceManager sourceManager = new YoutubeAudioSourceManager(options, ...);plugins:
youtube:
remoteCipher:
url: "http://localhost:3000"
password: "your_custom_api_token"
userAgent: "your_service_name"
timeout: 10000
retryOnFailure: trueAll API endpoints require API token authentication using the Authorization header:
Authorization: Bearer your_custom_api_token
Important: Change the default token YOUR_API_TOKEN to a secure custom token in production!
-
Clone and configure
git clone https://github.com/ryanisnomore/yt-cipher.git cd yt-cipher -
Set environment variables
export API_TOKEN="your_custom_api_token" # Change this!
-
Start the service
docker-compose up -d
-
Verify deployment
curl http://localhost:3000/health
-
Build the image
docker build -t yt-cipher . -
Run the container
docker run -d \ --name yt-cipher \ -p 3000:3000 \ -e API_TOKEN="your_custom_api_token" \ -v player_cache:/app/player_cache \ yt-cipher
- GET
/health- Basic health check with real-time data - GET
/status- Detailed system status including performance metrics
Access metrics at /metrics endpoint:
- HTTP Metrics: Request counts, response times, status codes
- Cache Metrics: Hit rates, miss rates, cache sizes
- Worker Metrics: Task counts, processing times, error rates
- System Metrics: Memory usage, uptime, active connections
- Real-time Metrics: Live performance data
The service provides real-time monitoring through:
- Live request statistics
- Active connection counts
- Average response times
- Error rates and performance metrics
- Interactive HTML dashboard at
/
- Deno 2.5.4+
-
Clone the repository
git clone https://github.com/ryanwtf88/yt-cipher.git cd yt-cipher -
Run in development mode
deno run --allow-net --allow-read --allow-write --allow-env --allow-sys server.ts
Run the test suite:
# Type checking
deno check server.ts
# Run with debug logging
LOG_LEVEL=debug deno run --allow-net --allow-read --allow-write --allow-env --allow-sys server.tsWe welcome contributions! Please see CONTRIBUTING.md for guidelines on how to get started, report issues, and submit pull requests.
If you discover a security vulnerability, please refer to our SECURITY.md for responsible disclosure guidelines and contact information.
By participating in this project, you agree to abide by our CODE_OF_CONDUCT.md. Let's foster a positive and inclusive environment together.
This project is licensed under the MIT License.
- Deno - The runtime that powers this service
- Lavalink - The music bot framework this integrates with
- yt-dlp - For YouTube extraction inspiration
- EJS - For signature decryption algorithms
- yt-cipher - The repository this is based off of and should be forked from ;)
- cursor - The author of basically all the code not from the above repo
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: API Docs (when running)
Made with ❤️ by RY4N