I recently found a 2 hour YouTube video where I wanted to listen to the audio only. On trying to install youtube-dl on my server, I was shocked to see the number of packages that it was trying to install.
I run Ubuntu, but this should work in any Linux distro. Using a docker container saves polluting your server with a lot of dependencies you might not need.
If you don’t already have it, install docker:
# curl -fsSL get.docker.com -o get-docker.sh # sh ./get-docker.sh
The following will download a video to the current working directory:
# docker run --rm -v $PWD:/downloads wernight/youtube-dl "https://www.youtube.com/watch?v=id-here
This will extract just the audio and give you the output as an mp3:
# docker run --rm -v $PWD:/downloads wernight/youtube-dl --extract-audio --audio-format mp3 "https://www.youtube.com/watch?v=id-here"