yt-dlp

From Gentoo Wiki
Jump to:navigation Jump to:search
This article is a stub. Please help out by expanding it - how to get started.

yt-dlp is a youtube-dl fork based on the now inactive youtube-dlc. The main focus of this project is adding new features and patches while also keeping up to date with the original project.

Installation

USE flags

USE flags for net-misc/yt-dlp youtube-dl fork with additional features and fixes

man Build and install man pages
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)

Emerge

root #emerge --ask net-misc/yt-dlp

Usage

Downloading a video

The easiest way to download a video from YouTube with yt-dlp is by passing it as the only argument:

Output format

To output the video in a different format, use the -f,--format flags:

Extracting audio

To download just the audio of a video, use -x,--extract-audio:

Or, if a format other than .opus is required, use --audio-format

user $yt-dlp -x --audio-format mp3 https://www.youtube.com/watch?v=t09IbcxAJlU

Adding metadata

To add chapters and infojson to a downloaded video, use --embed-metadata:

user $yt-dlp --embed-metadata https://www.youtube.com/watch?v=t09IbcxAJlU

Subtitles

To list available subtiles for a video, use --list-subs:

If a video provides subtitles then the ones provided by the channel will be listed below the auto-generated ones by YouTube.

Downloading a video with subtitles can then be done using --write-subs/--write-auto-subs if the manual or auto-generated subtitles wish to be used, respectively.

user $yt-dlp --write-subs/--write-auto-subs --sub-lang en https://www.youtube.com/watch?v=t09IbcxAJlU
Note
The default subtitle language is English

Configuration

yt-dlp's system-wide configuration files are located at: /etc/yt-dlp.conf, /etc/yt-dlp/config, /etc/yt-dlp/config.txt and the recommended path for user configuration is ${XDG_CONFIG_HOME}/yt-dlp/config

Default arguments

Adding default arguments to yt-dlp can be done by using the configuration file, for example, in ${XDG_CONFIG_HOME}/yt-dlp/config

FILE ${XDG_CONFIG_HOME}/yt-dlp/config
# Lines starting with # are comments

# Always extract audio
-x

# Do not copy the mtime
--no-mtime

# Use this proxy
--proxy 127.0.0.1:3128

# Save all videos under YouTube directory in your home directory
-o ~/YouTube/%(title)s.%(ext)s

Encoding

The default encoding yt-dlp uses for configuration files is UTC BOM, if that is not present then the system locale.

To use a encoding format other than these, add the comment # coding: ENCODING to the top of the configuration file.