You-Get is a small command line utility for downloading media content (videos, audios, images) from the web in case there is no other convenient method. The following dependencies are required and must be installed separately unless you are using a prebuilt package or chocolate package on Windows:
Python 3
FFmpeg (highly recommended) or Libav (optional)
RTMPDump
Option 1: Install via pip The official you-get is released on PyPI and can be installed via
pip package manager installs easily from PyPI mirrors.
Please note that you must use the Python 3 version of pip:
$ pip3 install you-get
Option 2: Install via antigen Add the following line to your .zshrc:
antigen bundle soimort/you-get
Option 3: Download the exe (standalone) or 7z (including all dependencies) using a pre-built package (Windows only) from:
[https](https://github.com/soimort/you-get/releases/latest):[//github.com/soimort/you-get/releases/latest](https://github.com/soimort/you-get/releases/latest)。
Option 4: Download from GitHub You can download the stable (same as the latest version on PyPI) or the development (more fixes, unstable features) branch you-get.
Related recommendations: "Python Video Tutorial"
Unzip it and put the directory containing the you-get script into PATH. Alternatively, run
$ [sudo] python3 setup.py install
or
$ python3 setup.py install --user
to install you-get to a permanent path.
Option 5: Git Clone This is the recommended method for all developers, even if you don’t code in Python often.
$ git clone git://github.com/soimort/you-get.git
Then put the cloned directory into your directory PATH, or run ./setup.py install to install you-get to a permanent path.
Option 6: Use Chocolatey (Windows only)
> choco install you-get
Option 7: Homebrew (Mac only)
You can -Get easily installed via:
$ brew install you-get
Shell completion Completion definitions for Bash, Fish and Zsh can be found in contrib/completion. Please refer to your shell manual to learn how to exploit them.
Upgrade
Depending on the option you-get you choose to install, you can upgrade via:
$ pip3 install --upgrade you-get
or download the latest version via:
$ you-get https://github.com/soimort/you-get/archive/master.zip
Or use the chocolate package manager:
> choco upgrade you-get
To get the latest develop branch without littering the PIP, you can try:
$ pip3 install --upgrade git+https://github.com/soimort/you-get@develop
Use
When you receive a video you are interested in, you can use the --info/ -i option to see all available qualities and formats:
$ you-get -i 'https://www.youtube.com/watch?v=jNQXAC9IVRw'site: YouTube title: Me at the zoo streams: # Available quality and codecs[ DEFAULT ] _________________________________ - itag: 43container: webm quality: medium size: 0.5 MiB (564215 bytes) # download-with: you-get --itag=43 [URL]- itag: 18 container: mp4 quality: medium # download-with: you-get --itag=18 [URL]- itag: 5 container: flv quality: small # download-with: you-get --itag=5 [URL]- itag: 36 container: 3gp quality: small # download-with: you-get --itag=36 [URL]- itag: 17 container: 3gp quality: small # download-with: you-get --itag=17 [URL]
The formats marked DEFAULT are the ones you will get by default format. If this looks cool, you download it:
$ you-get 'https://www.youtube.com/watch?v=jNQXAC9IVRw' site: YouTube title: Me at the zoo stream: - itag: 43 container: webm quality: medium size: 0.5 MiB (564215 bytes) # download-with: you-get --itag=43 [URL] Downloading zoo.webm ... 100.0% ( 0.5/0.5 MB) ├████████████████████████████████████████┤[1/1] 7 MB/s Saving Me at the zoo.en.srt ...Done.
(If the YouTube video has any subtitles, they will be downloaded along with the video file in SubRip subtitle format.) Or if you prefer another format (mp4), just use the options you-get shows you:
$ you-get --itag=18 'https://www.youtube.com/watch?v=jNQXAC9IVRw'
NOTE:
· At this point, most of our support sites generally do not implement format selection; in this case , the default format to download is the highest quality format.
·ffmpeg is a required dependency for downloading and joining multiple parts of a stream (e.g. on some sites like Youku), as well as videos in 1080p or high resolution YouTube videos.
If you-get don’t want to join the video part after downloading, please use the --no-merge/ -n option.
Download anything else
If you already have the URL of the resource you need, you can download it directly from:
$ you-get https://stallman.org/rms. Site: stallman.org Title: rms Type: JPEG Image (image/jpeg) Size: 0.06 MiB (66482 Bytes) Downloading rms.jpg ... 100.0% ( 0.1/0.1 MB) ├████████████████████████████████████████┤[1/1] 127 kB/s
Otherwise, you-get will scrape Take a web page and try to find out if there's anything interesting for you:
$ you-get http://kopasas.tumblr.com/post/69361932517 Site: Tumblr.com Title: kopasas Type: Unknown type (None) Size: 0.51 MiB (536583 Bytes) Site: Tumblr.com Title: tumblr_mxhg13jx4n1sftq6do1_1280 Type: Portable Network Graphics (image/png) Size: 0.51 MiB (536583 Bytes) Downloading tumblr_mxhg13jx4n1sftq6do1_1280.png ... 100.0% ( 0.5/0.5 MB) ├████████████████████████████████████████┤[1/1] 22 MB/s
Note:
This feature is an experimental and is far from perfect. It works best for scraping large images from popular sites like Tumblr and Blogger, but there's really no universal pattern that can be applied to any site on the internet.
Search in Google Video and download
You can pass anything you-get. If the URL is not a valid one, you-get will perform a Google search and download the most relevant video for you. (This may not be what you want to see, but it's still possible.)
$ you-get "Richard Stallman eats"
Pause and resume downloads You can use Ctrl C to interrupt a download. Temporary .download files remain in the output directory. The next time you-get is run with the same parameters, download progress will resume from the previous session. If the file is downloaded completely (the temporary .download extension has been removed), you-get will skip the download.
To force a re-download, use the --force/ -f option. (Warning: Doing so will overwrite any existing files or temporary files with the same name!)
Set the path and name of the downloaded file
Use --output- dir/ -o option sets the path, and --output-filename/ -O sets the name of the downloaded file:
$ you-get -o ~/Videos -O zoo.webm 'https://www.youtube.com/watch?v=jNQXAC9IVRw'
Tips:
· If you encounter the default video title (which may contain the same name as the current shell / These options are useful when you encounter problems with operating system/file system incompatible special characters).
·These options are also useful if you write a script to batch download files and put them into a folder with a specified name.
Proxy Settings
You-get to specify the HTTP proxy to use via the --http-proxy/ -x option:
$ you-get -x 127.0.0.1:8087 'https://www.youtube.com/watch?v=jNQXAC9IVRw'
但是,http_proxy默认情况下应用系统代理设置(即环境变量)。要禁用任何代理,请使用该--no-proxy选项。
提示:
如果你需要使用代理了很多(如果您的网络阻止某些网站),你可能希望使用you-get与proxychains并设置alias you-get="proxychains -q you-get"(Bash中)。
对于某些网站(例如优酷),如果您需要访问仅在中国大陆可用的一些视频,可以使用特定代理从网站提取视频信息:--extractor-proxy/ -y。
观看视频
使用--player/ -p选项将视频馈送到您选择的媒体播放器,例如mplayer或vlc,而不是下载:
$ you-get -p vlc 'https://www.youtube.com/watch?v=jNQXAC9IVRw'
或者,如果您更喜欢在浏览器中观看视频,只需没有广告或评论部分:
$ you-get -p chromium 'https://www.youtube.com/watch?v=jNQXAC9IVRw'
提示:
可以使用该-p选项来启动另一个下载管理器,例如you-get -p uget-gtk 'https://www.youtube.com/watch?v=jNQXAC9IVRw'
,尽管它们可能不能一起播放很好。
加载Cookie
并非所有视频都向任何人公开。如果您需要登录帐户以访问某些内容(例如,私人视频),则无法you-get通过--cookies/ -c选项向浏览器提供Cookie 。
注意:
到目前为止,我们支持两种格式的浏览器Cookie:Mozilla cookies.sqlite和Netscape cookies.txt。
重新使用提取的数据
使用--url/ -u获取从页面提取的可下载资源URL的列表。用于--json以JSON格式获取抽取数据的摘要。
The above is the detailed content of How to call youget in python. For more information, please follow other related articles on the PHP Chinese website!