you-get介绍
一、安装
更多方式请参考you-get GitHub主页
环境依赖
以下为必要配置:
方法 1: 通过 pip 安装(Mac/Windows)
首先配置python3环境,然后通过pip
命令直接安装you-get
,如果电脑只有python3
一个版本,则使用pip install you-get
即可,如果有python2
,则使用pip3
命令,即pip3 install you-get
The official release of you-get
is distributed on PyPI, and can be installed easily from a PyPI mirror via the pip package manager. Note that you must use the Python 3 version of pip
:
pip3 install you-get
方法 2: Homebrew (Mac only)
You can install you-get
easily via:
1 | brew install you-get |
二、简单的快速上手使用方式
2.1 查询视频/图片等信息
1 | you-get -i url |
2.2 下载视频/图片等
- 直接以默认文件名下载到当前文件夹下
1 | you-get --itag=18(目标质量) url |
- 修改路径及文件名
-o 保存的文件夹地址, -O 保存的文件名
Use the--output-dir
/-o
option to set the path, and--output-filename
/-O
to set the name of the downloaded file:
1 | you-get -o ~/Videos -O zoo.webm 'https://www.youtube.com/watch?v=jNQXAC9IVRw' |
三、其他用法
3.1 下载其他能下载的
If you already have the URL of the exact resource you want, you can download it directly with:
1 | $ you-get https://stallman.org/rms.jpg |
Otherwise, you-get
will scrape the web page and try to figure out if there’s anything interesting to you:
1 | $ you-get http://kopasas.tumblr.com/post/69361932517 |
Note:
- This feature is an experimental one and far from perfect. It works best on scraping large-sized images from popular websites like Tumblr and Blogger, but there is really no universal pattern that can apply to any site on the Internet.
3.2 直接观看视频
Use the --player
/-p
option to feed the video into your media player of choice, e.g. mpv
or vlc
, instead of downloading it:
1 | you-get -p vlc 'https://www.youtube.com/watch?v=jNQXAC9IVRw' |
Or, if you prefer to watch the video in a browser, just without ads or comment section:
1 | you-get -p chromium 'https://www.youtube.com/watch?v=jNQXAC9IVRw' |
3.3 Proxy settings
You may specify an HTTP proxy for you-get
to use, via the --http-proxy
/-x
option:
1 | you-get -x 127.0.0.1:8087 'https://www.youtube.com/watch?v=jNQXAC9IVRw' |
However, the system proxy setting (i.e. the environment variable http_proxy
) is applied by default. To disable any proxy, use the --no-proxy
option.
3.4 Search on Google Videos and download
You can pass literally anything to you-get
. If it isn’t a valid URL, you-get
will do a Google search and download the most relevant video for you. (It might not be exactly the thing you wish to see, but still very likely.)
1 | you-get "Richard Stallman eats" |
四、示例
Download a video(摘录自官网)
When you get a video of interest, you might want to use the --info
/-i
option to see all available quality and formats:
1 | $ you-get -i 'https://www.youtube.com/watch?v=jNQXAC9IVRw' |
By default, the one on the top is the one you will get. If that looks cool to you, download it:
1 | $ you-get 'https://www.youtube.com/watch?v=jNQXAC9IVRw' |
(If a YouTube video has any closed captions, they will be downloaded together with the video file, in SubRip subtitle format.)
Or, if you prefer another format (mp4), just use whatever the option you-get
shows to you:
1 | you-get --itag=18 'https://www.youtube.com/watch?v=jNQXAC9IVRw' |