mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-07-07 15:51:28 +08:00
增加PROXY_SUPPLEMENT变量
1、增加proxychains4模块,用于解决pip在socks5代理时,pip无法使用全局代理的问题 2、增加`PROXY_SUPPLEMENT`变量,可以手动控制,实现使用镜像站进行更新时,但缺少pip镜像站或者GitHub镜像站时,可以使用全局代理补全缺失的代理
This commit is contained in:
53
urlparse.py
Normal file
53
urlparse.py
Normal file
@@ -0,0 +1,53 @@
|
||||
import sys
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
||||
def parse_url(url):
|
||||
parsed_url = urlparse(url)
|
||||
|
||||
# 提取各个部分
|
||||
protocol = parsed_url.scheme or ""
|
||||
username = parsed_url.username or ""
|
||||
password = parsed_url.password or ""
|
||||
hostname = parsed_url.hostname or ""
|
||||
port = parsed_url.port or ""
|
||||
|
||||
if hostname:
|
||||
hostname = hostname.lower()
|
||||
|
||||
if not port:
|
||||
if protocol == "https":
|
||||
port = 443
|
||||
elif protocol == "http":
|
||||
port = 80
|
||||
elif protocol in {"socks5", "socks5h", "socks4", "socks4a"}:
|
||||
port = 1080
|
||||
|
||||
# socks协议转换,适配proxychains4的临时命令不支持的socks4a与socks5h
|
||||
if protocol:
|
||||
protocol = protocol.lower()
|
||||
if protocol in {"socks5", "socks5h"}:
|
||||
protocol = "socks5"
|
||||
elif protocol in {"socks4", "socks4a"}:
|
||||
protocol = "socks4"
|
||||
|
||||
# 打印提取的部分
|
||||
print(f"SCHEME:{protocol}")
|
||||
print(f"USERNAME:{username}")
|
||||
print(f"PASSWORD:{password}")
|
||||
print(f"HOST:{hostname}")
|
||||
print(f"PORT:{port}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 参数不全,直接返回空解析结果
|
||||
if len(sys.argv) != 2:
|
||||
print(f"SCHEME:''")
|
||||
print(f"USERNAME:''")
|
||||
print(f"PASSWORD:''")
|
||||
print(f"HOST:''")
|
||||
print(f"PORT:''")
|
||||
|
||||
# 参数全,解析URL
|
||||
PROXY_HOST = sys.argv[1]
|
||||
parse_url(url=PROXY_HOST)
|
||||
Reference in New Issue
Block a user