56 lines
1.2 KiB
Markdown
56 lines
1.2 KiB
Markdown
|
|
# 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
|
||
|
|
|
||
|
|
```bash
|
||
|
|
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 |
|
||
|
|
|
||
|
|
## 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
|
||
|
|
|
||
|
|
```bash
|
||
|
|
gunicorn -w 4 -b 0.0.0.0:5000 app:app
|
||
|
|
```
|
||
|
|
|
||
|
|
## Testing
|
||
|
|
|
||
|
|
```bash
|
||
|
|
pytest tests/test_proxy.py -v
|
||
|
|
```
|
||
|
|
|
||
|
|
## License
|
||
|
|
|
||
|
|
MIT
|