Install a youtube playlist downloader

In this post, i’m going to explain you how to build your home made youtube playlist downloader using a bash script.

Currently i use my RaspberryPi to download playlists but steps used in this tutorial should be the same for you.

Retrieve the youtube-dl package Either with CURL or WGET :

pi@raspberrypi:~ $ sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
pi@raspberrypi:~ $ sudo chmod a+rx /usr/local/bin/youtube-dl

The following script download the best audio quality of a youtube playlist starting by the parameter $1 and at the end create a compressed file containing music.

#!/bin/sh
#search update
youtube-dl -U 
#My music folder
cd /home/pi/Music
# remove previous files
rm -r *
youtube-dl --playlist-start $1 -x --audio-quality 0 -i https://www.youtube.com/playlist?list=URL_OF_YOUR_PLAYLIST
#compress music files in a tar folder
tar cvf compresse.tar ./* 

Add execution privileges and start harvesting 🙂

pi@raspberrypi:~ $ sudo chmod u+x pi
#starts downloading from the 205th music
pi@raspberrypi:~ $ ./auto.sh 205

The courageous ones can create a web application and can even make money by renting youtube playlist downloader service. Not sure whether or not it’s a legal activity :).

Usually, I collect the last musics that I haven’t added to my playlist before, so I don’t need to specify the end. However you can specify a range by adding the “–playlist-end” parameter.

For those that didn’t know youtube-dl, check the documentation for further information. As it is a very powerful tool, it allows you to download video or audio from several hosts other than youtube as twitch.tv, twitter, vimeo…

Twitch clips and twitter videos are really easy to download with this command line tool. I can give you the command line for the twitch and twitter scripts if you want.

© 2022 Delog • Crafted with ❤️ by W3Layouts