How it works
OwnTube has two server processes: the web app and the gateway. Both are built from the same repository and run as two containers.
browser · TV · iPhone │ ▼ reverse proxy (optional) ├── /media/* ──▶ gateway :8080 ──▶ YouTube └── the rest ──▶ web app :3000 │ └── SQLite: accounts, history, subscriptions, settingsThe web app
Section titled “The web app”A Next.js application. It holds the accounts, subscriptions, watch history, playlists, the queue, the recommender and all settings, in one SQLite file. It renders the pages, serves the API the TV and iPhone apps use, and runs background jobs: refreshing subscriptions and trending, and publishing podcast feeds if you set them up.
For every video it decides what to play and hands the player a playback URL signed for the gateway.
The gateway
Section titled “The gateway”A separate Node.js process that does everything that touches YouTube:
- video, channel and playlist metadata, search, trending and comments
- stream manifests, as DASH for browsers and Android TV and as HLS for Apple devices
- media segments, captions and thumbnails
- a disk cache for metadata and images
It runs apart from the web app for two reasons. A web app restart or update doesn’t cut streams that are playing, and the memory the gateway needs for YouTube sessions and streaming stays out of the web app.
The gateway only serves URLs signed with GATEWAY_SIGNING_KEY, a secret it shares with the web app. Nobody can use it as an open proxy to YouTube.
Transport
Section titled “Transport”By default the gateway uses YouTube’s regular stream URLs. When YouTube refuses them, it switches to SABR, the streaming protocol YouTube’s own apps use. If YouTube asks for proof that requests come from a real client, a gateway built with the optional PO-token browser can provide it. See Configuration.
The clients
Section titled “The clients”| Client | How it connects |
|---|---|
| Web | Pages and API from the web app; media from the gateway. |
| Apple TV, Android TV, Fire TV | A native app that uses the web app’s API and plays the gateway’s streams in the platform’s own player. Signs in with a pairing code. |
| iPhone and iPad | Native tabs and player around the web app’s pages. Plays the gateway’s HLS in AVPlayer, so playback continues in the background. |
What leaves your server
Section titled “What leaves your server”Only the gateway’s requests to YouTube: metadata, streams, captions and images. Clients never talk to Google directly; thumbnails and avatars are served through the gateway too. OwnTube has no telemetry.