Firstly, install youtube-dl.
jason@darkstar:~/Music$ sudo apt-get install youtube-dl |
Then run this command with the Youtube video URL.
jason@darkstar:~/Music$ youtube-dl -f bestaudio -x --audio-format mp3 --prefer-ffmpeg https://www.youtube.com/watch?v=UWFm2LIYNjg [youtube] UWFm2LIYNjg: Downloading webpage [youtube] UWFm2LIYNjg: Extracting video information [youtube] UWFm2LIYNjg: Downloading DASH manifest [download] Destination: Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.m4a [download] 100% of 13.85MiB in 00:11 [ffmpeg] Correcting container in "Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.m4a" [avconv] Destination: Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.mp3 Deleting original file Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.m4a (pass -k to keep) |
Now the MP3 file will be created on your HDD. This is the best way to save an MP3 of your favourite song on Youtube.
The –write-thumbnail parameter will write the video thumbnail to a jpeg file as well as the MP3, this could be useful if you wish to have it as the music ID3 art.
jason@darkstar:~/Music$ youtube-dl -f bestaudio -x --audio-format mp3 --write-thumbnail --prefer-ffmpeg https://www.youtube.com/watch?v=UWFm2LIYNjg [youtube] UWFm2LIYNjg: Downloading webpage [youtube] UWFm2LIYNjg: Extracting video information [youtube] UWFm2LIYNjg: Downloading DASH manifest [youtube] UWFm2LIYNjg: Downloading thumbnail ... [youtube] UWFm2LIYNjg: Writing thumbnail to: Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.jpg [download] Destination: Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.m4a [download] 100% of 13.85MiB in 00:22 [ffmpeg] Correcting container in "Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.m4a" [avconv] Destination: Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.mp3 Deleting original file Dune (1983) OST - Dune Prophecy (Long Version)-UWFm2LIYNjg.m4a (pass -k to keep) |
Use this whenever you want to save a Youtube video to a music file in your ~/Music folder.