Get video URLs from a YouTube playlist

I wanted to make my own list of YouTube video URLs today, and as far as I can tell, YouTube doesn't let you do that. The excellent tool youtube-dl came to the rescue, along with a post on askubuntu that combines it with jq and sed.

I wanted to output the video URLs and the titles, and it turns out this can be achieved with jq on it's own. I changed the jq portion and the final commandline looks like this.

1
2
youtube-dl --dump-json --flat-playlist "https://www.youtube.com/playlist?list=PL46-cKSxMYYCMpzXo6p0Cof8hJInYgohU" \
  | jq -r '"\(.title)\nhttps://youtu.be/\(.id)\n"'

This outputs something like:

1
2
3
4
5
6
7
8
9
Vim Un-Alphabet 01: Teaser
https://youtu.be/7LDlUMMbv6k

Vim Un-Alphabet 02: Help
https://youtu.be/ZTCzWRqR_us

Vim Un-Alphabet 03: Tilde
https://youtu.be/5jMiYtXz2QA

Of course, we can pipe the result of this to a file by appending > result.txt or, in my case, straight to the clipboard with | pbcopy.