YouTube to MP3 with yt-dlp
Build the yt-dlp command that turns a YouTube video into a tagged MP3 with cover art.
Getting a usable MP3
Extraction is a conversion, so ffmpeg is required — this is the reason the command fails on a fresh install. Best (VBR) is the right default: it gives the best size-to-quality ratio, and a higher fixed bitrate cannot add quality the source never had.
Cover art and metadata turn a folder of anonymous files into something a music player can organise. The naming template here puts the artist first, falling back to the uploader when no artist is tagged.
--audio-quality 0 is the setting people most often get wrong. It is not "zero quality" — it is the best variable-bitrate setting, roughly 245 kbps on average, and the scale runs the other way: 0 is best and 9 is worst. Variable bitrate spends more bits on the busy parts of a track and fewer on silence, which is why a VBR file usually sounds better than a constant-bitrate one of the same size. If you need a fixed rate for a device that insists on it, ask for it by name — --audio-quality 320K — rather than guessing at a number on the 0–9 scale.
The bigger question is whether to convert at all. YouTube serves audio as Opus or AAC, and neither is MP3, so asking for MP3 always means re-encoding: the file is decoded and compressed a second time, and some quality goes with it every time. If nothing you own demands the .mp3 extension specifically, choose "Best (no conversion)" instead. It is faster, it skips ffmpeg entirely, and the result is closer to the source than any MP3 of it can be. Convert when a car stereo, a DJ program or an old phone leaves you no choice.
For a whole playlist, turn playlists on and add an archive file. The archive records what has already been fetched, so running the same command next week picks up only what is new instead of starting over — and combined with "keep going after errors", one region-locked or deleted track stops taking the other two hundred down with it. Add the playlist index to the output template if the running order matters; without it your player will sort the folder alphabetically and the album will be in the wrong sequence.