How to listen only the audio in Youtube using the console

The most common Youtube app downloader there is youtube-dl, I am pretty sure that it is available in Ubuntu’s, Debian’s, Arch’s, Gentoo’s and OpenSUSE repos; but it is certain that it is available in a bunch of distros.

In Ubuntu and Debian you may install it with this command:

sudo apt-get install youtube-dl

I think this is the first Link from Google when searching for a Linux Youtube Music player: Link ; however, there is a lot of answers and some of them are complex. For the sake of simplicity I will share with you the most straightforward resolution to me:

mplayer <(youtube-dl -q -f bestaudio[ext=m4a] "$URL" -o - )

Mplayer is a command-line media player very usual in the Linux systems, so you may need to install it first.

I made it easier for you:

read -p "paste the url please:" URL ; mplayer <(youtube-dl -q -f bestaudio[ext=m4a] $URL -o - )

And I created this shortcut so you will never miss this command: In a terminal type the following for displaying the adequate command :

curl curl.pink/listen-music

(That is one of the reasons that my website is named curl, to not forget)

Explanation:

The full command will ask you for input the youtube URL.

After the mplayer command is the youtube-dl command, which is surrounded by parenthesis starting with a lesser than symbol. The whole output of this command will be treated as a file, so that it ends in a hyphen meaning that the resulting extraction will be redirected to standard output.

These bottons respect your privacy