01a376ae21
- Updated AGENTS.md to clarify dlp.py module usage and segment handling. - Modified README.md to include ALLOW_LOCAL configuration for testing. - Refactored app.py to streamline HLS proxy logic and improve error handling. - Enhanced dlp.py to optimize caching and segment retrieval processes. - Updated player.html to ensure proper JSON formatting for proxy URLs. - Improved test_integration.py to validate HLS segment proxying and added test for Pornhub HLS extraction. - Adjusted test_proxy.py to reflect changes in caching functions and data structure.
1.3 KiB
1.3 KiB
yt-dlp HLS Proxy
A simple Flask proxy server that uses yt-dlp to fetch HLS streams and serves them through a web player.
Features
- HLS stream proxying via yt-dlp
- In-memory caching (365 days TTL by default)
- URL validation with allowed domains
- HTML5 video player with hls.js
- Configurable via environment variables
Quick Start
pip install -r requirements.txt
cp .env.example .env
python app.py
Visit http://localhost:5000 and enter a video URL.
Configuration
| Variable | Default | Description |
|---|---|---|
| PORT | 5000 | Server port |
| LOG_LEVEL | INFO | Logging level |
| CACHE_TTL | 31536000 | Cache TTL in seconds (365 days) |
| SOCKET_TIMEOUT | 30 | Socket timeout for requests |
| VALIDATION_ENABLED | true | Enable URL validation |
| ALLOWED_DOMAINS | youtube.com,youtu.be,pornhub.com,xvideos.com | Allowed video domains |
| ALLOW_LOCAL | true | Allow localhost/127.0.0.1 URLs (for testing) |
Routes
/- Home page with video URL input/player?url=VIDEO_URL- Video player page/hls/<query>/index.m3u8- HLS playlist proxy/hls/<query>/<segment>.ts- HLS segment proxy
Running with Gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:app
Testing
pytest tests/test_proxy.py -v
License
MIT