Download Youtube content with youtube-dl


Example for OSX:

Make a new directory:

mkdir youtube-dl
cd youtube-dl

Install the python-tool youtube-dl:

sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o youtube-dl

To convert audio to mp3, you need ffmpeg:

wget https://evermeet.cx/ffmpeg/ffmpeg-4.2.2.zip
unzip ffmpeg-4.2.2.zip

Create a bash script which saves audio to mp3, with this you don’t have to remember the parameters:

vi youtube-dl-mp3.sh

Content:

#!/bin/bash
./youtube-dl --ffmpeg-location ./ffmpeg -x --audio-format mp3 $1

Save it with :x! and make it executable:

chmod +x youtube-dl-mp3.sh

Now you can let the magic begin by executing this script and give the youtube shortcode as parameter:

./youtube-dl-mp3.sh dQw4w9WgXcQ
 dQw4w9WgXcQ: Downloading webpage
[download] Destination: Rick Astley - Never Gonna Give You Up (Video)-dQw4w9WgXcQ.webm
[download] 100% of 3.28MiB in 00:00
[ffmpeg] Destination: Rick Astley - Never Gonna Give You Up (Video)-dQw4w9WgXcQ.mp3
Deleting original file Rick Astley - Never Gonna Give You Up (Video)-dQw4w9WgXcQ.webm (pass -k to keep)

Now we have an mp3 called:
“Rick Astley – Never Gonna Give You Up (Video)-dQw4w9WgXcQ.mp3”

If you want the complete video, just start:

./youtube-dl dQw4w9WgXcQ

See also the thousands of other options with:

./youtube-dl --help

Leave a Reply