1.you-get是什么
you-get是Github上的一个项目,源项目托管地址对其介绍如下:You-Get is a tiny command-line utility to download media contents (videos, audios, images) from the Web, in case there is no other handy way to do it.
You-Get是一个小型的命令行实用程序,用于从Web下载媒体内容(视频,音频,图像),方便实用,使用方法简单便捷,并且下载速度也十分迅速,普通视频网站(爱优腾)及其软件产品的下载速度最高达6M,you-get下载速度一般稳定在3M-12M之间(当然受网络基础设施的限制)。
2.you-get能做什么
官网介绍如下:
And here's why you might want to use it:
- You enjoyed something on the Internet, and just want to download them for your own pleasure.
- You watch your favorite videos online from your computer, but you are prohibited from saving them. You feel that you have no control over your own computer. (And it's not how an open Web is supposed to work.)
- You want to get rid of any closed-source technology or proprietary JavaScript code, and disallow things like Flash running on your computer.
- You are an adherent of hacker culture and free software.
What you-get
can do for you:
- Download videos / audios from popular websites such as YouTube, Youku, Niconico, and a bunch more. (See the full list of supported sites)
- Stream an online video in your media player. No web browser, no more ads.
- Download images (of interest) by scraping a web page.
- Download arbitrary non-HTML contents, i.e., binary files.
简单总结,you-get支持多网站下载该网站音视频及图片资源。
支持网站如下:
Supported Sites
For all other sites not on the list, the universal extractor will take care of finding and downloading interesting resources from the page.
3.如何使用you-get
you-get使用到底有多简洁呢,从其基于命令行这个特点可见一斑。下面话不多说,最有力的证据就是实践,直接上亲测过程。
3.1安装you-get
项目官方给出了以下安装办法。
Installation
Prerequisites
The following dependencies are necessary:
Option 1: Install via pip
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
Option 2: Install via Antigen (for Zsh users)
Add the following line to your .zshrc
:
antigen bundle soimort/you-get
Option 3: Download from GitHub
You may either download the stable (identical with the latest release on PyPI) or the develop (more hotfixes, unstable features) branch of you-get
. Unzip it, and put the directory containing the you-get
script into your PATH
.
Alternatively, run
$ [sudo] python3 setup.py install
Or
$ python3 setup.py install --user
to install you-get
to a permanent path.
Option 4: Git clone
This is the recommended way for all developers, even if you don't often code in Python.
$ git clone git://github.com/soimort/you-get.git
Then put the cloned directory into your PATH
, or run ./setup.py install
to install you-get
to a permanent path.
Option 5: Homebrew (Mac only)
You can install you-get
easily via:
$ brew install you-get
Option 6: pkg (FreeBSD only)
You can install you-get
easily via:
# pkg install you-get
Shell completion
Completion definitions for Bash, Fish and Zsh can be found in contrib/completion. Please consult your shell's manual for how to take advantage of them.
Upgrading
Based on which option you chose to install you-get
, you may upgrade it via:
$ pip3 install --upgrade you-get
or download the latest release via:
$ you-get https://github.com/soimort/you-get/archive/master.zip
In order to get the latest develop
branch without messing up the PIP, you can try:
$ pip3 install --upgrade git+https://github.com/soimort/you-get@develop
由于you-get基于Python,故我们应该首先安装Python。并且我们需要安装3.2或3.2以上版本。
以下为不同平台上安装 Python 的方法:
Unix & Linux 平台安装 Python:
以下为在 Unix & Linux 平台上安装 Python 的简单步骤:
- 打开 WEB 浏览器访问Python Source Releases | Python.org
- 选择适用 于Unix/Linux 的源码压缩包。
- 下载及解压压缩包。
- 如果你需要自定义一些选项修改Modules/Setup
- 执行 ./configure 脚本
- make
- make install
执行以上操作后,Python 会安装在 /usr/local/bin 目录中,Python 库安装在 /usr/local/lib/pythonXX,XX 为你使用的 Python 的版本号。
Window 平台安装 Python:
以下为在 Window 平台上安装 Python 的简单步骤:
-
打开 WEB 浏览器访问Python Releases for Windows | Python.org
- 在下载列表中选择Window平台安装包,包格式为:python-XYZ.msi 文件 , XYZ 为你要安装的版本号。
-
要使用安装程序 python-XYZ.msi, Windows 系统必须支持 Microsoft Installer 2.0 搭配使用。只要保存安装文件到本地计算机,然后运行它,看看你的机器支持 MSI。Windows XP 和更高版本已经有 MSI,很多老机器也可以安装 MSI。
-
下载后,双击下载包,进入 Python 安装向导,安装非常简单,你只需要使用默认的设置一直点击"下一步"直到安装完成即可。
MAC 平台安装 Python:
MAC 系统一般都自带有 Python2.x版本 的环境,你也可以在链接 Python Releases for macOS | Python.org 上下载最新版安装。
环境变量配置
程序和可执行文件可以在许多目录,而这些路径很可能不在操作系统提供可执行文件的搜索路径中。
path(路径)存储在环境变量中,这是由操作系统维护的一个命名的字符串。这些变量包含可用的命令行解释器和其他程序的信息。
Unix或Windows中路径变量为PATH(UNIX区分大小写,Windows不区分大小写)。
在Mac OS中,安装程序过程中改变了python的安装路径。如果你需要在其他目录引用Python,你必须在path中添加Python目录。
在 Unix/Linux 设置环境变量
- 在 csh shell: 输入
, 按下"Enter"。setenv PATH "$PATH:/usr/local/bin/python"
- 在 bash shell (Linux): 输入
,按下"Enter"。export PATH="$PATH:/usr/local/bin/python"
- 在 sh 或者 ksh shell: 输入
, 按下"Enter"。PATH="$PATH:/usr/local/bin/python"
注意: /usr/local/bin/python 是 Python 的安装目录。
在 Windows 设置环境变量
在环境变量中添加Python目录:
在命令提示框中(cmd) : 输入
path=%path%;C:\Python
按下"Enter"。
注意: C:\Python 是Python的安装目录。
也可以通过以下方式设置:
- 右键点击"计算机",然后点击"属性"
- 然后点击"高级系统设置"
- 选择"系统变量"窗口下面的"Path",双击即可!
- 然后在"Path"行,添加python安装路径即可(我的D:\Python32),所以在后面,添加该路径即可。 ps:记住,路径直接用分号";"隔开!
- 最后设置成功以后,在cmd命令行,输入命令"python",就可以有相关显示。
Python 环境变量
下面几个重要的环境变量,它应用于Python:
变量名 | 描述 |
---|---|
PYTHONPATH | PYTHONPATH是Python搜索路径,默认我们import的模块都会从PYTHONPATH里面寻找。 |
PYTHONSTARTUP | Python启动后,先寻找PYTHONSTARTUP环境变量,然后执行此变量指定的文件中的代码。 |
PYTHONCASEOK | 加入PYTHONCASEOK的环境变量, 就会使python导入模块的时候不区分大小写. |
PYTHONHOME | 另一种模块搜索路径。它通常内嵌于的PYTHONSTARTUP或PYTHONPATH目录中,使得两个模块库更容易切换。 |
运行Python
有三种方式可以运行Python:
1、交互式解释器:
你可以通过命令行窗口进入 Python,并在交互式解释器中开始编写 Python 代码。
你可以在 Unix、DOS 或任何其他提供了命令行或者 shell 的系统进行 Python 编码工作。
$ python # Unix/Linux
或者
C:>python # Windows/DOS
以下为Python命令行参数:
选项 | 描述 |
---|---|
-d | 在解析时显示调试信息 |
-O | 生成优化代码 ( .pyo 文件 ) |
-S | 启动时不引入查找Python路径的位置 |
-V | 输出Python版本号 |
-X | 从 1.6版本之后基于内建的异常(仅仅用于字符串)已过时。 |
-c cmd | 执行 Python 脚本,并将运行结果作为 cmd 字符串。 |
file | 在给定的python文件执行python脚本。 |
2、命令行脚本
在你的应用程序中通过引入解释器可以在命令行中执行Python脚本,如下所示:
$ python script.py # Unix/Linux
或者
C:>python script.py # Windows/DOS
注意:在执行脚本时,请检查脚本是否有可执行权限。
3、集成开发环境(IDE:Integrated Development Environment): PyCharm
PyCharm 是由 JetBrains 打造的一款 Python IDE,支持 macOS、 Windows、 Linux 系统。
PyCharm 功能 : 调试、语法高亮、Project管理、代码跳转、智能提示、自动完成、单元测试、版本控制……
PyCharm 下载地址 : Download PyCharm: Python IDE for Professional Developers by JetBrains
PyCharm 安装地址:http://www.runoob.com/w3cnote/pycharm-windows-install.html
简易总结安装如下:
安装
pip install you-get
更新
pip install --upgrade you-get
3.2安装ffmpeg
ffmpeg是一款视频合成处理软件,与you-get相同,便捷使用并且体积小,运行时所需内存也少,运行速度当然nice。
下载网址 https://ffmpeg.zeranoe.com/builds/
默认选项即可,直接点击“Download Build”
解压后的文件夹根据喜好放在随意硬盘内,然后将ffmpeg 目录下的 bin 文件夹 配置环境变量,例:D:\ffmpeg-20200131-62d92a8-win64-static\bin
检测是否安装成功
cmd中输入ffmpeg后按回车,看见一下图示字符即为成功
即如下:
C:\Users\AM>ffmpeg
ffmpeg version git-2020-07-20-43a08d9 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200621
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 55.100 / 56. 55.100
libavcodec 58. 96.100 / 58. 96.100
libavformat 58. 48.100 / 58. 48.100
libavdevice 58. 11.101 / 58. 11.101
libavfilter 7. 87.100 / 7. 87.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'
3.3you-get使用
1. 直接下载,默认最清晰
C:\>you-get 网址
2. 使用 -i 参数可以列出视频有哪些清晰度的格式
C:\>you-get -i 网址
然后使用以下代码选择下载
you-get --format == format码 网址
3. 假如视频需要密码才能访问,可使用 -P 参数来指定密码
C:\>you-get -P 密码 网址
4. 如果是多P视频(多P视频就是里面有好几个视频)**,可使用 -l **(小写l)参数来自动下载连续的多个视频列表
C:\>you-get -l 网址
5. 使用 http 代理下载一个视频可使用 -x 参数来指定代理
C:\>you-get -x 127.0.0.1:80 网址
6. 使用 socks 代理下载一个视频可使用 -s 参数来指定代理
C:\>you-get -s 127.0.0.1:233 网址
7. 解析视频真实的地址
C:\>you-get -u 网址
8. 需要登录才能下载的视频
1)首先使用火狐浏览器先登录该视频网站
2)window + r 打开运行输入 %appdata%/Mozilla/firefox/profiles 回车确定
显示类似以下名字的文件夹(名字各有不同),在该文件夹中找到cookies.sqlite 文件
复制cookies.sqlite 文件的完整路径
C:\Users\AM\AppData\Roaming\Mozilla\Firefox\Profiles\j2g95nvc.default-release\cookies.sqlite
3)使用 you-get 工具的 -c 参数加载 cookie 文件,便可下载视频
C:\Users\AM>set cookie=C:\Users\AM\AppData\Roaming\Mozilla\Firefox\Profiles\j2g95nvc.default-release\cookies.sqlite
C:\Users\AM>you-get -c %cookie% https://www.bilibili.com/bangumi/play/ep332611
you-get: This bangumi currently has 2 videos. (use --playlist to download all videos.)
site: Bilibili
title: 天气之子
stream:
- format: dash-hdflv2
container: mp4
quality: 高清 1080P+
size: 2989.5 MiB (3134727036 bytes)
# download-with: you-get --format=dash-hdflv2 [URL]
Downloading 天气之子.mp4 ...
100% (2989.5/2989.5MB) ├██████████████████████████████████████┤[2/2] 4 MB/s
Merging video parts... Merged into 天气之子.mp4
Downloading 天气之子.cmt.xml ...
4.you-get经验谈(偷偷告诉你,可别告诉别人哟^-^)
- you-get对于字母站的视频下载十分实用
- 对于优K的视频下载,只需要加载 cookie 文件即可
- 爱QY对于cookie 文件免疫(网上说,反正用了cookie都不能下VIP视频)
- 企鹅视频下载后会分开好几个视频,还可能会在下载过程中卡死
- 其他支持网站未作尝试,因为GFW太强大了(懂得都懂)。个人推测下载效果应该不会很理想,因为说千道万you-get还是基于所连网络的,国内的网下油管视频一般都是使用专用特殊工具的,you-get在国内下载油管视频的效果估计不会太好。
- 下载qe视频别用you-get,爱QY普通视频可尝试(一般下很久,会断,正常下载时还会出现掉线和重连),优K用cookie可以下载,字母站畅通无阻。
参考资料:https://www.jianshu.com/p/dd7f04c27a79
【工具】you-get 安装与使用(含使用反馈及总结)【最全】_300%努力努力再努力的博客-CSDN博客
GitHub - soimort/you-get: Dumb downloader that scrapes the web
测试所输入全部指令及显示:
Microsoft Windows [版本 10.0.18362.959]
(c) 2019 Microsoft Corporation。保留所有权利。
C:\Users\AM>pip3 install --upgrade you-get
Requirement already up-to-date: you-get in c:\users\am\appdata\local\programs\python\python38\lib\site-packages (0.4.1456)
Could not build wheels for you-get, since package 'wheel' is not installed.
WARNING: You are using pip version 20.1; however, version 20.1.1 is available.
You should consider upgrading via the 'c:\users\am\appdata\local\programs\python\python38\python.exe -m pip install --upgrade pip' command.
C:\Users\AM>pip3 install --upgrade you-get
Collecting you-get
Using cached you_get-0.4.1456-py3-none-any.whl (217 kB)
Installing collected packages: you-get
Successfully installed you-get-0.4.1456
WARNING: You are using pip version 20.1; however, version 20.1.1 is available.
You should consider upgrading via the 'c:\users\am\appdata\local\programs\python\python38\python.exe -m pip install --upgrade pip' command.
C:\Users\AM>c:\users\am\appdata\local\programs\python\python38\python.exe -m pip install --upgrade pip
Collecting pip
Downloading pip-20.1.1-py2.py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 409 kB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.1
Uninstalling pip-20.1:
Successfully uninstalled pip-20.1
Successfully installed pip-20.1.1
C:\Users\AM>pip3 install --upgrade you-get
Requirement already up-to-date: you-get in c:\users\am\appdata\local\programs\python\python38\lib\site-packages (0.4.1456)
C:\Users\AM>set cookie=C:\Users\AM\AppData\Roaming\Mozilla\Firefox\Profiles\j2g95nvc.default-release\cookies.sqlite
C:\Users\AM>you-get -c %cookie% https://www.bilibili.com/bangumi/play/ep332611
you-get: This bangumi currently has 2 videos. (use --playlist to download all videos.)
site: Bilibili
title: 天气之子
stream:
- format: dash-hdflv2
container: mp4
quality: 高清 1080P+
size: 2989.5 MiB (3134727036 bytes)
# download-with: you-get --format=dash-hdflv2 [URL]
Downloading 天气之子.mp4 ...
100% (2989.5/2989.5MB) ├██████████████████████████████████████┤[2/2] 4 MB/s
Merging video parts... Merged into 天气之子.mp4
Downloading 天气之子.cmt.xml ...
C:\Users\AM>--playlist
'--playlist' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
C:\Users\AM>you-get -c %cookie% https://www.bilibili.com/bangumi/play/ep118109
site: Bilibili
title: 大鱼海棠
stream:
- format: hdflv2
container: flv
quality: 高清 1080P+
size: 2124.8 MiB (2227986169 bytes)
# download-with: you-get --format=hdflv2 [URL]
Downloading 大鱼海棠.mp4 ...
100% (2124.8/2124.8MB) ├████████████████████████████████████┤[17/17] 15 MB/s
Merging video parts... Merged into 大鱼海棠.mp4
Downloading 大鱼海棠.cmt.xml ...
C:\Users\AM>you-get -c %cookie% https://www.bilibili.com/video/av79614253
site: Bilibili
title: 【鹿小草QAQ】《故梦》翻唱,人生如梦,说要遗忘,何时能忘。
stream:
- format: dash-hdflv2
container: mp4
quality: 高清 1080P+
size: 35.0 MiB (36650745 bytes)
# download-with: you-get --format=dash-hdflv2 [URL]
Downloading 【鹿小草QAQ】《故梦》翻唱,人生如梦,说要遗忘,何时能忘。.mp4 ...
100% ( 35.0/ 35.0MB) ├████████████████████████████████████████┤[2/2] 6 MB/s
Merging video parts... Merged into 【鹿小草QAQ】《故梦》翻唱,人生如梦,说要遗忘,何时能忘。.mp4
Downloading 【鹿小草QAQ】《故梦》翻唱,人生如梦,说要遗忘,何时能忘。.cmt.xml ...
C:\Users\AM>ffmpeg
ffmpeg version git-2020-07-20-43a08d9 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200621
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 55.100 / 56. 55.100
libavcodec 58. 96.100 / 58. 96.100
libavformat 58. 48.100 / 58. 48.100
libavdevice 58. 11.101 / 58. 11.101
libavfilter 7. 87.100 / 7. 87.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'
C:\Users\AM>you-get -i https://www.bilibili.com/bangumi/play/ep264225?from=search&seid=8589884304499412353
site: Bilibili
title: 白蛇:缘起
streams: # Available quality and codecs
[ DEFAULT ] _________________________________
- format: flv480
container: flv
quality: 清晰 480P
size: 43.0 MiB (45103107 bytes)
# download-with: you-get --format=flv480 [URL]
'seid' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
C:\Users\AM>you-get -c %cookie% https://www.bilibili.com/bangumi/play/ep264225
site: Bilibili
title: 白蛇:缘起
stream:
- format: dash-hdflv2
container: mp4
quality: 高清 1080P+
size: 4122.6 MiB (4322808033 bytes)
# download-with: you-get --format=dash-hdflv2 [URL]
Downloading 白蛇:缘起.mp4 ...
100% (4122.6/4122.6MB) ├██████████████████████████████████████┤[2/2] 13 MB/s
Merging video parts... Merged into 白蛇:缘起.mp4
Downloading 白蛇:缘起.cmt.xml ...
C:\Users\AM>
PS C:\Users\AM> you-get https://www.bilibili.com/bangumi/play/ss12455/ -c C:\Users\AM\AppData\Roaming\Mozilla\Firefox\Profiles\j2g95nvc.default-release\cookies.sqlite
site: Bilibili
title: 青春派
stream:
- format: hdflv2
container: flv
quality: 高清 1080P+
size: 2030.1 MiB (2128729406 bytes)
# download-with: you-get --format=hdflv2 [URL]
以上为无法完整下载破站大会员视频所提供的新链接,供大家使用。