Python开发的视频下载器神器you-get,你值得了解一下

不知道大家有没有遇到过这种情况,就是看到自己喜欢的视频,突然想要下载,可是又无从下手,有些网站需要下载特有的播放器才能下载,如此之多的网站,那岂不是我们的桌面要装满播放器吗?其实不然,现在有一款下载器可以帮我们友好的解决这个问题.

这里我要安利一下you-get,有兴趣的伙伴可以去you-get github去学习一下。这里我们需要先安装Python环境,然后通过pip来安装。如果直接通过pip3 install you-get会出现这样的问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
C:\Users\wmymt>pip3 install you-get
Collecting you-get
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x040E8D30>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/you-get/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x040E8C88>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/you-get/
ERROR: Operation cancelled by user
Traceback (most recent call last):
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\urllib3\util\connection.py", line 70, in create_connection
sock.connect(sa)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "D:\Users\wmymt\AppData\Local\Programs\Python\Python38-32\Scripts\pip3.exe\__main__.py", line 9, in <module>
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\__init__.py", line 77, in main
return command.main(cmd_args)
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\cli\base_command.py", line 240, in main
pip_version_check(session, options)
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\utils\outdated.py", line 142, in pip_version_check
candidate = finder.find_candidates("pip").get_best()
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\index.py", line 1183, in find_candidates
candidates = self.find_all_candidates(project_name)
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\index.py", line 1128, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\index.py", line 1282, in _get_pages
page = _get_html_page(location, session=self.session)
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\index.py", line 234, in _get_html_page
resp = _get_html_response(url, session=session)
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\index.py", line 165, in _get_html_response
resp = session.get(
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\requests\sessions.py", line 546, in get
return self.request('GET', url, **kwargs)
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\download.py", line 624, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\cachecontrol\adapter.py", line 53, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\urllib3\connectionpool.py", line 600, in urlopen
httplib_response = self._make_request(conn, method, url,
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\urllib3\connectionpool.py", line 344, in _make_request
self._validate_conn(conn)
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\urllib3\connectionpool.py", line 843, in _validate_conn
conn.connect()
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\urllib3\connection.py", line 316, in connect
conn = self._new_conn()
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\urllib3\connection.py", line 159, in _new_conn
conn = connection.create_connection(
File "d:\users\wmymt\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\urllib3\util\connection.py", line 70, in create_connection
sock.connect(sa)
KeyboardInterrupt

原因,大家应该是懂的,我就不细说了,这里我们需要修改一下下载的镜像地址,有两种方式、一种是pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple you-get,另外一种就是在C:\Users\当前用户\下新建一个pip文件夹,进入到该文件夹继续新建一个pip.ini并在文件中加入一下配置

1
2
3
4
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

这时候我们再执行pip3 install you-get基本就会安装成功了

1
2
3
4
5
6
7
8
9
C:\Users\wmymt>pip3 install you-get
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting you-get
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/24/bf/22a3c582dfd4969bace5eb287acfb9264e4999602312b3cf879ea0beff48/you_get-0.4.1432-py3-none-any.whl (215kB)
|████████████████████████████████| 225kB 930kB/s
Installing collected packages: you-get
Successfully installed you-get-0.4.1432
WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

这时候我们就可以在命令行执行you-get命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
C:\Users\wmymt>you-get -h
you-get: version 0.4.1432, a tiny downloader that scrapes the web.
usage: you-get [OPTION]... URL...

A tiny downloader that scrapes the web

optional arguments:
-V, --version Print version and exit
-h, --help Print this help message and exit

Dry-run options:
(no actual downloading)

-i, --info Print extracted information
-u, --url Print extracted information with URLs
--json Print extracted URLs in JSON format

Download options:
-n, --no-merge Do not merge video parts
--no-caption Do not download captions (subtitles, lyrics, danmaku, ...)
-f, --force Force overwriting existing files
--skip-existing-file-size-check
Skip existing file without checking file size
-F STREAM_ID, --format STREAM_ID
Set video format to STREAM_ID
-O FILE, --output-filename FILE
Set output filename
-o DIR, --output-dir DIR
Set output directory
-p PLAYER, --player PLAYER
Stream extracted URL to a PLAYER
-c COOKIES_FILE, --cookies COOKIES_FILE
Load cookies.txt or cookies.sqlite
-t SECONDS, --timeout SECONDS
Set socket timeout
-d, --debug Show traceback and other debug info
-I FILE, --input-file FILE
Read non-playlist URLs from FILE
-P PASSWORD, --password PASSWORD
Set video visit password to PASSWORD
-l, --playlist Prefer to download a playlist
-a, --auto-rename Auto rename same name different files
-k, --insecure ignore ssl errors

Proxy options:
-x HOST:PORT, --http-proxy HOST:PORT
Use an HTTP proxy for downloading
-y HOST:PORT, --extractor-proxy HOST:PORT
Use an HTTP proxy for extracting only
--no-proxy Never use a proxy
-s HOST:PORT, --socks-proxy HOST:PORT
Use an SOCKS5 proxy for downloading

这时候,我们来下载一个视频瞧瞧效果,我去腾讯视频搜索斗破苍穹2

1
2
3
4
5
6
7
8
C:\Users\wmymt>you-get https://v.qq.com/x/cover/o0ytzgvq6o08e9o/e00316w2fzo.html
Site: QQ.com
Title: 斗破苍穹 第3季_01
Type: MPEG-4 video (video/mp4)
Size: 197.48 MiB (207069792 Bytes)

Downloading 斗破苍穹 第3季_01.mp4 ...
36.8% ( 72.7/197.5MB) ├███████████████─────────────────────────┤[2/5] 2 MB/s

这时候下载的文件就存放在命令执行目录,收费视频不行哟。

Python开发的视频下载器神器you-get,你值得了解一下

https://blogs.52fx.biz/posts/506177874.html

作者

eyiadmin

发布于

2020-04-16

更新于

2024-05-31

许可协议

评论