TransWikia.com

using youtube-dl to download entire youtube channel

Ask Ubuntu Asked by Sam Vega on January 2, 2021

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.

2 Answers

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:

sudo snap install 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

-o, --output
    Output filename template, this example functions similarly to the old --title option

-v, --verbose
    print various debugging information

Correct answer by karel on January 2, 2021

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:

youtube-dl -F https://www.youtube.com/watch?v=FmZXCqqx6q0
[youtube] FmZXCqqx6q0: Downloading webpage
[info] Available formats for FmZXCqqx6q0:
format code  extension  resolution note
249    webm   audio only tiny   61k , opus @ 50k (48000Hz), 12.74MiB
250    webm   audio only tiny   80k , opus @ 70k (48000Hz), 16.87MiB
140    m4a    audio only tiny  132k , m4a_dash container, mp4a.40.2@128k (44100Hz), 31.35MiB
251    webm   audio only tiny  158k , opus @160k (48000Hz), 33.34MiB
...
244    webm   854x480    480p  271k , vp9, 30fps, video only, 35.05MiB
398    mp4    1280x720   720p  443k , av01.0.05M.08, 30fps, video only, 102.27MiB
247    webm   1280x720   720p  480k , vp9, 30fps, video only, 63.02MiB
136    mp4    1280x720   720p  489k , avc1.4d401f, 30fps, video only, 114.12MiB
18     mp4    640x360    360p  360k , avc1.42001E, 30fps, mp4a.40.2@ 96k (44100Hz), 87.29MiB (best)

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.

Answered by smile-eh on January 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP