14

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
karel
  • 13,390
  • 26
  • 45
  • 52

6 Answers6

18

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
karel
  • 13,390
  • 26
  • 45
  • 52
  • 2
    Good one! +1 **;-)** – Fabby Oct 20 '16 at 07:48
  • I'm not downloading a playlist, I'm downloading an ENTIRE YouTube channel consisting of about 10,000 videos. The -c or -i will not help in my problem. –  Oct 20 '16 at 16:34
  • Forget the last sentence of my previous comment. I'm gonna try and see if it works with -c or -i. This is my command now –  Oct 20 '16 at 16:36
  • >youtube-dl -f bestvideo+bestaudio ytuser:lylehsaxon -o "/Videos/lhs/[%(upload_date)s - %(id)s] %(title)s.%(ext)s" --ffmpeg-location %CD%\ffmpeg\bin -c -i –  Oct 20 '16 at 16:37
  • Put the -c and the -i in the same place where I put it in the first command in my answer. – karel Oct 20 '16 at 17:07
  • Will do. Does it change anything? –  Oct 20 '16 at 17:19
4

If you look youtube-dl man page you will see option to resume partial downloads.

-c, --continue
           Resume partially downloaded files.

Man Page Link

Raja G
  • 557
  • 2
  • 6
  • 16
  • Yes I saw that and that is not what I'm looking for. When hits the errors I mentioned above, it completely stops and I have to manually restart it. I'm looking for something that will automatically restart it. –  Oct 20 '16 at 05:15
  • Ok I will write code hang on..I m in travel. In mean time study about bash if , pgrep and crontab. – Raja G Oct 20 '16 at 05:56
  • I forgot to mention. I'm on Windows 10, not Ubuntu. So a bat file will be needed I know a bit about scripts but not too much. –  Oct 20 '16 at 07:32
  • 1
    @INeedHelp101: Windows is off-topic here, so no, you will not receive a BAT file, only shell scripts – Fabby Oct 20 '16 at 07:47
1

Perhaps this argument didn't exist when the question was asked, but using

--ignore-errors

will 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.log

will 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.

Nawor3565
  • 11
  • 1
0

you should use the option "--download-archive". That will skip already downloaded videos from your playlist/channel.

  • 2
    Please be a little more specific with your detail, consider adding some reference and proof supporting what you state, and confirm this answer is not already answered in one of the existing answers on the post. – Vomit IT - Chunky Mess Style Sep 05 '17 at 01:56
0

A helpful script: youtube_channel_archiver

Motsel
  • 840
  • 6
  • 10
0

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.

pbies
  • 2,757
  • 3
  • 21
  • 23