← Pablo Murad

Note IV

First day of vacation, and I already miss my natural habitat. It has a keyboard, a screen, and no out-of-office reply.

So, with nothing to do, I did what any reasonable person on vacation does: I started opening random repositories to see what was inside. That's how I ran into cobalt, a media downloader. You paste a link from YouTube, TikTok, Instagram, Reddit, SoundCloud or a pile of other places, and it hands the file back.

The cobalt web app on a black background: a sidebar with save, remux, settings, donate, updates and about, a line-drawn cat in the middle, a box that says "paste the link here", the buttons auto, audio, mute and paste, and at the bottom "by continuing, you agree to terms and ethics of use".

The sad part: it doesn't work as advertised. Self-hosted, about half of the YouTube downloads failed, with 0-byte files and an error saying the "file tunnel is empty", which is a very poetic way of saying nothing came out.

The community noticed long ago. There are forks that fix the video sites' APIs, YouTube included.1 The catch is the treasure hunt: a fork here, a patch there, a setting nobody wrote down, and the vacation quietly turns into an assembly job.

So I put all the pieces in one place, an apparent fork, or almost a fork, at code.pablomurad.com/cobalt.git. It doesn't carry cobalt's code, only everything around it: Docker Compose for the API and the web app, a community fork that gets YouTube right, a daily timer that follows that fork and rebuilds only when something changes, and fixes for the two errors that showed up along the way.

$ git clone --recursive https://code.pablomurad.com/cobalt.git
$ cd cobalt && cp .env.example .env
$ ./build-api.sh && ./build-web.sh
$ docker compose up -d
Source
$ git clone --recursive https://code.pablomurad.com/cobalt.git
$ cd cobalt && cp .env.example .env
$ ./build-api.sh && ./build-web.sh
$ docker compose up -d

Fill in the addresses in .env before building. If the instance faces the internet, lock it down too, or the whole neighborhood ends up downloading through your connection.2

It's a shame the original doesn't work out of the box, because it's a really cool project. But we saved it. Now, back to vacation. Probably.

Notes

  1. The one in the repo is zImPatrick/cobalt. It generates the proof of origin (PO) tokens YouTube asks for to check that a request comes from a real player, and that's what ends the empty files. ↩

  2. cobalt's API is under AGPL-3.0 and its web app under CC BY-NC-SA 4.0. A public instance has to publish its changes and stay non-commercial. ↩