So I'm trying to download an entire youtube channel using youtube-dl. I know that if you use the -F command, it gives you a list of the quality type of the videos. My question is this: how to download the best quality of all the videos so the download doesnt default to 460p or something low like that.
This answer won't work on older versions of youtube-dl. You need to update youtube-dl to the latest version. You can either install the latest version of youtube-dl locally inside a Python virtual environment (virtualenv), or you can download the latest version of youtube-dl and install it with
pip
(sudo apt remove youtube-dl && sudo apt install python-pip && pip install --user youtube-dl
). youtube-dl is also a snap package. To install it type:Open the terminal and type:
...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
TL;DR use the
-f 'bestvideo[height>=720]+bestaudio/best'
flag to get a higher resolution. The full command I used is:youtube-dl -f "bestvideo[height>=720]+bestaudio/best" -ciw -o "%(title)s.%(ext)s" -v <url-of-channel>
Here is why
-f best
might not give you the highest resolution.When you use the
-F
flag to list the possible file formats, sometimes it lists a 360p format as "best", for example:As you can see the last option is listed as the best despite it's low resolution. There are a few ways we can get around this, I was trying to download from a channel that uploads in 720p so the easiest way was for me to use the
-f 'bestvideo[height>=720]+bestaudio/best'
flag.Depending on your situation you might have to play with the format selector expression, perhaps either increasing it from 720 to 1080 or selecting a specific file format like mp4.
To see other format selector examples
To see a full breakdown of the options
You will need to install ffmpeg or convert from mkv.
The other two answers provide a good way to download all the videos from a youtube channel, but something that might come up is wanting to re-download the videos from a channel to get new videos they might have posted.
youtube-dl
comes with an option which allows for this called--download-archive
, it allows you to give a file which stores the videos you've already downloaded and then makes sure not to re-download them. It also writes to this file as it downloads new videos.First we have to create this file for the videos we've already downloaded:
create_download_list.sh
:Now when you want to fetch new videos from the channel, you would just have to run:
You can use this with
youtube-dl
.But I recommend
yt-dlp
, it provides better download speed.Example of Batch script for Windows.
Can be also adapted for Linux Bash.
Inspiration from Linux Bash script https://askubuntu.com/a/1022993/803975