Development

Downloading a YouTube channel with yt-dlp

Downloading whole YouTube channels using the yt-dlp tool, with specifying video quality and format types.

For a general run down and usage guide on yt-dlp go here.

Downloaded video format

Go to the bottom for the full yt-dlp command, this just breaks down each part.

Start by calling yt-dlp and then giving the format options for the videos

yt-dlp -f 'bv*[height=720]+ba'

'bv*[height=720]+ba' this is 720p best video format with the best audio combined.

Other option examples:

'bv[height=1080][ext=mp4]+ba[ext=m4a]' 1080p mp4 video combined with best m4a audio.

best select the best format that contains both video and audio.

'bv*[height<720]+ba' Best video format under 720p combined with the best audio.

View yt-dlp the formating docs here.

The archive list

When downloading a channel (or playlist) you want to list what videos you already have downloaded to avoid repetitively downloading them.

An archive list can be done with the download archive parameter where you state the file to save the downloaded  video id’s in

--download-archive the_list.txt

Saving the videos

Now for the save folder and filename options with string formatting. In the example below it will be channel name/video title.extension

-o '%(channel)s/%(title)s.%(ext)s'

Other handy options include %(channel_id)s for the channel id string and %(id)s the video id string.

By using %(ext)s makes yt-dlp choose the extension based on the format parameters provided at the start.

Thumbnail and metadata

If you wish you can save the thumbnail image and the video metadata to the file. Note .webm cannot have the thumbnail embedded, instead .mkv will be used.

--embed-thumbnail --embed-metadata

The final command

Here is the full command using the parts above:

yt-dlp -f 'bv*[height>=720]+ba' --embed-thumbnail --embed-metadata --download-archive FootheFlowerhorn.txt https://www.youtube.com/c/FootheFlowerhorn/videos -o '%(channel)s/%(title)s.%(ext)s'

It will download FootheFlowerhorn YouTube channel into FootheFlowerhorn/ with the filename being the title of the video. The videos will be the best quality equal to or greater than 720p combined with the best audio.

 

Share

Recent Posts

Kennington reservoir drained drone images

A drained and empty Kennington reservoir images from a drone in early July 2024. The…

1 year ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

1 year ago

FTP getting array of file details such as size using PHP

Using FTP and PHP to get an array of file details such as size and…

2 years ago

Creating Laravel form requests

Creating and using Laravel form requests to create cleaner code, separation and reusability for your…

2 years ago

Improving the default Laravel login and register views

Improving the default Laravel login and register views in such a simple manner but making…

2 years ago

Laravel validation for checking if value exists in the database

Laravel validation for checking if a field value exists in the database. The validation rule…

2 years ago