74

I use youtube-dl to download files from YouTube. I have tried downloading multiple files, but it is not working out for me. I have to open multiple terminals and start afresh every time I want to download a video.

Can you help me to download multiple files with a single terminal window by just mentioning all the URLs at once? I use Ubuntu 12.04 64-bit.

2
  • 2
    Not an answer to your question but others may stumble on this. If the videos are related in some way, remember that youtube-dl can download all videos from a playlist, user, or channel.
    – Dennis
    Jun 13, 2015 at 1:55
  • 2
    see the answer below (not the most upvoted currently) suggesting just adding a space between url's and you're done.
    – gota
    Sep 8, 2017 at 21:36

11 Answers 11

74

Shortcuts

If all of the videos are in the same playlist or the same channel, you can save time by using the following shortcuts.

Playlist

youtube-dl -f FORMAT -ciw -o "%(title)s.%(ext)s" -v <url-of-playlist>

...where <url-of-playlist> is replaced by the URL of the playlist and replace FORMAT with any available video format, for example 18. You can use the -F option to see all valid formats like this:

youtube-dl -F 'http://www.youtube.com/some-alphanumeric-string'

Download part of a playlist from start of batch to end of batch

youtube-dl -f FORMAT -ci --playlist-start NUMBER --playlist-end NUMBER <url-of-playlist>  

...where <url-of-playlist> is replaced by the URL of the playlist, replace FORMAT with any available video format, for example 18, and NUMBER is the number of the video in the playlist to start/end downloading at.

Channel

youtube-dl -f FORMAT -ciw -o "%(title)s.%(ext)s" -v <url-of-channel>

...where <url-of-channel> is replaced by the URL of the channel and replace FORMAT with any available video format, for example 18.

Videos not in the same playlist or channel

First create a batch file which is a text file containing a list of URLs of videos from YouTube that you want to download. The URLs should be arranged in a list having only one URL and nothing else on each line, with a new line for each URL in the list. Save the batch file with a name that is easy to remember like batch-file.txt. If the multiple files are all on the same playlist, channel or user webpage in YouTube, you can generate a text file with a list that has all the links on that page by running the following command:

sudo apt install jq  
youtube-dl -j --flat-playlist "https://<yourYoutubeWebpage>" | jq -r '.id' | sed 's_^_https://youtu.be/_' > batch-file.txt

From the terminal run:

youtube-dl -ct --simulate --batch-file='/path/to/batch-file.txt'

This is the basic command, however you also need to add the formats of the videos that you want to download or else you may find yourself downloading videos with formats that you didn't want. So first simulate your download to see if the format you want is available:

youtube-dl -ct -f 34 --simulate 'http://www.youtube.com/some-alphanumeric-string'

If the video format is not available you will get an error message that says: requested format not available. If the video format is available you will not get any error message when you use the --simulate option. You can also add the -F option to see all valid formats like this:

youtube-dl -F 'http://www.youtube.com/some-alphanumeric-string'

In the third command I have used the common flv 360p video format:
-f 34. You might prefer to try the flv 480p video format by using -f 35. So after you have added the video format that you want to the command, the command becomes something like this:

youtube-dl -ciw -o "%(title)s.%(ext)s" --batch-file='/path/to/batch-file.txt'

Notes:

I didn't add the --simulate option to the last command, so this command would be executed for real.

1
  • So long, honestly would have preferred a shorter answer. I composited yours and someone else.
    – MrMesees
    Jun 12, 2020 at 14:53
42

You can put the urls one after another, with a space in between. Youtube-dl will download them sequentially. This is a bit simpler than making a batch file.

Notice the --help says youtube-dl --help Usage: youtube-dl [options] url [url...]

Sample input:

youtube-dl http://www.youtube.com/watch?v=fqULJBBEVQE http://www.youtube.com/watch?v=vDbbz-BdyYc http://www.youtube.com/watch?v=OrIFaWJ9Glo

Sample output:

    [youtube] Setting language
    [youtube] fqULJBBEVQE: Downloading video webpage
    [youtube] fqULJBBEVQE: Downloading video info webpage
    [youtube] fqULJBBEVQE: Extracting video information
    [download] Destination: Web Components - A Tectonic Shift for Web Development - Google I_O 2013-fqULJBBEVQE.mp4
    [download] 100% of 238.14MiB in 36:54
    [youtube] vDbbz-BdyYc: Downloading video webpage
    [youtube] vDbbz-BdyYc: Downloading video info webpage
    [youtube] vDbbz-BdyYc: Extracting video information
    [download] Paul Irish on Web Application Development Workflow-vDbbz-BdyYc.mp4 has already been downloaded
    [youtube] OrIFaWJ9Glo: Downloading video webpage
    [youtube] OrIFaWJ9Glo: Downloading video info webpage
    [youtube] OrIFaWJ9Glo: Extracting video information
    [download] Got server HTTP error. Retrying (attempt 1 of 20)...
    [download] Destination: Single Page Web Applications - JavaScript End-to-End (The Hard Stuff)-OrIFaWJ9Glo.mp4
    [download] 100% of 553.10MiB in 42:17
0
15

To download multiple files from YouTube

  1. Go to your desktop and make a text document called list (or any other name). Copy and paste the URLs if files you want to download into the file, one URL per line.

  2. Open terminal and go to desktop

    cd ~/Desktop
    
  3. To download the files on your list, type (replace list accordingly if you named your file something else)

    youtube-dl -a list
    

To download a YouTube playlist

Run this command

youtube-dl -citk -format mp4 -yes-playlist VIDEO_PLAYLIST_LINK
  • -c resume partially downloaded files
  • -i ignore any errors.
  • -t use the video title as the file name.
  • -k keep the video on the disk after the post-processing is finished.
  • --format mp4 save the video files as MP4 files.
  • --yes-playlist affirms that the URL that follows points to a video playlist.
2
  • 2
    -citk is very misleading, and can lead to errors. -c forces resuming, even if it doesn't make much sense. The default is already to continue. -i might be ok, but beware that you may miss errors on some videos. -t is already the default, and deprecated. -k makes no sense with -f mp4. See the youtube-dl FAQ for more details.
    – phihag
    Jan 24, 2018 at 15:02
  • Please, anyone having enough rep/permissions ( @pomsky ), please correct -format mp4 -yes-playlist to --format mp4 --yes-playlist, it is two-characters edit and I can't do it myself for obvious reasons. Jun 3, 2022 at 18:44
7

most straightforward solution would be make a bash script like this

#!/bin/bash
terminal=`tty`
exec < ~/Documents/youtubevideolinks.txt

while read -r line
do
    cd ~/Desktop/TilakDa/
    youtube-dl -f 18 "$line"
done
exec < "$terminal"

just copy and paste the the video links in that txt file in documents folder with each video url in a new line and run this script it will download the videos one by one By default the -f 18option is for 360p video

1
  • 1
    This is not the most straightforward at all. There is now (I don't know how long it's been there) a --batch-file script which takes one line of a text file as a url
    – MrMesees
    Jun 12, 2020 at 14:54
7

youtube-dl -cit --format=mp4 --batch-file=./list-of-youtube-videos-link.txt was what worked for me combining https://askubuntu.com/a/947676/481688 and https://askubuntu.com/a/334097/481688 solutions. I'm recording it here standalone rather than scroll multiple answers again in future.

  • --batch-file=./list-of-youtube-videos-link.txt file with a list of youtube links
  • --format=mp4 mp4 format output desired
  • -c resume partially downloaded files
  • -i ignore any errors.
  • -t use the video title as the file name.
3

If you have multiple video URLs just add them in one playlist into your YouTube Playlist by creating a new one or using an existing one.

Then use command below.

youtube-dl -f FORMAT --yes-playlist [url-of-playlist]

The option --yes-playlist will download the playlist, if the URL refers to a video and a playlist.

This is the simplest and quickest option I found for my purpose of downloading hundreds of videos from a website which had videos linked from YouTube.

1
  • This is useful for downloading a lot of videos from the same channel. You can use an unlisted playlist to not make it public
    – qwr
    Apr 23, 2018 at 18:39
3

To download multiple videos you can use this structure. It's similar to @coreyb's response with the addition that you can use it elsewhere in bash, for example with echo. Here are two ways:

Braces

youtube-dl -f FORMAT {url1,url2,url...}

Repeat the last command without the last argument

youtube-dl -f FORMAT url1; !:- url2; !:-url...
3

Try with bash script:

while read LL ; do youtube-dl "$LL" ; done < your_file
1

Type the command and then type && and type the next command like:

youtube-dl--add-metadata -xic http://(the url) && youtube-dl--add-metadata -xic http://(the url) 
1

Topic is still relevant, so:

  • Get your YouTube link.
  • Remove the first video parameter starting with ?
  • use like this :-)

    youtube-dl.exe --yes-playlist https://www.youtube.com/watch?list=yourlistlink
    

This works for me.

0
0

youtube-dl --retry-sleep fragment:exp=1:20 --write-subs --write-auto-subs --batch-file file_name.txt

Evades by different sleep times

downloads subtitiles, auto generated ones

batch mode of multiple youtube links some playlists some videos

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .