23 releases in three weeks: building a local-first video downloader in Go
YTGrab started as a browser UI for yt-dlp and grew into a local media archiver. Notes on securing a localhost server, surviving YouTube's rate limits, a job queue that outlives crashes, and the unglamorous work of shipping installers.
On this page
YTGrab began with a small idea: yt-dlp is the best video downloader there is, and most people will never use it because it’s a command-line tool. Put a clean browser interface in front of it, keep everything on the user’s own computer, and ship it as one program.
Version 1.0.0 shipped on September 26. Version 1.23.0 shipped on October 18. In between, it grew from “paste a link, pick a quality” into something closer to a local media archiver: five sites, watched channels, podcast feeds, a Jellyfin and Plex layout, local captions, and search inside your videos.

- minor releases, Sep 26 to Oct 18
- 23
- sites: YouTube, Vimeo, X, Reddit, Instagram
- 5
- Go binary, UI embedded, no build step
- 1
- media bytes passing through the server
- 0
The shape of it#
YTGrab is a single Go program. It serves a browser UI on 127.0.0.1, and orchestrates yt-dlp and FFmpeg underneath:
Browser ──HTTP + SSE──▶ Go server (127.0.0.1:8787)
├─ API handlers + validation
├─ queue (bounded workers)
├─ SQLite (jobs, settings)
└─ yt-dlp adapter ──▶ yt-dlp ──▶ files on disk
└─▶ ffmpeg (merge / convert)
The UI is plain HTML, CSS, and ES modules embedded in the binary, with no build step. Progress streams to the page over Server-Sent Events. And media never passes through the Go process or the browser: yt-dlp writes straight to the output folder. The server only orchestrates.
A localhost server is still a server#
“It only listens on localhost” is the most common reason local tools skip security. It’s not a good reason. Any web page you visit can make your browser send requests to 127.0.0.1. So YTGrab treats the browser as hostile by default:
- DNS rebinding. The server binds to loopback and rejects any request whose
Hostheader isn’t a loopback name. Without that second check, a malicious domain that re-resolves to127.0.0.1could talk to it. - Cross-site writes. Requests that change anything are rejected based on
OriginandSec-Fetch-Site. - Clickjacking. Every response carries a Content-Security-Policy that forbids framing, plus
X-Frame-Options: DENY. A framed copy of the page would make same-site requests, so this is what stops another site from hiding YTGrab’s buttons under its own. - Injected markup. The page builds content with text nodes, never with HTML from video titles or descriptions.
- The “Send to YTGrab” bookmark only fills in the link field. Nothing is queued until the user presses Add, so another site can’t queue downloads by linking to it.
Then there’s the process boundary, which is where downloaders usually get hurt:
- yt-dlp is started with an explicit argument list, never a shell string, and the URL always comes last, after
--, so a crafted URL can’t become an option. - User input never becomes a yt-dlp option. Format IDs must match a strict pattern and a recent inspection the server ran itself.
- Output paths reported by yt-dlp must resolve inside the output folder, and a job only completes once that file is confirmed to exist there.
- Browser sign-in is opt-in, accepts only names from a fixed list of browsers, and becomes yt-dlp’s
--cookies-from-browser. yt-dlp reads the cookies itself. YTGrab never reads, stores, or logs them.
A queue that survives everything#
Downloads are long, networks drop, and people close laptops. The job model is built around that.
Jobs move through queued → downloading → processing → completed, with failed and cancelled reachable from any active state and paused able to return to queued. Transitions are enforced in exactly one place in the code. In SQLite, a partial unique index prevents two active jobs for the same video, and every update compares the previous state atomically, so two workers can never both think they own a job.
On startup, any job left active by a crash or a closed window becomes failed with the code interrupted. Retry keeps the job ID and resumes from yt-dlp’s .part file instead of starting over.
There’s also only ever one copy running. On startup, YTGrab claims its port before opening the database. If a running YTGrab already holds it (recognized by an X-YTGrab-Version header), the new launch just opens the browser to it and exits. An exclusive lock file stops a second copy on a different port from sharing the database.
Being a good citizen to YouTube#
YouTube sometimes answers with HTTP 429 or a “confirm you’re not a bot” page. The tempting response is to retry. Retrying straight away tends to extend the block.
So there’s a shared cooldown gate. When YouTube blocks, the whole download queue and all format and playlist checks pause together: 15 minutes for the first block, then 30, then 60 while blocks continue, reset by the next successful download. A blocked job goes back in the queue, up to three attempts. The page shows a countdown, and the user can end the pause early.
To avoid triggering blocks in the first place, downloads start 3 to 8 seconds apart, yt-dlp waits half a second between requests, format inspections are serialized at least two seconds apart, and their results are cached (64 entries, ten minutes).
Every site is different#
Supporting five sites through one adapter mostly meant learning each site’s quirks:
- Vimeo links are rewritten to the embedded player URL, because vimeo.com’s own pages make yt-dlp sign in and the embedded player doesn’t.
- X posts already contain sound in their MP4s, so YTGrab picks them with
-f b, and sorts by the shorter side so portrait videos get the right resolution. - Instagram videos are merged into MP4, where yt-dlp would otherwise pick MKV for VP9 with AAC.
- Reddit posts take the YouTube path, with separate video and audio streams merged, but with the post’s ID in the file name and sizes estimated from bitrate.
File names include the quality, like Title [id] 1080p.mp4, so different qualities and clips of the same video never collide. A picked video format is paired with audio from the same container family, so merges stay lossless.
From downloader to archive#
A lot of the later releases added things people do after downloading:
- Watched channels and playlists. A watch remembers every video ID it has seen. Adding one marks everything currently listed as seen, so only new uploads download, with an optional backfill of the newest few. A background loop checks on a 1, 6, or 24 hour interval, through the same throttle and cooldown as everything else.
- Podcast feeds for watched channels, so new episodes show up in podcast apps on a phone.
- A Jellyfin and Plex layout that saves each channel as a show, with a season per upload year, episodes named by date, a poster, and
.nfofiles. - Local captions made on your own computer by whisper.cpp, for videos that have none, and search inside your videos: the Library search finds words in saved subtitles, and each match links to that moment.
- Evidence copies for journalists and researchers: streams kept exactly as served, nothing written into the files, the site’s own metadata saved, and a capture record alongside.
Using YTGrab from a phone on the same Wi-Fi is also possible, and it’s off by default. A phone pairs by scanning a one-time QR code that’s valid for ten minutes. Its key is 256 random bits in an HttpOnly cookie, stored on the computer only as a SHA-256 hash. An allowlist limits phones to downloads, watching, and the Library. Settings, files on the computer, sign-in, backups, and updates stay computer-only, and any new route is refused until it’s added to the list.
The unglamorous part: shipping#
Writing the downloader was the smaller job. Getting it onto other people’s computers, and keeping it working, took more.
$ brew install sanoy24/tap/ytgrab$ scoop bucket add sanoy24 https://github.com/Sanoy24/scoop-bucket$ scoop install sanoy24/ytgrab$ curl -fsSL https://raw.githubusercontent.com/Sanoy24/ytgrab/main/install.sh | sh$ go install github.com/Sanoy24/ytgrab/cmd/ytgrab@latest
The release workflow builds the Windows and Linux archives on Windows and the macOS archives on a Mac, because the menu-bar icon needs cgo. It publishes them together, updates the Homebrew tap and the Scoop bucket, and then installs the release with each method in CI to check that it actually starts. Every archive includes a manifest.json and SHA256SUMS.
yt-dlp needs updating more than anything else, because YouTube changes often. YTGrab checks for new yt-dlp releases in the background and, when nothing is downloading, updates it with the same checksum verification as first-time setup. It always installs into its own tools folder, never over a system-wide yt-dlp.
YTGrab can also update itself on Windows and Linux. It downloads the new release with its .sha256 file, refuses any mismatch, then runs the new program with --version and checks that it prints the expected version before swapping it in. On Windows, a running .exe can’t be replaced, only renamed, so the old one becomes ytgrab.exe.old and the next start deletes it. Updates are refused while downloads are running.
Responsible use#
YTGrab doesn’t bypass sign-in, DRM, or paywalls. The README asks users to download only what they have the right to save, like their own uploads or permissively licensed content, and to follow the platform’s terms and the law where they live.
Try it#
$ brew install sanoy24/tap/ytgrab$ ytgrab --open
On Windows, download the zip from Releases and double-click Start YTGrab.cmd, or use the Scoop bucket. The architecture doc has everything in this post in more detail.
What I’d pass on from this one: a local app deserves the same threat model as a hosted one, because the browser that talks to it also talks to everything else on the internet.
The project
YTGrab: Local Video Downloader
A single Go binary with a clean browser UI for YouTube, Vimeo, X, Reddit, and Instagram. Paste a link, pick the exact quality, and download, with everything running on your own machine.
Personal project
v1.23, installable via Homebrew, Scoop, or one line