I absolutely love music in every shape or form and YouTube is an endless source of new inspiration for me. Few months ago I wanted to transcribe some songs, but at that time I was travelling abroad and the internet connection wasn’t always available. Searching for a solution, I found this useful tool called youtube-dl.
YouTube-dl is awesome! After creating a list of files (video.txt) that I wanted to download I wrote a simple loop that iterates through the list and downloads each video.
#!/bin/bash
#author: Paolo Frigo, https://www.scriptinglibrary.com
video_list="videos.txt"
total=$(wc -l $video_list | awk '{ print $1 }')
counter=0
help="Please, install it:
'sudo apt-get install youtube-dl' or
'brew install youtube-dl'
for more info: https://github.com/rg3/youtube-dl"
if command -v youtube-dl >/dev/null 2>&1 ; then
echo "$(date) Download Started..."
else
echo "youtube-dl not found. $help"
exit
fi
for video in $(cat $video_list); do
counter=$(($counter + 1))
echo "[$counter/$total]: " $video
youtube-dl -f 22 -o '%(title)s.%(ext)s' $video
done
echo "$(date) Download Finished!"
You can find this source code on git. I hope you find it useful and if you have got any question don’t hesitate to contact me.


