Skip to content

YouTube

YouTube channels are a source type of their own, youtube (SI-526). Code: packages/core/src/feeds/youtube.ts and services/youtube-takeout.ts.

Following channels

  • One channel: paste its address under Sources → Add: a channel URL, an @handle, a video or a playlist. Feed discovery turns it into the channel’s feed (sources.md).
  • All your subscriptions: on Google Takeout, choose only “YouTube and YouTube Music”. In the download, upload YouTube and YouTube Music/subscriptions/subscriptions.csv under Settings → Import and export, the same place as OPML. Channels you already follow are skipped, and the new ones are fetched right away.

Takeout writes the header row in the account’s language (“Channel Id” or “Kanal-ID”), so Hotaru reads the columns by position: channel ID, channel URL, title. Rows without a channel ID are listed as invalid. A file counts as CSV when it isn’t XML and its first line has a comma. Everything else is read as OPML.

Syncing subscriptions through the YouTube Data API (OAuth) isn’t built yet.

Polling: the free feed

Each channel has a feed, https://www.youtube.com/feeds/videos.xml?channel_id=UC…, with its 15 newest videos. Hotaru polls it like any other feed (scheduler.md). It costs no API quota.

The feed gives the title, the link, the description and a 480×360 thumbnail. It links Shorts as youtube.com/shorts/<id>, so Shorts are recognized without any lookup. It leaves out the duration, whether a video is a live stream, and the large thumbnail.

Video details

For new videos only, Hotaru looks up what the feed leaves out. A refetch looks up nothing.

With YOUTUBE_API_KEY Without
Where from YouTube Data API, videos.list The video’s watch page
Which videos Every new video New videos from the last 3 days, at most 5 per fetch of a channel
Cost 1 quota unit per 50 videos (the free quota is 10,000 a day) About 1.5 MB per page
Duration Yes Yes
Live streams (running, upcoming, past) Yes Yes
Large thumbnail maxres, else the largest there is maxresdefault (the page’s og:image)

A first import of a few hundred channels with a key costs a few hundred units. Without a key, older videos keep the feed’s thumbnail and show “Video” instead of a duration.

Without a key, YouTube may answer a server with a consent or “confirm you’re not a bot” page instead of the watch page. Hotaru sends the consent cookie (SOCS) and checks that the page belongs to the video. When it doesn’t, the video arrives without details. Set a key on a server: in the Google Cloud console, create a project, turn on the YouTube Data API v3, and create an API key restricted to that API. Then set YOUTUBE_API_KEY (deployment.md).

A failed lookup never fails the fetch. The video arrives with what the feed says.

Each YouTube item has a video_kind: video, short or live. Items fetched before SI-526 were classified by their link when the migration ran: Shorts by /shorts/, everything else as video.

Transcripts

The pipeline’s extract stage fetches each new video’s transcript from its captions, for the AI stages to read. Videos without captions keep their description. See extraction.md.

To read a transcript yourself, press Show transcript under the video’s description in the reader. It loads on request, since transcripts run to thousands of words, and shows in paragraphs: YouTube’s captions come as one long run of text, so the reader breaks it after the sentence that passes about 500 characters, or at a space (or every 500 characters) when automatic captions have no punctuation. Hide transcript folds it away. After 90 days the transcript is pruned with the item’s text, and the button goes.

Asking YouTube through a proxy

YouTube answers many servers in data centers with “Sign in to confirm you’re not a bot”, for transcripts and watch pages alike. The same requests usually work from a home connection. Whether your server is affected depends on its provider. Many VPS addresses are blocked; a server at home usually isn’t.

When YouTube blocks the server, nothing breaks:

  • Videos keep their description as their text, and the AI stages read that.
  • Settings → Executions shows why: “YouTube asks this server to sign in: it blocks many data-center addresses. Set YOUTUBE_PROXY_URL…”.

YOUTUBE_PROXY_URL sends Hotaru’s requests to YouTube through a proxy. That covers the player API, caption tracks, watch pages and the Data API. Everything else goes out directly, including the channel feeds, which YouTube doesn’t block. Code: youtubeDispatcher() in feeds/http.ts.

Form Example
HTTP proxy http://proxy.example.com:8080
HTTPS proxy https://proxy.example.com:8443
With a user name and password http://user:[email protected]:8080
SOCKS5 (experimental in Node’s HTTP client) socks5://192.0.2.10:1080

At start, the log says which proxy is used ([youtube] Requests to YouTube go through YOUTUBE_PROXY_URL (http://proxy.example.com:8080).), without the user name and password. An address in any other form fails each YouTube request with “YOUTUBE_PROXY_URL isn’t an http://, https:// or socks5:// address.”

For a video that already failed, Run again in Settings → Executions fetches it again once the proxy works. That runs the item’s paid stages again too (pipeline.md).

Where the proxy can leave from

Any connection YouTube doesn’t block works. Some options:

  • A residential proxy provider. Paid services that route through home connections. Use the HTTP address with your user name and password that they give you.
  • Your own home connection, through a VPN exit node. For example, a Tailscale exit node at home (any always-on device) plus a small proxy container next to Hotaru. See the next section.
  • An SSH tunnel to a machine at home. ssh -N -D 0.0.0.0:1080 you@home-machine on a host that Hotaru can reach gives a SOCKS5 proxy: socks5://<that host>:1080. Keep the port off the internet.
  • Any HTTP proxy you run elsewhere, such as Squid or tinyproxy on a server that YouTube doesn’t block.

Only point Hotaru at a proxy you trust: it sees which videos Hotaru asks about.

Example: a Tailscale exit node at home

This runs a Tailscale container next to Hotaru that offers an HTTP proxy and sends its traffic through an exit node in your tailnet. Only what Hotaru sends to the proxy takes that route. The server’s own traffic stays as it is.

  1. Make a home device an exit node. In its Tailscale app, turn on Run as exit node. Then approve it in the admin console: the device → Edit route settings → Use as exit node. Disable key expiry for it.

  2. Create an auth key for the proxy under Settings → Keys: not reusable, not ephemeral, with a tag such as tag:hotaru-proxy. Add the tag to tagOwners in your tailnet policy. If your policy limits traffic, also grant tag:hotaru-proxy access to autogroup:internet.

  3. Run the proxy on the same Docker network as Hotaru, without publishing a port:

    services:
    youtube-proxy:
    image: tailscale/tailscale:stable
    hostname: hotaru-youtube-proxy
    environment:
    - TS_AUTHKEY=${TS_AUTHKEY}
    - TS_STATE_DIR=/var/lib/tailscale
    - TS_USERSPACE=false
    - TS_OUTBOUND_HTTP_PROXY_LISTEN=0.0.0.0:1055
    - TS_EXTRA_ARGS=--exit-node=<exit node's Tailscale IP> --exit-node-allow-lan-access=true --advertise-tags=tag:hotaru-proxy
    devices:
    - /dev/net/tun:/dev/net/tun
    cap_add:
    - NET_ADMIN
    - NET_RAW
    volumes:
    - tailscale-state:/var/lib/tailscale
    restart: unless-stopped
    volumes:
    tailscale-state:
    • Kernel mode (TS_USERSPACE=false, the tun device, NET_ADMIN): in userspace mode, Tailscale’s HTTP and SOCKS5 proxies ignore the exit node.
    • --exit-node-allow-lan-access keeps the Docker network out of the tunnel, so the proxy’s answers reach Hotaru.
    • The exit node’s IP address, not its name: by name, Tailscale refuses to start (“cannot resolve exit node by hostname while Tailscale is starting up”).
  4. Check that it leaves from home. This prints your home connection’s IP address, not the server’s (use your Docker network’s name):

    Terminal window
    docker run --rm --network <network> curlimages/curl -sS --max-time 20 -x http://youtube-proxy:1055 https://api.ipify.org

    If it prints the server’s address or hangs, run docker exec <proxy container> tailscale status: the exit node’s line says active; exit node.

  5. Point Hotaru at it: YOUTUBE_PROXY_URL=http://youtube-proxy:1055 (the container’s name on that network), then restart Hotaru.

When the home device is off, YouTube requests fail and videos keep their description, as without the proxy. On Coolify, the proxy is a Docker Compose resource with Connect to Predefined Network turned on. Coolify adds a suffix to its container name (docker ps shows it), and that full name goes into YOUTUBE_PROXY_URL.

In the stream

Cards of YouTube items show a badge on the thumbnail: the duration, “Short · 0:41”, or “Live”.

In the reader

The reader plays the video in place of its thumbnail. Code: YoutubePlayer.svelte.

  • Click to load: the reader shows the thumbnail, served from Hotaru’s own image cache, with a play button. Nothing is loaded from YouTube until the play button is pressed. Then the player starts right away.
  • No cookies: the player comes from www.youtube-nocookie.com/embed/<id>, YouTube’s privacy-enhanced mode. The video ID comes from the item’s link (watch?v=, /shorts/, /live/).
  • Shorts play in a portrait frame (9:16), live streams and videos in 16:9. Full screen and picture-in-picture work.
  • Referrer: the player is sent the page’s origin (strict-origin-when-cross-origin). Without it, YouTube refuses to play with “Video player configuration error”.
  • Keyboard: after the click, the player has the focus. Space, k, f and the arrows go to YouTube, not to Hotaru’s shortcuts. Click outside the player to use Hotaru’s keys again.
  • Security: the Content-Security-Policy allows frames only from www.youtube-nocookie.com and player.vimeo.com (hooks.server.ts). YouTube players embedded in feed content are moved to the no-cookie host when the content is cleaned. Items stored before are rewritten in the reader.
  • A video has no article to load, so the reader doesn’t offer Load full article for it.

Under Settings → Appearance → YouTube, each user can hide Shorts and live streams. Hidden videos stay out of the stream, the unread count, the new-items pill and “Mark all as read”. Starred videos always stay in Starred. Hiding a live stream needs a lookup to know it is one, so with no key, an older stream can still appear.