brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: yt-dlp --download-archive skips videos you already downloaded

CLI
~/tips/tip-ytdlp-download-archive

yt-dlp --download-archive archive.txt "https://www.youtube.com/playlist?list=PLAYLIST_ID"

Remembers which videos were downloaded so a re-run only fetches new ones.

I’d rather not download the same playlist twice. If you run yt-dlp against a channel or playlist regularly, it will happily fetch every video again unless you tell it what it already has.

Add --download-archive with a file name:

yt-dlp --download-archive archive.txt "https://www.youtube.com/playlist?list=PLAYLIST_ID"

After each successful download yt-dlp appends one line to archive.txt, made of the site name and the video ID. On the next run it reads that file first and skips every video it finds there. Run the same command a week later and it only downloads what was added since.

That makes it a good fit for a cron job or a scheduled task. Combine it with --break-on-existing and yt-dlp stops at the first video it already has, which saves time on a long channel that lists newest videos first.

A caveat: the archive records IDs, not files. If you delete a video from disk, yt-dlp still considers it done and won’t fetch it again. Remove the matching line from the archive (or delete the whole file) when you do want it back. Keep one archive file per playlist or per purpose if you move things around a lot.

Respect the terms of the site and the copyright of whatever you download. This is a tool for your own backups and for content you may keep.

Further reading: yt-dlp README: Video selection options

More CLI tips printf 'GET /\r\n' | hexdump -C hexdump -C -s 512 -n 64 disk.img wget --limit-rate=2m https://example.com/big-file.iso wget --spider https://example.com/file.zip rg 'apiKey' -g '!*.min.js' -g '!package-lock.json' All CLI tips (46) All topics

Link