YouTube IPTV proxy.
MIT
ytproxy turns YouTube channels into IPTV playlists and exposes individual
videos as playable HTTP streams.
/channel/<channel>.m3ureturns an M3U playlist for IPTV players./channel/<channel>.xmlreturns an Atom/RSS-style feed for Jellyfin/Emby./watch?v=<video_id>returns a playable media stream.
Streaming is done by yt-dlp for URL
resolution and by ffmpeg for remuxing when the video and audio are served
as separate streams. HLS variants are preferred, because YouTube frequently
rejects direct googlevideo.com HTTPS URLs with 403 Forbidden; the HLS
manifests and segments remain usable.
HTTP Range requests are forwarded when possible, so players can seek.
- Streams YouTube videos directly or via
ffmpeg - H.264/AAC preference for maximum direct-play compatibility
- HTTP
Rangesupport for seeking (direct streams) - Works with mpv, VLC, Kodi, Jellyfin, Emby and browsers
- Quality selection (1080p, 720p, 480p, ...)
- MPEG-TS by default, fragmented MP4 with
container=mp4 - M3U playlists and Atom/XML feeds for Jellyfin/Emby
- Channel/video caching and optional background refresh
- Python 3 (3.12+ recommended; the code uses modern f-string syntax)
python-flaskrequestsyt-dlpffmpeg
$ makepkg -siTo run it at boot:
$ sudo systemctl enable --now ytproxy.service$ pip install flask requests yt-dlp
$ python3 ytproxy.pyffmpeg must be available in PATH.
$ python3 ytproxy.pyWith environment overrides:
$ YTPROXY_HOST=0.0.0.0 YTPROXY_PORT=8090 python3 ytproxy.pyhttp://localhost:8080/channel/<channel>.m3u?count=<count>
Example:
http://localhost:8080/channel/TechnologyConnections.m3u?count=10&quality=1080
http://localhost:8080/channel/<channel>.xml?count=<count>
Examples:
http://localhost:8080/channel/Computerphile.xml?count=20
http://localhost:8080/channel/Computerphile.xml?count=20&shorts=1
http://localhost:8080/watch?v=<video_id>
http://localhost:8080/watch?v=<video_id>&quality=<quality>
http://localhost:8080/watch?v=<video_id>&container=mp4
Examples:
http://localhost:8080/watch?v=dQw4w9WgXcQ
http://localhost:8080/watch?v=dQw4w9WgXcQ&quality=720
http://localhost:8080/watch?v=dQw4w9WgXcQ&quality=1080&container=mp4
| Option | Description | Default |
|---|---|---|
count |
Number of recent videos to include | 5 |
shorts |
1 includes YouTube Shorts (XML feed) |
off |
quality |
Passed to the generated stream URLs | off |
container |
mp4 for MP4 URLs in the XML feed |
mp4 |
| Option | Description |
|---|---|
quality |
Maximum video height in pixels (e.g. 1080, 720, 480, 360). The best available format at or below this height is used. |
container |
mp4 serves fragmented MP4 (video/mp4), usable in browsers and Emby/Jellyfin. Omit for MPEG-TS (video/mp2t). |
| Variable | Description | Default |
|---|---|---|
YTPROXY_HOST |
Address to bind | 0.0.0.0 |
YTPROXY_PORT |
Port to listen on | 8080 |
YTPROXY_BG_REFRESH |
yes enables the background channel refresh worker |
no |
YTPROXY_LOG_DIR |
Log directory | /var/log/ytproxy |
YTPROXY_LOG_LEVEL |
Log level (DEBUG, INFO, ...) |
INFO |
YTPROXY_PREWARM |
Resolve feed videos in the background so the first playback is fast | yes |
Persistent data is stored under /var/lib/ytproxy (yt-dlp cache, channel ID
cache, channel video cache, known channels, resolved stream URLs). The service
user must be able to write there.
- mpv / VLC / Kodi: use the
/watchURL directly, or import the M3U playlist. - Browsers: add
container=mp4. - Jellyfin / Emby: import the
.xmlfeed. It uses the same MPEG-TS default as/watch; add&container=mp4to the feed URL if your setup prefers MP4. - IPTV clients: import the
.m3uplaylist. MPEG-TS is used by default.
Check the log first:
$ journalctl -u ytproxy -f
# or
$ tail -f /var/log/ytproxy/ytproxy.logCommon issues:
-
HTTP 403 from YouTube — yt-dlp is out of date, or YouTube changed a player client. Update
yt-dlpfirst. -
ffmpeg failed: Unrecognized option ...— the installedffmpegdoes not support an option used by a newer build. Check the logged command. -
Permission denied under
/var/lib/ytproxy— make the directory writable by the user running the service. -
Playlist is empty — YouTube's RSS channel feed is currently unreliable; the proxy falls back to
yt-dlp. Check the log for the fallback result. -
Seeking does not work with
container=mp4— the MP4/TS stream is produced live byffmpeg, so it is not seekable. Direct (progressive) streams forwardRangerequests. -
Emby/Jellyfin says "No compatible stream" the first time — their playback request gives up after roughly six seconds while a cold start (yt-dlp ~3 s + ffmpeg ~2–3 s) is still running. The proxy now:
- pre-resolves the videos of every channel feed it serves
(
YTPROXY_PREWARM=yes, the default) in a background worker, so playback only waits for ffmpeg; - retries once with freshly resolved URLs;
- waits for a full 64 KiB chunk before sending the response, because a tiny
first chunk (for example only the MPEG-TS PAT/PMT packets) makes
ffprobereport no streams.
To diagnose, look for these INFO lines in the log:
Watch request: v=... quality=... container=... ua=... range=... Resolved stream for ... (quality=..., mode=..., height=...) in Xs Stream ... q=...: first output after Xs (65536 bytes, first=...) Stream ... q=... ended after Xs: client disconnected|ffmpeg eof, sent N bytes, ffmpeg rc=RIf the probe disconnects before
first output, the cold start is too slow for the media server (pre-resolve the URL or raise its probe timeout). Ifffmpeg eofappears with anstderr:detail, the upstream stream failed. - pre-resolves the videos of every channel feed it serves
(
Enable verbose logging:
$ YTPROXY_LOG_LEVEL=DEBUG python3 ytproxy.py