视频下载工具yt-dlp_macos

项目地址:https://github.com/yt-dlp/yt-dlp

下载对应系统的版本,我的是mac,下载的是:yt-dlp_macos

将下载的文件放到自己常用的目录中,并把目录添加到环境变量中:

#yt_dlp
export PATH="/Users/testmanzhang/Documents/software:$PATH"

给yt-dlp_macos添加可执行权限:

chmod +x /Users/testmanzhang/Documents/software/yt-dlp_macos

我本地安装过程中出现了一点小问题,原因是我去年安装的版本现在已经很低了,下载过程中会报错:

正在下载: https://www.youtube.com/shorts/poW2NEvhnLQ?feature=share
[失败] https://www.youtube.com/shorts/poW2NEvhnLQ?feature=share
错误信息: [youtube] Extracting URL: https://www.youtube.com/shorts/poW2NEvhnLQ?feature=share
[youtube] poW2NEvhnLQ: Downloading webpage
WARNING: [youtube] Unable to download webpage: HTTP Error 429: Too Many Requests
[youtube] poW2NEvhnLQ: Downloading ios player API JSON
WARNING: [youtube] YouTube said: ERROR - Request contains an invalid argument.
WARNING: [youtube] HTTP Error 400: Bad Request. Retrying (1/3)...
[youtube] poW2NEvhnLQ: Downloading ios player API JSON
WARNING: [youtube] YouTube said: ERROR - Request contains an invalid argument.
WARNING: [youtube] HTTP Error 400: Bad Request. Retrying (2/3)...
[youtube] poW2NEvhnLQ: Downloading ios player API JSON
WARNING: [youtube] YouTube said: ERROR - Request contains an invalid argument.
WARNING: [youtube] HTTP Error 400: Bad Request. Retrying (3/3)...
[youtube] poW2NEvhnLQ: Downloading ios player API JSON
WARNING: [youtube] YouTube said: ERROR - Request contains an invalid argument.
WARNING: [youtube] Unable to download API page: HTTP Error 400: Bad Request (caused by <HTTPError 400: Bad Request>)
[youtube] poW2NEvhnLQ: Downloading iframe API JS
[youtube] poW2NEvhnLQ: Downloading player ac290d0b
[youtube] poW2NEvhnLQ: Downloading tv player API JSON
WARNING: [youtube] Falling back to generic n function search
         player = https://www.youtube.com/s/player/ac290d0b/player_ias.vflset/en_US/base.js
WARNING: [youtube] poW2NEvhnLQ: nsig extraction failed: Some formats may be missing
         n = C2qWf10kbUc8yBL ; player = https://www.youtube.com/s/player/ac290d0b/player_ias.vflset/en_US/base.js
WARNING: [youtube] Falling back to generic n function search
         player = https://www.youtube.com/s/player/ac290d0b/player_ias.vflset/en_US/base.js
WARNING: [youtube] poW2NEvhnLQ: nsig extraction failed: Some formats may be missing
         n = NkT7ItcqWHVEZPX ; player = https://www.youtube.com/s/player/ac290d0b/player_ias.vflset/en_US/base.js
[youtube] poW2NEvhnLQ: Downloading initial data API JSON
WARNING: Extractor failed to obtain "title". Creating a generic title instead
WARNING: Only images are available for download. use --list-formats to see them
ERROR: [youtube] poW2NEvhnLQ: Requested format is not available. Use --list-formats for a list of available formats

解决方法就是把之前的版本卸载掉:

brew uninstall yt-dlp

或者

pip uninstall yt-dlp

或者

rm -f /usr/local/bin/yt-dlp
rm -f ~/.local/bin/yt-dlp

检查是否已经卸载:

which yt-dlp
yt-dlp --version

彻底卸载后再重新安装即可。

安装完成后如果遇到:无法打开“yt-dlp_macos”

进入:系统设置->隐私与安全性->允许即可

【基本使用方法】

yt-dlp_macos --cookies www.youtube.com_cookies.txt -f mp4 https://www.youtube.com/shorts/BGaE9PdZ0FA

--cookies 指定cookies

-f 下载视频的格式

后面是下载的url