Francesco Mantovani
Francesco Mantovani

Reputation: 12377

youtube-dl :: search for video and listen

One of the features of youtube-dl allows you to search for a video and download.

Example: if I want to search for P!NK - Never Gonna Not Dance Again I just need to do:

youtube-dl "ytsearch1:P!NK - Never Gonna Not Dance Again"

And the video is downloaded on my computer.

But what I want to do instead is not downloading.

I want to grab the URL ID which for P!NK - Never Gonna Not Dance Again is iqYK79jCssA :

enter image description here

and I want to listen to it on a web browser this way:

youtube-dl -g 'iqYK79jCssA'

The steps should be:

  1. Search for P!NK - Never Gonna Not Dance Again and not download
  2. Grab the URL ID
  3. Listen to web browser

Upvotes: 1

Views: 372

Answers (1)

ilias-sp
ilias-sp

Reputation: 6705

Seems the -g prints the links for the audio and video streams of the YT video - https://www.youtube.com/watch?v=iqYK79jCssA in our case.

Using options --skip-download and --get-id, you can extract the video ID, skip downloading of the video, but pass it to an echo command to build the string for the link you need to use from your browser:

[ilias@greenhat-37 tmp]$ youtube-dl 'ytsearch1:P!NK - Never Gonna Not Dance Again' --skip-download --get-id | xargs -I {} echo "https://www.youtube.com/watch?v="{}
https://www.youtube.com/watch?v=iqYK79jCssA
[ilias@greenhat-37 tmp]$ 

Upvotes: 1

Related Questions