We’ll need
- mpd with curl support
- youtube-dl
For example, we may want to listen to some vocal trance on youtube.
First we use youtube-dl to determine what formats are available
$ youtube-dl -F http://www.youtube.com/watch?v=HS5fHWmzqIg [youtube] Setting language [youtube] HS5fHWmzqIg: Downloading video webpage [youtube] HS5fHWmzqIg: Downloading video info webpage [youtube] HS5fHWmzqIg: Extracting video information Available formats: 22 : mp4 [720x1280] 18 : mp4 [360x640] 43 : webm [360x640] 5 : flv [240x400] 36 : 3gp [240x320] 17 : 3gp [144x176] 136 : mp4 [720p] (DASH Video) 135 : mp4 [480p] (DASH Video) 134 : mp4 [360p] (DASH Video) 133 : mp4 [240p] (DASH Video) 160 : mp4 [192p] (DASH Video) 141 : m4a [256k] (DASH Audio) 172 : webm [256k] (DASH Audio) 140 : m4a [128k] (DASH Audio) 171 : webm [128k] (DASH Audio) 139 : m4a [48k] (DASH Audio)
There are 5 audio formats for this video, the one with id 141
has the highest bitrate. All that is left is to get the real URL for this format and feed it to mpd
$ mpc add `youtube-dl -f141 -g http://www.youtube.com/watch?v=HS5fHWmzqIg`
That’s all, track from youtube is now in mpd queue. Enjoy!