youtube-dl 大杂烩 合集
安装使用
To install it right away for all UNIX users (Linux, OS X, etc.), type:
sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
windows.exe地址
https://yt-dl.org/downloads/2021.12.17/youtube-dl.exe
Windows users can download an .exe file and place it in any location on their PATH except for %SYSTEMROOT%System32 (e.g. do not put in C:WindowsSystem32).
If you do not have curl, you can alternatively use a recent wget:
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
You can also use pip:
sudo pip install --upgrade youtube_dl
签名校验
sudo wget https://yt-dl.org/downloads/latest/youtube-dl.sig -O youtube-dl.sig
gpg --verify youtube-dl.sig /usr/local/bin/youtube-dl
rm youtube-dl.sig
github 地址:
https://github.com/ytdl-org/youtube-dl
youtube-dl 下载慢
youtube-dl https://www.youtube.com/*** --external-downloader aria2c --external-downloader-args "-x 16 -k 1M"
参数说明
--external-downloader aria2c //调用外部下载工具
--external-downloader-args //外部下载工具指定参数
-x 16 //启用aria2 16个线程,最多就支持16线程
-K 1M //指定块的大小
youtube-dl 下载慢 改用yt-dlp这个工具
安装yt-dlp这个工具得是Python3,2.7不受支持;
安装命令:
pip install yt-dlp
升级命令:
pip install -U yt-dlp
yt-dlp GitHub地址:https://github.com/yt-dlp/yt-dlp
youtube-dl 下载需要登录的资源
安装GetCookie插件(https://chrome.google.com/webstore/detail/get-cookiestxt/bgaddhkoddajcdgocldbbfleckgcbcid)
I then visited YouTube.com, while I was logged in, and clicked on the Get
Cookies icon. Then I clicked on the “Export” button to download my YouTube cookies as a text file.
This created a youtube.com_cookies.txt file that I then copied into the YouTube-DL directory on my laptop.
Finally I ran the following command in YouTube-DL to pass the cookie to YouTube and download the video:
youtube-dl -f bestvideo+bestaudio --merge-output-format mkv --all-subs --cookies youtube.com_cookies.txt [YouTube URL]
使用 youtube-dl 只下载音频
如果你只想从 YouTube 视频中下载音频,你可以使用 youtube-dl 的 -x 选项。这个提取音频的选项将视频文件转换为纯音频文件。
youtube-dl -x video_URL
该文件被保存在你运行 youtube-dl 命令的同一目录下。
如你想提取 MP3 格式的音频。你可以像这样使用它:
youtube-dl -x --audio-format mp3 video_URL