Watching YouTube in Private
I recently stumbled across link to the site yewtu.be and found it intriguing. It’s not only possible to watch YouTube without being on YouTube, it’s also possible to create an account and subscribe to channels without a Google account. I wondered what sort of wizardry was going on under the hood and discovered that it’s a hosted version of invidious.
Wow, this is cool, and JavaScript is not required.
I started to use yewtu.be as my primary client for watching videos. I subscribe to about a dozen channels and I really only want to a see list of the latest videos from my subscriptions, and not be the victim of a proprietry algorithm feeding me new content. A few days ago, yewtu.be went down briedly, and that motivated me enough to self-host inviduous.
There are several other hosted instances of inviduous listed here, but being able to easily backup my own instance (along with watch history) is more compelling in my case.
Hosting inviduous
The quickest way to get invidious up is with docker-compose as mentioned in the docs.
I made a few modifications (such as pinning the container’s tag), and ended up with:
version: "3"
services:
invidious:
image: quay.io/invidious/invidious:5160d8bae39dc5cc5d51abee90571a03c08d0f2b
restart: unless-stopped
ports:
- "0.0.0.0:3000:3000"
environment:
INVIDIOUS_CONFIG: |
db:
dbname: invidious
user: kemal
password: kemal
host: invidious-db
port: 5432
check_tables: true
healthcheck:
test: wget -nv --tries=1 --spider http://127.0.0.1:3000/api/v1/comments/jNQXAC9IVRw || exit 1
interval: 30s
timeout: 5s
retries: 2
depends_on:
- invidious-db
invidious-db:
image: docker.io/library/postgres:14
restart: unless-stopped
volumes:
- postgresdata:/var/lib/postgresql/data
- ./config/sql:/config/sql
- ./docker/init-invidious-db.sh:/docker-entrypoint-initdb.d/init-invidious-db.sh
environment:
POSTGRES_DB: invidious
POSTGRES_USER: kemal
POSTGRES_PASSWORD: kemal
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
volumes:
postgresdata:
After this, I installed Tailscale on it, to leverage its MagicDNS and am able to access it anywhere at http://invidious:3000/feed/subscriptions.
Redirecting YouTube links
I figured it would be nice to redirect existing YouTube links that others send me, so that I could seamlessly watch the videos using inviduous.
Without subjecting my entire household to this, I went looking for a way to redirect paths at the browser level. I found the lightweight proxy requestly, which can be used to modify http requests in my browser. I created the following rules:
Now the link https://www.youtube.com/watch?v=-lz30by8-sU will redirect to http://invidious:3000/watch?v=-lz30by8-sU
I’m still looking for ways to improve this inviduous setup. There doesn’t appear to be a way to stream in 4K yet.