mirror of
https://github.com/Remik1r3n/maimaiDX-Api.git
synced 2025-06-15 16:57: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
|
retries = 0
|
||||||
while retries < maxRetries:
|
while retries < maxRetries:
|
||||||
try:
|
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),
|
url=endpoint + getSDGBApiHash(targetApi),
|
||||||
headers={
|
headers={
|
||||||
"User-Agent": f"{getSDGBApiHash(targetApi)}#{agentExtra}",
|
"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,
|
content=reqData_deflated,
|
||||||
# 经测试,加 Verify 之后速度慢好多,因此建议选择性开
|
# 经测试,加 Verify 之后速度慢好多,因此建议选择性开
|
||||||
#verify=certifi.where(),
|
#verify=certifi.where(),
|
||||||
verify=False,
|
#verify=False,
|
||||||
timeout=timeout
|
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!")
|
logger.debug("200 OK!")
|
||||||
else:
|
else:
|
||||||
errorMessage = f"请求失败: {response.status_code}"
|
errorMessage = f"请求失败: {responseOriginal.status_code}"
|
||||||
logger.error(errorMessage)
|
logger.error(errorMessage)
|
||||||
raise SDGBRequestError(errorMessage)
|
raise SDGBRequestError(errorMessage)
|
||||||
|
|
||||||
responseRAWContent = response.content
|
responseRAWContent = responseOriginal.content
|
||||||
|
|
||||||
try:
|
try:
|
||||||
responseDecompressed = zlib.decompress(responseRAWContent)
|
responseDecompressed = zlib.decompress(responseRAWContent)
|
||||||
|
@ -4,6 +4,9 @@ placeId = 3490
|
|||||||
placeName = "赛博时空枣庄市中店"
|
placeName = "赛博时空枣庄市中店"
|
||||||
clientId = "A63E01E9564"
|
clientId = "A63E01E9564"
|
||||||
|
|
||||||
|
useProxy = True
|
||||||
|
proxyUrl = "http://100.104.133.113:33080"
|
||||||
|
|
||||||
loginBonusDBPath = "./Data/loginBonusDB.json"
|
loginBonusDBPath = "./Data/loginBonusDB.json"
|
||||||
musicDBPath = "./Data/musicDB.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