Download an entire YouTube channel with youtube-dl and automatically resume if interrupted
I'm downloading an entire YouTube channel consisting of about 10,000 videos. Sometimes the download stops due to errors like "content too short" or "connection interrupted". However, is there a way to automatically restart the download? There is probably a batch file you can make, but I don't know how to make one.
This is the command I use to download:
youtube-dl -f bestvideo+bestaudio ytuser:(Channel) -o "/Videos/lhs/[%(upload_date)s - %(id)s] %(title)s.%(ext)s" --ffmpeg-location %CD%\ffmpeg\bin 0 6 Answers
This answer won't work on older versions of youtube-dl. You need to update youtube-dl to the latest version. If you have Python installed on your system, you can install the latest version of youtube-dl locally inside a Python virtual environment, or you can download the latest version of youtube-dl and install it globally.
In Ubuntu 14.04 and later youtube-dl is also a snap package. To install it type:
sudo snap install youtube-dl # launch it with snap run youtube-dl
Open the terminal and type:
youtube-dl -f best -ciw -o "%(title)s.%(ext)s" -v <url-of-channel>...where <url-of-channel> is replaced by the URL of the channel.
Note: If you are downloading a lot of videos, you should change directories to the directory where you want to save the videos before you start downloading them.
Explanation
-f, --format FORMAT video format code. The special name "best" will pick the best quality.
-c, --continue force resume of partially downloaded files
-i, --ignore-errors continue on download errors, for example to skip unavailable videos in a channel
-w, --no-overwrites do not overwrite files
-v, --verbose print various debugging information 6 If you look youtube-dl man page you will see option to resume partial downloads.
-c, --continue Resume partially downloaded files.Man Page Link
4Perhaps this argument didn't exist when the question was asked, but using
--ignore-errorswill cause youtube-dl to continue downloading regardless of any errors. Use with caution, since a catch-all solution like this has the potential to cause problems if you miss an important error, although with a channel with 10k videos, you probably don't mind if a handful of them don't download properly.
In addition, using
--download-archive archive.logwill keep track of what's already been downloaded and will skip videos that you've already got, so if the script stops due to something like a power failure, when you run it again it won't try to re-download everything from the beginning.
you should use the option "--download-archive". That will skip already downloaded videos from your playlist/channel.
1A helpful script: youtube_channel_archiver
My suggestion is to use newer, more developed and more supported yt-dlp.
I am scraping channels using command (in .bat file):
yt-dlp -i -f bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio --merge-output-format mp4 "Put_here_YouTube_Channel_URL" -o "%%(upload_date)s %%(title)s.%%(ext)s"which gives me best mp4 with best audio and makes file name starting with date of the video.