OwnTube

Podcast feeds, hooks and tokens

OwnTube can publish your lists as podcast feeds, receive new uploads by push, run scripts on watch events and give other services limited access through API tokens. All of this is optional.

Podcast feeds

Playlists, the queue, saved videos, subscriptions, every subscribed channel and every channel tag can be published as podcast RSS, in an audio (.m4a) and a video (.mp4) version, with chapters. Each user gets a secret feed address; Copy RSS URL appears on those pages and in their menus.

Why a separate feeds server

Podcast apps and directories fetch feeds from the internet, while OwnTube usually runs at home. The feeds server in feeds/server is a small public service that receives finished feed snapshots from OwnTube and serves them as RSS. It contains no OwnTube logic and no media: the enclosure URLs in each feed point back to your OwnTube server's /media/ path, so episodes play wherever the podcast app can reach your server (at home, or over a VPN).

Set it up

  1. Run the feeds server on a public host behind HTTPS. From feeds/server:
    echo "PUBLISH_SECRET=$(openssl rand -base64 48)" > .env
    docker compose up -d --build
    Adjust the Caddy labels and network in its docker-compose.yml to your proxy.
  2. Give the OwnTube web app the address and the same secret:
    OWNTUBE_PUBLISH_TARGET=https://feeds.example.org
    OWNTUBE_PUBLISH_SECRET=<same value as PUBLISH_SECRET>
    OWNTUBE_APP_URL=https://tube.example.org
  3. Restart the app. It publishes shortly after anything in a feed changes, and at least every OWNTUBE_PUBLISH_INTERVAL_SEC.

Lock down publishing further with PUBLISH_ALLOW_HOSTS or PUBLISH_ALLOW_IPS on the feeds server; /publish then requires both the secret and a matching source address.

WebSub push for new uploads

YouTube announces uploads through Google's WebSub hub, which can only deliver to a public address. Set WEBSUB_CALLBACK_URL=https://feeds.example.org/websub/callback on the feeds server and it subscribes to your channels and queues the notifications. OwnTube collects them about once a minute, so new videos appear in Subscriptions within a minute or two. Set OWNTUBE_WEBSUB=false on the app to turn this off.

A second, optional hub in feeds/hub announces changed feeds to podcast apps that support WebSub, so they refresh right away instead of on their own schedule. See feeds/hub/README.md.

Hooks

Every write to watch history (starting, progressing and finishing a video) can run executables in a directory you choose. Use it to sync progress to another app, scrobble, or log.

services:
  app:
    environment:
      OWNTUBE_HOOKS_DIR: /app/apps/web/data/hooks
    volumes:
      - ./hooks:/app/apps/web/data/hooks:ro

Each executable runs once per event, in name order, with the event as environment variables and as JSON on stdin:

VariableValue
OT_EVENTwatched or progress
OT_VIDEO_ID, OT_CHANNEL_IDYouTube IDs
OT_POSITION_SECONDS, OT_DURATION_SECONDSPosition and length; duration 0 means unknown
OT_COMPLETEDtrue or false
OT_VIDEO_TITLE, OT_CHANNEL_NAMEMay be empty
OT_SOURCElive, or replay for the periodic re-delivery of the last 48 hours
OT_ATUnix time

Events can be delivered more than once, so hooks must be idempotent. A hook that fails or exceeds OWNTUBE_HOOK_TIMEOUT_MS (30 s) is logged and never holds up playback or other hooks. Shorts are not reported.

Webhooks

To receive the same events over HTTP, for example in n8n or Home Assistant, list one or more URLs:

OWNTUBE_WEBHOOK_URLS=https://n8n.example.org/webhook/owntube
OWNTUBE_WEBHOOK_TOKEN=<sent as X-Webhook-Token>

Each event is POSTed as JSON.

API tokens

Under Settings → Feeds & tokens each user can create tokens starting with ot_ for services that act on their behalf. A token only reaches the API calls of the scopes it was given and can be revoked at any time. Send it as Authorization: Bearer ot_….

ScopeAllows
playbackRecording watch progress, and removing finished videos from the queue, saved or a playlist. Used to keep a podcast app and OwnTube in sync.