mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
增加PROXY_SUPPLEMENT变量
1、增加proxychains4模块,用于解决pip在socks5代理时,pip无法使用全局代理的问题 2、增加`PROXY_SUPPLEMENT`变量,可以手动控制,实现使用镜像站进行更新时,但缺少pip镜像站或者GitHub镜像站时,可以使用全局代理补全缺失的代理
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import secrets
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import sys
|
||||
import threading
|
||||
from pathlib import Path
|
||||
@@ -148,6 +150,8 @@ class Settings(BaseSettings):
|
||||
GITHUB_PROXY: Optional[str] = ''
|
||||
# pip镜像站点,格式:https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
PIP_PROXY: Optional[str] = ''
|
||||
# 代理补全开关,支持 True、False, 在没有配置镜像站的时候,True 使用 PROXY_HOST 补全镜像站缺失,False 在没有配置镜像站的时候,不使用全局补全
|
||||
PROXY_SUPPLEMENT: bool = True
|
||||
# 大内存模式
|
||||
BIG_MEMORY_MODE: bool = False
|
||||
|
||||
@@ -226,6 +230,58 @@ class Settings(BaseSettings):
|
||||
}
|
||||
return None
|
||||
|
||||
@property
|
||||
def PROXY_URLPARSE(self, url: str = PROXY_HOST):
|
||||
"""
|
||||
解析地址组成 - 允许其他地址调用
|
||||
"""
|
||||
if url:
|
||||
# 解析 URL
|
||||
parsed_url = urlparse(url)
|
||||
# 协议
|
||||
protocol = parsed_url.scheme or ""
|
||||
# 用户名
|
||||
username = parsed_url.username or ""
|
||||
# 密码
|
||||
password = parsed_url.password or ""
|
||||
# 主机
|
||||
host = parsed_url.hostname or ""
|
||||
# 端口:
|
||||
port = parsed_url.port or ""
|
||||
# 路径
|
||||
path = parsed_url.path or ""
|
||||
# 用户名:密码@主机:端口
|
||||
netloc = parsed_url.netloc or ""
|
||||
# 查询参数: ?key=value
|
||||
query = parsed_url.query or ""
|
||||
# 使用;分割的参数
|
||||
params = parsed_url.params or ""
|
||||
# 片段: #fragment
|
||||
fragment = parsed_url.fragment or ""
|
||||
|
||||
if not port:
|
||||
if protocol == "https":
|
||||
port = 443
|
||||
elif protocol == "http":
|
||||
port = 80
|
||||
elif protocol in {"socks5", "socks5h", "socks4", "socks4a"}:
|
||||
port = 1080
|
||||
|
||||
# 返回解析结果
|
||||
return {
|
||||
"protocol": protocol,
|
||||
"username": username,
|
||||
"password": password,
|
||||
"host": host,
|
||||
"port": port,
|
||||
"path": path,
|
||||
"netloc": netloc,
|
||||
"query": query,
|
||||
"params": params,
|
||||
"fragment": fragment
|
||||
}
|
||||
return None
|
||||
|
||||
@property
|
||||
def PROXY_SERVER(self):
|
||||
if self.PROXY_HOST:
|
||||
|
||||
Reference in New Issue
Block a user