1.安装pip
我的服务器上已经有了python3,但是看了下,没有pip3,安装它。
// 下面命令下载get-pip.py
curl -sSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py
// 下面命令安装pip
python3 get-pip.py
安装的时候报错了:
~/python$ python3 get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 27077, in
main()
File "get-pip.py", line 135, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 111, in bootstrap
monkeypatch_for_cert(tmpdir)
File "get-pip.py", line 92, in monkeypatch_for_cert
from pip._internal.commands.install import InstallCommand
File "/tmp/tmpih8jjpai/pip.zip/pip/_internal/commands/__init__.py", line 9, in
File "/tmp/tmpih8jjpai/pip.zip/pip/_internal/cli/base_command.py", line 13, in
File "/tmp/tmpih8jjpai/pip.zip/pip/_internal/cli/cmdoptions.py", line 23, in
File "/tmp/tmpih8jjpai/pip.zip/pip/_internal/cli/parser.py", line 12, in
File "/tmp/tmpih8jjpai/pip.zip/pip/_internal/configuration.py", line 26, in
File "/tmp/tmpih8jjpai/pip.zip/pip/_internal/utils/logging.py", line 13, in
File "/tmp/tmpih8jjpai/pip.zip/pip/_internal/utils/misc.py", line 40, in
File "/tmp/tmpih8jjpai/pip.zip/pip/_internal/locations/__init__.py", line 14, in
File "/tmp/tmpih8jjpai/pip.zip/pip/_internal/locations/_distutils.py", line 9, in
ModuleNotFoundError: No module named 'distutils.cmd'
于是,根据错误提示,还需要安装distutils.cmd
sudo apt install python3-distutils
装好后,即可安装。
2.安装you-get
使用下面命令安装:
pip install you-get
安装好后,有下面的警告,添加到环境变量即可。
WARNING: The script you-get is installed in '/home/xxx/.local/bin' which is not on PATH.
添加到环境变量
// 添加到.bashrc中
echo "export PATH=/home/xxx/.local/bin:$PATH" >> ~/.bashrc
// 使.bashrc生效
source ~/.bashrc
3.下载视频
you-get -I https:xxx能看到视频列表。
you-get -i https://www.youtube.com/watch?v=Qq0V09-s6LI
site: YouTube
title: Chinese Dress❾ Try On Haul
streams: # Available quality and codecs
[ DASH ] ____________________________________
- itag: 315
container: webm
quality: 3840x2160 (2160p60)
size: 492.8 MiB (516698530 bytes)
# download-with: you-get --itag=315 [URL]
- itag: 308
container: webm
quality: 2560x1440 (1440p60)
size: 171.7 MiB (180032880 bytes)
# download-with: you-get --itag=308 [URL]
- itag: 299
container: mp4
quality: 1920x1080 (1080p60)
size: 81.2 MiB (85094618 bytes)
# download-with: you-get --itag=299 [URL]
使用--itag=xxx下载指定的视频。
you-get --itag=308 https://www.youtube.com/watch?v=Qq0V09-s6LI
4.更多命令查看官方文档
https://github.com/soimort/you-get