Toni Tested :: How to download a large amount of YouTube videos

How to download a large amount of YouTube videos

Ever wanted to download a whole playlist or even a whole channel from YouTube? This article will help you.

Posted by Anton Šijanec on November 1, 2018
2captcha
Loading content. Please disable adBlock if this doesn't disappear.

Intro

Imagine you are going on a long holiday and you know you will have no Internet access there. How are you going to watch YouTube or listen to music from YouTube? You would probably google for a online youtube downloader. But those downloaders usualy contain a lot of annoying ads and redirections an often don't allow a lot of videos to be downloaded at once, at least not for free. So you want to make your own personal YouTube downloader that can download any video in seconds, without annoying popups and it is 100% free. Keep reading to figure out how to do it!

First of all I have to tell you that downloading videos for commercial use is illegal and since you won't watch ads, the publisher will not earn anything. It is also against YouTube's usage policy to download music, even if it is only for personal use. I am not responsible for any damage done!

If you understand the terms specified above, continue with the blog post. This kind of downloading is not very datectable, not even for the YouTube staff, so unless you publish the downloaded content on a pirate website, you will probably remain unnoticed and okay.

Note that this software can be used for almost any video sharing website, even for your local television archive.

Requirements

For viewing/listening to downloaded content you can use any device that can play music and/or video.

For downloading you need a computer running Linux, Windows or Mac OS with sufficient bandwith (Internet connection). If you are planning to download more than 500 videos, I recommend you Linux because it is faster.
If some videos have geolocation restrictions, you will need a VPN or a proxy. If you do not already have a VPN and do not want to pay, I recommend you Tor.
If some videos have age restrictions, you will need a Google account with a high enough age.

Preparing the software

We will use an open source program called youtube-dl.

If you have Windows, visit https://rg3.github.io/youtube-dl/download.html and click on the Windows exe link. That will download the binary for you. Copy the file from your Downloads folder to the folder where you will keep the YouTube downloader software (empty one).

If you have Linux you will need root access. Open terminal and paste the following code inside it:

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

For OSX use Homebrew. Copy and paste this in the terminal: brew install youtube-dl

For all systems it is required to install ffprobe too.

On Windows, download it from https://ffbinaries.com/downloads. Scroll down to get the latest version (currently 4.0.2). You only need ffprobe, not ffserver, ffmpeg or ffplay. Rename the downloaded binary to ffprobe.exe and move it from your Downloads folder to the folder where you have already placed youtube-dl.exe. Make two copies of the ffprobe.exe and name them ffprobe.exe and ffprobe. Now you have three files in your folder: youtube-dl.exe, ffprobe.exe and ffprobe.

If you have Linux or OSX it will be much easier. Copy and paste the following commands into your terminal to install ffprobe. You will need root access:
Linux users should type sudo apt-get install -y libav-tools in terminal to install ffprobe. You will need root access.
Mac users have to use Homebrew. Type brew install ffmpeg in to your terminal install ffprobe.

Using youtube-dl

youtube-dl has A LOT of options. I am obviously not able to cover every option, but I will try to put some most used examples.

Command line arguments are the same for both UNIX (Linux+OSX) and Windows, but there are filesystem differences. To download a sound or video you must first open Terminal for Linux and OSX or Command Prompt (cmd) for Windows (search for it in Start menu). On Windows you have to navigate to your directory (folder) with youtube-dl.exe, ffprobe.exe and ffprobe. Use command cd C:\path\to\software to achieve this.

On UNIX you can stay in your home directory.

Now we can use the software. Every download command must begin with youtube-dl and end with the YouTube URL of the channel, playlist or one video.

Switches

To change download options, you have to use switches. Add a switch after youtube-dl and before the YouTube link. Some examples (note the capitalisation):

Switch What it does
-U Updates the youtube-dl client. Useful if it stops working.
-i Ignore errors. Usefull if some videos are blocked. (recommended)
--proxy URL Use SOCKS5 proxy. You can use Tor, but expect speed decreasment. Tor example: socks5://localhost:9050/
--geo-bypass Bypass georestrictions.
--max-filesize SIZE and --min-filesize SIZE Do not save videos/music that will be smaller/bigger than SIZE. For example 10m, 55k, 2m.
-o "C:/path/to/directory/%(title)s-%(id)s.%(ext)s" Output directory path. Leave empty for curent directory. Windows users should use / instead of \.
-c Continue to download .part files (default ON).
-q Be quiet (not recomended, default OFF).
-v Verbose output, print a lot of useful info in the terminal.
--write-sub --sub-lang LANGS Write subtitles into .srt file. LANGS are comma seperated language codes, such as en, sl, hr, au.
-u USERNAME -p PASSWORD Google username and password. For age verification and private videos.
-f FORMAT Video format to download. mp4 is recommended, because it is the smallest.
-x --audio-format FORMAT Only download audio, it is recommended to set FORMAT to mp3, because it is the smallest.

Example commands

Make sure to put your URL in quotes!

Command Description
youtube-dl -cix --audio-format mp3 --max-filesize 10m -o "D:/MUSIC/housenation/%(title)s-%(id)s.%(ext)s" "https://www.youtube.com/channel/UCj_Y-xJ2DRDGP4ilfzplCOQ" Download every song from House Nation to D:\MUSIC\housenation\ with maximum size 10 megabytes, so it doesn't download mixes.
youtube-dl -ci -f mp4 -o "D:/VIDEOS/importantvideos/%(title)s-%(id)s.%(ext)s" "https://www.youtube.com/watch?v=q6EoRBvdVPQ&list=PLFsQleAWXsj_4yDeebiIADdH5FMayBiJo" Download every video from important videos playlist in mp4.
youtube-dl -f mp4 -o "D:/VIDEOS/meinthezoo.mp4" "https://www.youtube.com/watch?v=jNQXAC9IVRw" Download the first video uploaded on YouTube, Me in the zoo in mp4.
youtube-dl -ci -f bestvideo+bestaudio -o "/dev/null/%(title)s-%(id)s.%(ext)s" "https://www.youtube.com/channel/UC-lHJZR3Gqxm24_Vd_AJ5Yw" Download all videos from PewDiePie in best quality without saving them. Useful if you hate your ISP and you want to waste your bandwith. Works only on UNIX systems (Linux, MacOS).
youtube-dl -cixv --audio-format mp3 -o "D:/MUSIC/funkypanda-electroswing/%(title)s-%(id)s.%(ext)s" "https://www.youtube.com/channel/UCUHhoftNnYfmFp1jvSavB-Q" --match-title "swing" Download every song from channel Funky Panda™ that contains SWING in its title (case-insensitive) to D:\MUSIC\funkypanda-electroswing\.
For example: swing xxxxxxxxxxx, xxxxxxxxx swing, SwInG xxxxxxxx,xxxxxxxxxxxxxxx SwiNg will all be downloaded.

Thanks for reading this article. If you like my posts, please subscribe to my blog and you will get notified for future posts. Subscription form can be found under this text.