youtube-dl 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

youtube-dl 命令安装:


-bash: youtube-dl: command not found

#Debian
apt-get install youtube-dl

#Ubuntu
apt-get install youtube-dl

#Alpine
apk add youtube-dl

#Arch Linux
pacman -S youtube-dl

#Kali Linux
apt-get install youtube-dl

#Fedora
dnf install youtube-dl

#OS X
brew install youtube-dl

#Raspbian
apt-get install youtube-dl

#Docker
docker run cmd.cat/youtube-dl youtube-dl

#Windows
https://yt-dl.org/latest/youtube-dl.exe

youtube-dl 命令补充说明:


youtube-dl 命令从 YouTube (油管)和其他网站下载视频。官网主页:http://rg3.github.io/youtube-dl

Youtube-dl 是一个开源的 Python 命令行工具,可用于下载上千个视频网站的视频内容,它可以保存视频 MP4 和其他提供的格式,也可以仅提取音轨,用途十分广泛。此前该项目曾因涉嫌违反美国版权法被美国唱片业协会 RIAA 投诉下架,在众多开发者的争取下,该项目仓库最终得以恢复。

youtube-dl 命令语法:


youtube-dl [OPTIONS] URL [URL...]

youtube-dl 命令选项:


-h, --help                       Print this help text and exit
--version                        Print program version and exit
-U, --update                     Update this program to latest version. Make
                                 sure that you have sufficient permissions
                                 (run with sudo if needed)
-i, --ignore-errors              Continue on download errors, for example to
                                 skip unavailable videos in a playlist
--abort-on-error                 Abort downloading of further videos (in the
                                 playlist or the command line) if an error
                                 occurs
--dump-user-agent                Display the current browser identification
--list-extractors                List all supported extractors
--extractor-descriptions         Output descriptions of all supported
                                 extractors
--force-generic-extractor        Force extraction to use the generic
                                 extractor
--default-search PREFIX          Use this prefix for unqualified URLs. For
                                 example "gvsearch2:" downloads two videos
                                 from google videos for youtube-dl "large
                                 apple". Use the value "auto" to let
                                 youtube-dl guess ("auto_warning" to emit a
                                 warning when guessing). "error" just throws
                                 an error. The default value "fixup_error"
                                 repairs broken URLs, but emits an error if
                                 this is not possible instead of searching.
--ignore-config                  Do not read configuration files. When given
                                 in the global configuration file
                                 /etc/youtube-dl.conf: Do not read the user
                                 configuration in ~/.config/youtube-
                                 dl/config (%APPDATA%/youtube-dl/config.txt
                                 on Windows)
--config-location PATH           Location of the configuration file; either
                                 the path to the config or its containing
                                 directory.
--flat-playlist                  Do not extract the videos of a playlist,
                                 only list them.
--mark-watched                   Mark videos watched (YouTube only)
--no-mark-watched                Do not mark videos watched (YouTube only)
--no-color                       Do not emit color codes in output

youtube-dl 命令参数:


要下载的视频 URL 网址

youtube-dl 命令实例:


youtube-dl 下载视频或播放列表:

youtube-dl https://www.youtube.com/watch?v=oHg5SJYRHA0

youtube-dl 从视频下载音频并将其转换为 MP3

youtube-dl -x --audio-format mp3 url

youtube-dl 将视频下载为具有自定义文件名的 MP4 文件:

youtube-dl --format mp4 -o "%(title)s by %(uploader)s on %(upload_date)s in %(playlist)s.%(ext)s" url

youtube-dl 下载视频并保存其描述,元数据,注释,字幕和缩略图:

youtube-dl --write-description --write-info-json --write-annotations --write-sub --write-thumbnail url

youtube-dl 从播放列表中下载所有未标记为 NSFW 或年龄限制为7岁的 Let's Play 视频:

youtube-dl --match-title "let's play" --age-limit 7 --reject-title "nsfw" playlist_url

youtube-dl 命令扩展阅读:




youtube-dl 命令评论