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.
Use youtube-dl
command to download videos straight off of YouTube.
To install youtube-dl
either
Use pip
to install from the official youtube-dl
channel's:
sudo apt install pip
pip install youtube-dl
Or, use the Debian package manager and an appropriate PPA (source):
sudo add-apt-repository ppa:nilarimogard/webupd8 -y
sudo apt update
sudo apt install youtube-dl
If you're getting errors, try upgrading youtube-dl
to the latest version (depending on the method of installation):
pip install --upgrade youtube-dl
sudo apt update && sudo apt upgrade youtube-dl
To download an entire channel
youtube-dl https://www.youtube.com/user/ChannelFoo
To download all videos on a playlist
youtube-dl https://www.youtube.com/user/ChannelFoo/playlist
To download a YouTube video as an MP3
youtube-dl -x --audio-format mp3 --audio-quality 320K <VIDEO_URL>
Best Answer
You need to create the config file yourself, it's not created by installation of the program.
Just save from your editor to
~/.config/youtube-dl.conf
(note no dash in.config
).The system-wide default configuration file,
/etc/youtube-dl.conf
, could be created by installing, but is not. That's not a problem, as the file format is not complicated, so an example file is not important.Not sure what exactly you are doing, but if it's about repeating the download command with a different url, try using the shell history, pressing Up to recall the command, and edit the file name.
(To show your Ubuntu version, use
lsb_release -a
)