Tag Archives: download

Generate list of youtube links from song titles

I needed to get a list of youtube links from a list of song titles. Thanks to this reddit post I was able to get what I needed. I did have to update it to use yt which is a fork of the referenced mps-youtube package.

After installing yewtube per https://github.com/mps-youtube/yewtube#installation I was able to get what I wanted with this one-liner:

while read song; do echo $song; yt search "$song", i 1, q|grep -i link| awk -F ': ' '{ print $2 }'; done < playlist

The above command looks at a playlist which is only artist & song names, prints the song name to the console for reference, then uses yewtube to search youtube for that song name and select the first result, then grab the link and print it to the screen.

I had to double check that the correct version of the song was selected, but for the most part it did exactly what I needed!

Get youtube audio with metadata

Taken from here

yay -S atomicparsley

youtube-dl --extract-audio -f bestaudio[ext=m4a] --add-metadata --embed-thumbnail YOUTUBE_URL

Update 2025-12-11

yt-dlp is the successor to youtube-dl. Here is the latest (with an appropriate cookies file)

yt-dlp --audio-format m4a -x --embed-metadata --embed-thumbnail --cookies cookies.txt YOUTUBE_URL

You can also do a list of URLs by passing the -a argument:

yt-dlp --audio-format m4a -x --embed-metadata --embed-thumbnail --cookies cookies.txt -a playlists.txt

I used this cheat sheet to get the parameters I want.