1# install latest youtube-dl version
2#sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
3#sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
4#sudo chmod a+rx /usr/local/bin/youtube-dl
5
6# Ubuntu
7# an older version is available in the repos.
8# You can install that and run with `--update` to get to the latest version
9sudo apt install youtube-dl
10youtube-dl --update
11
12source ~/.bashrc
13
14# install ffmpeg to be able to convert video files to audio
15sudo apt install -y ffmpeg
16
17# macOS
18# brew install youtube-dl ffmpeg
1youtbe-dl -x https://www.youtube.com/watch?v=xvtBAXM-YZs -o ~/Music/%(title)s.%(ext)s
You can also sudo apt install youtube-dl -y
but that installs an outdated version. (Installed 2018.03.14 for me when the latest was 2019.07.02) on July 10, 2019. And 2019.07.02 when the latest was 2019.10.16 on October 21, 2019. That’s 12 versions older.
To upgrade the version, pass it the -U
or --update
flag. Run with sudo
if needed
1sudo youtube-dl --update
1# create conf file
2sudo nano /etc/youtube-dl.conf
Add the following to it and save
# Always extract audio (-x or --extract-audio)
--extract-audio
# Always save Audio in MP3 format
--audio-format mp3
# Save all files to a specific folder
#-o /mnt/d/Music/%(title)s.%(ext)s
# Save to the Linux User's Music dircetory
-o /home/${USER}/Music/%(title)s.%(ext)s
Now you only need tp pass the URL and that’s it.
1youtbe-dl https://www.youtube.com/watch?v=xvtBAXM-YZs
I got tired of typing the complete youtube-dl
all the time so i added an alias for it.
1# '~/.bash_aliases' on Ubuntu or '~/.bash_profile' on macOS
2alias ydl='youtube-dl'
the command now becomes
1ydl https://www.youtube.com/watch?v=xvtBAXM-YZs