Managing videos and playlists locally with YouTube DL

2026/07/08 - 2026/07/11

I have a YouTube Premium subscription, so downloading videos once and for all only reduces the burden of their servers.

Do not forget to use --cookies-from-browser <browser> in case some videos require you to be logged in.

Example playlist metatdata pulling

Let’s assume some video IDs stored in playlist.txt, one ID per line.

def yt-dlp-playlist [file: path, --browser: string] {
    let ids = open --raw $file | lines
    let n = $ids | length
    let w = $n | into string | str length
    $ids
    | enumerate
    | each {
        print $"[($in.index + 1 | fill -w $w -a right -c ' ') / ($n)] ($in.item)"
        yt-dlp ...[
            $"https://www.youtube.com/watch?v=($in.item)"
            --skip-download
            --quiet
            --dump-json
            ...(if $browser != null {[--cookies-from-browser $browser]} else {[]})
        ]
        | from json
    }
}

Example download

The example video is QoGM9hCxr4k, the first opening of 葬送のフリーレン (Sōsō no Furīren | Frieren: Beyond the Journey’s End): YUSHA(Brave) from YOASOBI.

yt-dlp ...[
    https://www.youtube.com/watch?v=QoGM9hCxr4k
    --force-overwrites
    -t sleep
    -f "bv*[height<=720][ext=webm]+ba[ext=webm]/b[height<=720]"
    --merge-output-format webm
    -o "%(id)s.%(ext)s"
]
QoGM9hCxr4k.webm will be downloaded and not exceed a resolution of \(720\text{px}\).