mirror of
https://github.com/Remik1r3n/maimaiDX-Api.git
synced 2025-06-15 07:27:29 +08:00
提供 requirements.txt,TitleServer支持配置Http代理
This commit is contained in:
parent
b78df68d5c
commit
00776f330d
@ -75,7 +75,15 @@ def apiSDGB(data:str, targetApi:str, userAgentExtraData:str, noLog:bool=False, t
|
||||
retries = 0
|
||||
while retries < maxRetries:
|
||||
try:
|
||||
response = httpx.post(
|
||||
if useProxy:
|
||||
# 使用代理
|
||||
logger.debug("使用代理")
|
||||
httpClient = httpx.Client(proxy=proxyUrl, verify=False)
|
||||
else:
|
||||
# 不使用代理
|
||||
logger.debug("不使用代理")
|
||||
httpClient = httpx.Client(verify=False)
|
||||
responseOriginal = httpClient.post(
|
||||
url=endpoint + getSDGBApiHash(targetApi),
|
||||
headers={
|
||||
"User-Agent": f"{getSDGBApiHash(targetApi)}#{agentExtra}",
|
||||
@ -89,20 +97,21 @@ def apiSDGB(data:str, targetApi:str, userAgentExtraData:str, noLog:bool=False, t
|
||||
content=reqData_deflated,
|
||||
# 经测试,加 Verify 之后速度慢好多,因此建议选择性开
|
||||
#verify=certifi.where(),
|
||||
verify=False,
|
||||
#verify=False,
|
||||
timeout=timeout
|
||||
)
|
||||
if not noLog:
|
||||
logger.info(f"{targetApi} 请求结果: {response.status_code}")
|
||||
|
||||
if response.status_code == 200:
|
||||
if not noLog:
|
||||
logger.info(f"{targetApi} 请求结果: {responseOriginal.status_code}")
|
||||
|
||||
if responseOriginal.status_code == 200:
|
||||
logger.debug("200 OK!")
|
||||
else:
|
||||
errorMessage = f"请求失败: {response.status_code}"
|
||||
errorMessage = f"请求失败: {responseOriginal.status_code}"
|
||||
logger.error(errorMessage)
|
||||
raise SDGBRequestError(errorMessage)
|
||||
|
||||
responseRAWContent = response.content
|
||||
responseRAWContent = responseOriginal.content
|
||||
|
||||
try:
|
||||
responseDecompressed = zlib.decompress(responseRAWContent)
|
||||
|
@ -4,6 +4,9 @@ placeId = 3490
|
||||
placeName = "赛博时空枣庄市中店"
|
||||
clientId = "A63E01E9564"
|
||||
|
||||
useProxy = True
|
||||
proxyUrl = "http://100.104.133.113:33080"
|
||||
|
||||
loginBonusDBPath = "./Data/loginBonusDB.json"
|
||||
musicDBPath = "./Data/musicDB.json"
|
||||
|
||||
|
7
requirements.txt
Normal file
7
requirements.txt
Normal file
@ -0,0 +1,7 @@
|
||||
pycryptodome
|
||||
requests
|
||||
httpx
|
||||
python-rapidjson
|
||||
pytz
|
||||
loguru
|
||||
datetime
|
Loading…
x
Reference in New Issue
Block a user