If you want to automate downloading video’s from YouTube, or just want to download single YouTube video’s once in a while, then keep reading on.
First step is to download a program called youtube-dl from github. This command will download the latest version and put it the /usr/local/bin folder. The second command will make the program executable.
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
or if you are using Windows download the .exe file: youtube-dl.exe
Next you will need the ffmpeg that the program uses to download the video
sudo apt-get install ffmpeg
Download single video from Youtube
To download a single video all you need is to grab the URL of the video and copy this command:
youtube-dl https://www.youtube.com/watch?v=dQw4w9WgXcQ
Download all videos from a Youtube channel(s)
To download all video’s from a channel or multiple channels you can use the command:
youtube-dl "channel_URL"
Or what I like to use is a txt file with all the channels and tell youtube-dl to use the file and read the channel URL’s
nano channels.txt
and paste in all the channel URL's. You can even use a # to comment a line to describe the channel. For example:
#channel about Formula1
"URL"
#channel from person X
"URL"
And then type the following command. This will automatically download all video’s from the channels. Nice thing is that youtube-dl detects all previous downloaded video’s, so it will download only the new video’s
youtube-dl -a channels.txt
Other useful youtube-dl settings
You can also include additional details, such as the title, the uploader name, etc., in the file name by using the following command:
youtube-dl -o "%(title)s by %(uploader)s on %(upload_date)s" URL
Or download only the audio from a youtube video
youtube-dl -x URL
and use the parameter --audio-format mp3 if you only want mp3
For full list of options check the youtube-dl github page examples
And if you want to have more examples leave a comment below and I will help you out.