youtube-dl, how do I resume a download after error?

I am using youtube-dl to download videos from Lynda (I have an account).

After about the 40th video in a list I received this error:

ERROR: Unable to download JSON metadata: HTTP Error 403: Forbidden

Is there a way to 'restart' the downloads so I don't have to start from the first file again? Say just tell it to start from file 41 or something?

This is the command I used to download:

./youtube-dl --cookies cookies.txt --username <myusername> --password <mypassword> --sleep-interval 200 -o "%(autonumber)s - %(title)s.%(ext)s” http://www.lynda.com/C-tutorials/C-Essential-Training/188207-2.html

Solution 1:

It's good to use a combination of -ciw when downloading playlists.

-i, --ignore-errors    Continue on download errors, for example to skip
                       unavailable videos in a playlist
-w, --no-overwrites    Do not overwrite files
-c, --continue         Force resume of partially downloaded files.
                       By default, youtube-dl will resume downloads if possible.

The following example downloads top 100 songs on YouTube Music

youtube-dl -ciw --playlist-items 1-100 --extract-audio --audio-format mp3 --restrict-filenames https://www.youtube.com/playlist?list=PLDcnymzs18LWrKzHmzrGH1JzLBqrHi3xQ

The actual link to Youtube Music playlist varies with time, I guess. You can go the the playlist and copy. One way to check whether a link refers to a playlist or a single video, is that the playlist link has "playlist" keyword in it.

Solution 2:

You can continue the download using:

youtube-dl <link_to_video> -c

Or

youtube-dl <link_to_video> --continue

Also, youtube-dl mostly continues the download whenever possible

Solution 3:

Download specific videos from playlist This is yet another useful feature of Youtube-dl. It allows us to download a specific song(s) from a playlist that contains 100s of songs.

For example, to download the 10th file from a playlist, run:

$ youtube-dl --playlist-items 10 <playlist_url>

Similarly, to download multiple random files, just specify indices of the videos in the playlist separated by commas like below::

$ youtube-dl --playlist-items 2,3,7,10 <playlist_url>

You can also specify the range of songs. To download a video playlist starting from a certain video, say 10, to end:

$ youtube-dl --playlist-start 10 <playlist_url>

To download only the files starting from 2nd to 5th in a playlist, use:

$ youtube-dl --playlist-start 2 --playlist-end 5 <playlist_url>

You should do like this if it is a playlist with 200 videos and it stuck at the 127 also use the -ciw in the same order below to avoid it from stop during errors.

 youtube-dl -ciw --playlist-start 127 <then past the playlist link after the 127>

To download only the audio from the video do this

youtube-dl -ciw -x --audio-format mp3 --playlist-start 127 <then past the playlist link after the 127>

for example:

youtube-dl -ciw -x --audio-format mp3 --playlist-start 127 https://www.youtube.com/playlist?list=PLjzdNLPsCsPeeO49mvhHP5uyKdYkAbON8

Solution 4:

You can resume a video with -c option. For instance, if you previously started a download using:

youtube-dl <some_youtube_URL>

You may, if it was stopped or interrupted, resume that download later with:

youtube-dl -c <some_youtube_URL>