yt-dlp 是一個功能豐富的命令列音訊/視訊下載器,支援數千個網站。該專案是 youtube-dl 的一個分支,基於現在不活動的 youtube-dlc。
安裝
詳細說明
發布文件
更新
依賴關係
編譯
用途和選項
一般選項
網路選項
地理限制
影片選擇
下載選項
檔案系統選項
縮圖選項
網路快捷方式選項
冗長和模擬選項
解決方法
視訊格式選項
字幕選項
身份驗證選項
後處理選項
贊助區塊選項
提取器選項
配置
設定檔編碼
使用 netrc 進行身份驗證
關於環境變數的注意事項
輸出模板
輸出範本範例
格式選擇
過濾格式
排序格式
格式選擇範例
修改元數據
修改元資料範例
提取器參數
外掛
安裝插件
開發外掛
嵌入YT-DLP
嵌入範例
YouTube-DL 的變更
新功能
預設行為的差異
已棄用的選項
貢獻
提出問題
開發者說明
維基百科
常問問題
您可以使用二進位檔案、pip 或使用第三方套件管理器安裝 yt-dlp。請參閱 wiki 以了解詳細說明
| 文件 | 描述 |
|---|---|
| yt-dlp | 獨立於平台的 zipimport 二進位。需要Python(建議用於Linux/BSD ) |
| yt-dlp.exe | Windows (Win8+) 獨立 x64 二進位檔案(建議用於Windows ) |
| yt-dlp_macos | 通用 MacOS (10.15+) 獨立執行檔(推薦用於MacOS ) |
| 文件 | 描述 |
|---|---|
| yt-dlp_x86.exe | Windows (Win8+) 獨立 x86(32 位元)二進位文件 |
| yt-dlp_linux | Linux 獨立 x64 二進位文件 |
| yt-dlp_linux_armv7l | Linux 獨立armv7l(32位元)二進位文件 |
| yt-dlp_linux_aarch64 | Linux 獨立 aarch64(64 位元)二進位文件 |
| yt-dlp_win.zip | 未打包的 Windows 可執行檔(無自動更新) |
| yt-dlp_macos.zip | 未打包的 MacOS (10.15+) 可執行檔(無自動更新) |
| yt-dlp_macos_legacy | MacOS (10.9+) 獨立 x64 執行檔 |
| 文件 | 描述 |
|---|---|
| yt-dlp.tar.gz | 原始碼包 |
| SHA2-512SUMS | GNU 風格 SHA512 求和 |
| SHA2-512SUMS.sig | SHA512 和的 GPG 簽署文件 |
| SHA2-256SUMS | GNU 風格 SHA256 求和 |
| SHA2-256SUMS.sig | SHA256 和的 GPG 簽章文件 |
可用於驗證 GPG 簽署的公鑰可在此處找到範例用法:
curl -L https://github.com/yt-dlp/yt-dlp/raw/master/public.key | gpg --import gpg --verify SHA2-256SUMS.sig SHA2-256SUMS gpg --verify SHA2-512SUMS.sig SHA2-512SUMS
注意:手冊頁、shell 完成(自動完成)檔案等可在來源 tarball 中找到
如果您使用的是發布二進位文件,則可以使用yt-dlp -U進行更新
如果您使用 pip 安裝,只需重新執行用於安裝程式的相同命令
對於其他第三方套件管理器,請參閱 wiki 或參考他們的文檔
目前二進位檔案有三個發布管道: stable 、 nightly和master 。
stable是預設頻道,其許多更改已經過nightly和master頻道的用戶測試。
該nightly頻道計劃每天在 UTC 午夜左右發布版本,以獲取該項目的新補丁和更改的快照。這是向 yt-dlp 普通用戶推薦的頻道。 nightly版本可從 yt-dlp/yt-dlp-nightly-builds 獲取,或作為yt-dlp PyPI 套件的開發版本(可以使用 pip 的--pre標誌安裝)。
master通道的功能是在每次推送到主分支後建立的版本,這些版本將具有最新的修復和添加,但也可能更容易出現回歸。它們可從 yt-dlp/yt-dlp-master-builds 取得。
當使用--update / -U時,發布二進位檔案將僅更新到其目前通道。 --update-to CHANNEL可用於在有新版本可用時切換到不同的頻道。 --update-to [CHANNEL@]TAG也可用於從通道升級或降級到特定標籤。
您也可以使用--update-to <repository> ( <owner>/<repository> ) 更新到完全不同的儲存庫上的通道。不過,要小心您要更新到的儲存庫,因為不會對來自不同儲存庫的二進位檔案進行驗證。
用法範例:
yt-dlp --update-to master切換到master通道並更新到其最新版本
yt-dlp --update-to [email protected]升級/降級以發佈到stable頻道標籤2023.07.06
yt-dlp --update-to 2023.10.07升級/降級到標籤2023.10.07 (如果目前頻道存在)
yt-dlp --update-to example/[email protected]從example/yt-dlp儲存庫升級/降級到版本,標籤2023.09.24
重要提示:任何遇到stable版本問題的使用者都應在提交錯誤報告之前安裝或更新到nightly版本:
# To update to nightly from stable executable/binary: yt-dlp --update-to nightly # To install nightly with pip: python3 -m pip install -U --pre "yt-dlp[default]"
支援 Python 版本 3.9+ (CPython) 和 3.10+ (PyPy)。其他版本和實作可能會或可能不會正常運作。
雖然所有其他依賴項都是可選的,但強烈建議使用ffmpeg和ffprobe
ffmpeg和ffprobe - 合併單獨的視訊和音訊檔案以及各種後處理任務所需的。許可證取決於構建
ffmpeg 中存在一些錯誤,當與 yt-dlp 一起使用時會導致各種問題。由於 ffmpeg 是一個非常重要的依賴項,因此我們在 yt-dlp/FFmpeg-Builds 上為其中一些問題提供了帶有修補程式的自訂建置。有關這些構建解決的具體問題的詳細信息,請參閱自述文件
重要提示:您需要的是 ffmpeg二進位文件,而不是同名的 Python 包
certifi * - 提供 Mozilla 的根證書包。根據 MPLv2 獲得許可
brotli * 或brotlicffi - Brotli 內容編碼支援。均獲得 MIT 1 2許可
websockets * - 用於透過 websocket 下載。根據 BSD-3 條款獲得許可
請求* - HTTP 庫。用於 HTTPS 代理和持久連接支援。已獲得 Apache-2.0 許可
以下提供了對模擬瀏覽器請求的支援。對於某些使用 TLS 指紋辨識的網站來說,這可能是必要的。
curl_cffi (建議) - 用於curl 模擬的Python 綁定。為 Chrome、Edge 和 Safari 提供模擬目標。獲得麻省理工學院許可
可與curl-cffi群組一起安裝,例如pip install "yt-dlp[default,curl-cffi]"
目前包含在yt-dlp.exe 、 yt-dlp_linux和yt-dlp_macos版本中
誘變劑* - 對於某些格式的--embed-thumbnail 。根據 GPLv2+ 許可
AtomicParsley - 當mutagen / ffmpeg不能時,用於mp4 / m4a檔案中的--embed-thumbnail 。根據 GPLv2+ 許可
xattr 、 pyxattr或setfattr - 用於在Mac和BSD上寫入 xattr 元資料 ( --xattr )。分別獲得 MIT、LGPL2.1 和 GPLv2+ 許可
pycryptodomex * - 用於解密 AES-128 HLS 流和各種其他資料。根據 BSD-2 條款獲得許可
phantomjs - 用於需要運行 javascript 的提取器。根據 BSD-3 條款獲得許可
Secretstorage * - 用於--cookies-from-browser在Linux上解密基於Chromium的瀏覽器的 cookie 時存取Gnome金鑰環。根據 BSD-3 條款獲得許可
您想要與--downloader一起使用的任何外部下載器
avconv和avprobe - 現已棄用ffmpeg 的替代品。許可證取決於構建
sponskrub - 用於使用現已棄用的sponskrub 選項。根據 GPLv3+ 許可
rtmpdump - 用於下載rtmp串流。 ffmpeg 可以與--downloader ffmpeg一起使用。根據 GPLv2+ 許可
mplayer或mpv - 用於下載rstp / mms串流。 ffmpeg 可以與--downloader ffmpeg一起使用。根據 GPLv2+ 許可
若要使用或重新散佈依賴項,您必須同意其各自的授權條款。
獨立版本的二進位檔案是使用 Python 解釋器建構的,並且包含標有*的套件。
如果您沒有嘗試執行的任務所需的依賴項,yt-dlp 將向您發出警告。所有目前可用的依賴項都在--verbose輸出的頂部可見
要建立獨立的可執行文件,您必須擁有 Python 和pyinstaller (如果需要,也可以加上 yt-dlp 的任何可選依賴項)。可執行檔將針對與所使用的 Python 相同的 CPU 架構而建置。
您可以執行以下命令:
python3 devscripts/install_deps.py --include pyinstaller python3 devscripts/make_lazy_extractors.py python3 -m bundle.pyinstaller
在某些系統上,您可能需要使用py或python而不是python3 。
python -m bundle.pyinstaller接受任何可以傳遞給pyinstaller參數,例如--onefile/-F或--onedir/-D ,此處有進一步記錄。
注意:4.4 以下的 Pyinstaller 版本不支援在不使用虛擬環境的情況下從 Windows 商店安裝 Python。
重要提示:官方不支援直接運行pyinstaller而不是使用python -m bundle.pyinstaller 。這可能會或可能不會正常工作。
您將需要建置工具python (3.9+)、 zip 、 make (GNU)、 pandoc * 和pytest *。
安裝這些後,只需運行make即可。
您也可以執行make yt-dlp來僅編譯二進位文件,而不更新任何其他文件。 (不需要標示*的建置工具)
devscripts/install_deps.py - 安裝 yt-dlp 的依賴項。
devscripts/update-version.py - 根據目前日期更新版本號。
devscripts/set-variant.py - 設定可執行檔的建置變體。
devscripts/make_changelog.py - 使用短提交訊息建立 markdown 更改日誌並更新CONTRIBUTORS檔案。
devscripts/make_lazy_extractors.py - 建立惰性提取器。在建置二進位檔案(任何變體)之前執行此命令將提高其啟動效能。將環境變數YTDLP_NO_LAZY_EXTRACTORS設為非空值以強制停用延遲擷取器載入。
注意:請參閱他們的--help以獲取更多資訊。
如果您在 GitHub 上分叉該項目,則可以執行分叉的建置工作流程以自動將所選版本建置為工件。或者,您可以執行發布工作流程或啟用夜間工作流程來建立完整(預)版本。
yt-dlp [OPTIONS] [--] URL [URL...]
Ctrl+F是你的朋友 :D
-h, --help Print this help text and exit
--version Print program version and exit
-U, --update Update this program to the latest version
--no-update Do not check for updates (default)
--update-to [CHANNEL]@[TAG] Upgrade/downgrade to a specific version.
CHANNEL can be a repository as well. CHANNEL
and TAG default to "stable" and "latest"
respectively if omitted; See "UPDATE" for
details. Supported channels: stable,
nightly, master
-i, --ignore-errors Ignore download and postprocessing errors.
The download will be considered successful
even if the postprocessing fails
--no-abort-on-error Continue with next video on download errors;
e.g. to skip unavailable videos in a
playlist (default)
--abort-on-error Abort downloading of further videos if an
error occurs (Alias: --no-ignore-errors)
--dump-user-agent Display the current user-agent and exit
--list-extractors List all supported extractors and exit
--extractor-descriptions Output descriptions of all supported
extractors and exit
--use-extractors NAMES Extractor names to use separated by commas.
You can also use regexes, "all", "default"
and "end" (end URL matching); e.g. --ies
"holodex.*,end,youtube". Prefix the name
with a "-" to exclude it, e.g. --ies
default,-generic. Use --list-extractors for
a list of extractor names. (Alias: --ies)
--default-search PREFIX Use this prefix for unqualified URLs. E.g.
"gvsearch2:python" downloads two videos from
google videos for the search term "python".
Use the value "auto" to let yt-dlp 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 Don't load any more configuration files
except those given to --config-locations.
For backward compatibility, if this option
is found inside the system configuration
file, the user configuration is not loaded.
(Alias: --no-config)
--no-config-locations Do not load any custom configuration files
(default). When given inside a configuration
file, ignore all previous --config-locations
defined in the current file
--config-locations PATH Location of the main configuration file;
either the path to the config or its
containing directory ("-" for stdin). Can be
used multiple times and inside other
configuration files
--plugin-dirs PATH Path to an additional directory to search
for plugins. This option can be used
multiple times to add multiple directories.
Note that this currently only works for
extractor plugins; postprocessor plugins can
only be loaded from the default plugin
directories
--flat-playlist Do not extract the videos of a playlist,
only list them
--no-flat-playlist Fully extract the videos of a playlist
(default)
--live-from-start Download livestreams from the start.
Currently only supported for YouTube
(Experimental)
--no-live-from-start Download livestreams from the current time
(default)
--wait-for-video MIN[-MAX] Wait for scheduled streams to become
available. Pass the minimum number of
seconds (or range) to wait between retries
--no-wait-for-video Do not wait for scheduled streams (default)
--mark-watched Mark videos watched (even with --simulate)
--no-mark-watched Do not mark videos watched (default)
--color [STREAM:]POLICY Whether to emit color codes in output,
optionally prefixed by the STREAM (stdout or
stderr) to apply the setting to. Can be one
of "always", "auto" (default), "never", or
"no_color" (use non color terminal
sequences). Use "auto-tty" or "no_color-tty"
to decide based on terminal support only.
Can be used multiple times
--compat-options OPTS Options that can help keep compatibility
with youtube-dl or youtube-dlc
configurations by reverting some of the
changes made in yt-dlp. See "Differences in
default behavior" for details
--alias ALIASES OPTIONS Create aliases for an option string. Unless
an alias starts with a dash "-", it is
prefixed with "--". Arguments are parsed
according to the Python string formatting
mini-language. E.g. --alias get-audio,-X
"-S=aext:{0},abr -x --audio-format {0}"
creates options "--get-audio" and "-X" that
takes an argument (ARG0) and expands to
"-S=aext:ARG0,abr -x --audio-format ARG0".
All defined aliases are listed in the --help
output. Alias options can trigger more
aliases; so be careful to avoid defining
recursive options. As a safety measure, each
alias may be triggered a maximum of 100
times. This option can be used multiple times--proxy URL Use the specified HTTP/HTTPS/SOCKS proxy. To enable SOCKS proxy, specify a proper scheme, e.g. socks5://user:[email protected]:1080/. Pass in an empty string (--proxy "") for direct connection --socket-timeout SECONDS Time to wait before giving up, in seconds --source-address IP Client-side IP address to bind to --impersonate CLIENT[:OS] Client to impersonate for requests. E.g. chrome, chrome-110, chrome:windows-10. Pass --impersonate="" to impersonate any client. Note that forcing impersonation for all requests may have a detrimental impact on download speed and stability --list-impersonate-targets List available clients to impersonate. -4, --force-ipv4 Make all connections via IPv4 -6, --force-ipv6 Make all connections via IPv6 --enable-file-urls Enable file:// URLs. This is disabled by default for security reasons.
--geo-verification-proxy URL Use this proxy to verify the IP address for some geo-restricted sites. The default proxy specified by --proxy (or none, if the option is not present) is used for the actual downloading --xff VALUE How to fake X-Forwarded-For HTTP header to try bypassing geographic restriction. One of "default" (only when known to be useful), "never", an IP block in CIDR notation, or a two-letter ISO 3166-2 country code
-I, --playlist-items ITEM_SPEC Comma separated playlist_index of the items to download. You can specify a range using "[START]:[STOP][:STEP]". For backward compatibility, START-STOP is also supported. Use negative indices to count from the right and negative STEP to download in reverse order. E.g. "-I 1:3,7,-5::2" used on a playlist of size 15 will download the items at index 1,2,3,7,11,13,15 --min-filesize SIZE Abort download if filesize is smaller than SIZE, e.g. 50k or 44.6M --max-filesize SIZE Abort download if filesize is larger than SIZE, e.g. 50k or 44.6M --date DATE Download only videos uploaded on this date. The date can be "YYYYMMDD" or in the format [now|today|yesterday][-N[day|week|month|year]]. E.g. "--date today-2weeks" downloads only videos uploaded on the same day two weeks ago --datebefore DATE Download only videos uploaded on or before this date. The date formats accepted are the same as --date --dateafter DATE Download only videos uploaded on or after this date. The date formats accepted are the same as --date --match-filters FILTER Generic video filter. Any "OUTPUT TEMPLATE" field can be compared with a number or a string using the operators defined in "Filtering Formats". You can also simply specify a field to match if the field is present, use "!field" to check if the field is not present, and "&" to check multiple conditions. Use a "" to escape "&" or quotes if needed. If used multiple times, the filter matches if at least one of the conditions is met. E.g. --match-filters !is_live --match-filters "like_count>?100 & description~='(?i)bcats & dogsb'" matches only videos that are not live OR those that have a like count more than 100 (or the like field is not available) and also has a description that contains the phrase "cats & dogs" (caseless). Use "--match-filters -" to interactively ask whether to download each video --no-match-filters Do not use any --match-filters (default) --break-match-filters FILTER Same as "--match-filters" but stops the download process when a video is rejected --no-break-match-filters Do not use any --break-match-filters (default) --no-playlist Download only the video, if the URL refers to a video and a playlist --yes-playlist Download the playlist, if the URL refers to a video and a playlist --age-limit YEARS Download only videos suitable for the given age --download-archive FILE Download only videos not listed in the archive file. Record the IDs of all downloaded videos in it --no-download-archive Do not use archive file (default) --max-downloads NUMBER Abort after downloading NUMBER files --break-on-existing Stop the download process when encountering a file that is in the archive --no-break-on-existing Do not stop the download process when encountering a file that is in the archive (default) --break-per-input Alters --max-downloads, --break-on-existing, --break-match-filters, and autonumber to reset per input URL --no-break-per-input --break-on-existing and similar options terminates the entire download queue --skip-playlist-after-errors N Number of allowed failures until the rest of the playlist is skipped
-N, --concurrent-fragments N Number of fragments of a dash/hlsnative video that should be downloaded concurrently (default is 1) -r,&n