mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-02-11 22:47:18 +08:00
1、删除`proxychains4`模块支持,`pip`代理已支持全局模式下的`socks4`、`socks4a`、`socks5`、`socks5h`、`http`、`https`协议; 2、删除`PROXY_SUPPLEMENT`变量,取消手动控制功能; 3、增加自动判断,将`pip`与`update`的代理判断,从手动改为自动,优先级:镜像站 > 全局 > 不代理; 4、将`pip`的附加代理参数,作为只读属性`PIP_OPTIONS`写入到`config`中,其他对象可通过`settings.PIP_OPTIONS`实现快速调用。
43 lines
973 B
Python
43 lines
973 B
Python
import sys
|
||
from urllib.parse import urlparse
|
||
|
||
|
||
def parse_url(url):
|
||
parsed_url = urlparse(url)
|
||
|
||
# 提取各个部分
|
||
protocol = parsed_url.scheme 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
|
||
|
||
if protocol:
|
||
protocol = protocol.lower()
|
||
|
||
# 打印提取的部分
|
||
print(f"SCHEME:{protocol}")
|
||
print(f"HOST:{hostname}")
|
||
print(f"PORT:{port}")
|
||
|
||
|
||
if __name__ == "__main__":
|
||
# 参数不全,直接返回空解析结果
|
||
if len(sys.argv) != 2:
|
||
print(f"SCHEME:''")
|
||
print(f"HOST:''")
|
||
print(f"PORT:''")
|
||
# 参数全,解析URL
|
||
else:
|
||
PROXY_HOST = sys.argv[1]
|
||
parse_url(url=PROXY_HOST)
|