There is a famous command line tool called youtube-dl to download videos from youtube, and its an opensource project written in python and available for Linux, windows and OSX platforms.
In Linux, you can install the tool using:
$ sudo pip install –upgrade youtube-dl
To download a video from a link:
$ youtube-dl <Your Video link>
Example: youtube-dl https://www.youtube.com/watch?v=pRpeEdMmmQ0&list=RDpRpeEdMmmQ0
It will get donwloaded in $PWD.
To download mp3 from a link:
$ youtube-dl –extract-audio –audio-format mp3 <Your Video Link>
Example: youtube-dl –extract-audio –audio-format mp3 https://www.youtube.com/watch?v=krpm0DaeLnI
It will get downloaded in $PWD.
Do “youtube-dl -h” for more help on formats and other features.