use httpx instead of requests

This commit is contained in:
91c0e59d-6161-45ab-8aa4-2371574db28f 2025-01-25 10:40:43 +08:00
parent 5e83dfc8c5
commit a4fe8208d9
4 changed files with 19 additions and 25 deletions

View File

@ -1,3 +1,3 @@
requests httpx
pycryptodome pycryptodome
pytz pytz

View File

@ -1,24 +1,22 @@
import base64 import base64
import urllib3
import zlib import zlib
import re import re
import httpx
def DownloadOrder(): def DownloadOrder():
ua = 'Windows/3.0' ua = 'Windows/3.0'
content = b'game_id=SDGA&ver=1.50&serial=A63E01E0048&encode=UTF-8' content = b'game_id=SDGA&ver=1.50&serial=A63E01E0048&encode=UTF-8'
body = base64.b64encode(zlib.compress(content)) body = base64.b64encode(zlib.compress(content))
http = urllib3.PoolManager() r = httpx.post(
r = http.request(
'POST',
'http://naominet.jp/sys/servlet/DownloadOrder', 'http://naominet.jp/sys/servlet/DownloadOrder',
body = body, data = body,
headers = { headers = {
'Pragma': 'DFI', 'Pragma': 'DFI',
'User-Agent': ua, 'User-Agent': ua,
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
} }
) )
resp_data = r.data resp_data = r.content
response = zlib.decompress(base64.b64decode(resp_data)).decode() response = zlib.decompress(base64.b64decode(resp_data)).decode()
return response return response
@ -26,15 +24,13 @@ def uri():
data = DownloadOrder() data = DownloadOrder()
pattern = r"https://[^\s]+" pattern = r"https://[^\s]+"
endpoint = re.search(pattern, data).group() endpoint = re.search(pattern, data).group()
http = urllib3.PoolManager() r = httpx.get(
r = http.request(
'GET',
endpoint, endpoint,
headers = { headers = {
'User-Agent': 'A63E01E0000', 'User-Agent': 'A63E01E0000',
} }
) )
resp_data = r.data resp_data = r.content
response = resp_data.decode() response = resp_data.decode()
return response return response

View File

@ -2,7 +2,7 @@ import json
import zlib import zlib
import pytz import pytz
import hashlib import hashlib
import requests import httpx
from binascii import unhexlify, hexlify from binascii import unhexlify, hexlify
import socket import socket
@ -57,16 +57,15 @@ def sdgb_api(data, useApi, userId):
data_def = zlib.compress(data) data_def = zlib.compress(data)
data_enc = aes.encrypt(data_def) data_enc = aes.encrypt(data_def)
endpoint = "https://mai2exp.sic-rd1.jp:42081/Maimai2Servlet/" endpoint = "https://mai2exp.sic-rd1.jp:42081/Maimai2Servlet/"
requests.packages.urllib3.disable_warnings() r = httpx.post(
r = requests.post(
endpoint + get_hash_api(useApi), endpoint + get_hash_api(useApi),
headers = { headers = {
"User-Agent": "%s#%d"%(get_hash_api(useApi), userId), "User-Agent": "%s#%d"%(get_hash_api(useApi), userId),
"Content-Type": "application/json", "Content-Type": "application/json",
"Mai-Encoding": "1.51", "Mai-Encoding": "1.51",
"Accept-Encoding": "", "Accept-Encoding": "",
"Charset": "UTF-8", "Charset": "UTF-8",
"Content-Encoding": "deflate", "Content-Encoding": "deflate",
"Expect": "100-continue" "Expect": "100-continue"
}, },
data = data_enc data = data_enc
@ -86,8 +85,8 @@ def felica(IDm):
command_id = "0100" # ID = 1 command_id = "0100" # ID = 1
length = "3000" # 48 length = "3000" # 48
gameId = "534447410000" # SDGA gameId = "534447410000" # SDGA
storeId = "bc310000" storeId = "aa1e0000"
keychip_ID = "413633453031453032363400" # A63E01E0264 keychip_ID = "413633453031453031383200" # A63E01E0264
header = magic + version + command_id + length + "0000" + gameId + storeId + keychip_ID header = magic + version + command_id + length + "0000" + gameId + storeId + keychip_ID
IDm = str(IDm) IDm = str(IDm)
@ -113,7 +112,7 @@ def felica(IDm):
decrypted_hex_stream = hexlify(decrypted_response).decode('utf-8') decrypted_hex_stream = hexlify(decrypted_response).decode('utf-8')
return decrypted_hex_stream return decrypted_hex_stream[-24:-4]
def aimedb_api(accessCode): def aimedb_api(accessCode):
key = b'Copyright(C)SEGA' key = b'Copyright(C)SEGA'
@ -123,8 +122,8 @@ def aimedb_api(accessCode):
command_id = "0f00" # ID = 15 command_id = "0f00" # ID = 15
length = "3000" # 48 length = "3000" # 48
gameId = "534447410000" # SDGA gameId = "534447410000" # SDGA
storeId = "bc310000" storeId = "aa1e0000"
keychip_ID = "413633453031453032363400" # A63E01E0264 keychip_ID = "413633453031453031383200" # A63E01E0264
header = magic + version + command_id + length + "0000" + gameId + storeId + keychip_ID header = magic + version + command_id + length + "0000" + gameId + storeId + keychip_ID
access_code = str(accessCode) access_code = str(accessCode)

View File

@ -3,7 +3,7 @@ import zlib
import pytz import pytz
import base64 import base64
import hashlib import hashlib
import requests import httpx
from datetime import datetime from datetime import datetime
from Crypto.Cipher import AES from Crypto.Cipher import AES
@ -56,9 +56,8 @@ def sdgb_api(data, useApi, userId):
data = data data = data
data_enc = aes.encrypt(data) data_enc = aes.encrypt(data)
data_def = zlib.compress(data_enc) data_def = zlib.compress(data_enc)
requests.packages.urllib3.disable_warnings()
endpoint = "https://maimai-gm.wahlap.com:42081/Maimai2Servlet/" endpoint = "https://maimai-gm.wahlap.com:42081/Maimai2Servlet/"
r = requests.post( r = httpx.post(
endpoint + get_hash_api(useApi), endpoint + get_hash_api(useApi),
headers = { headers = {
"User-Agent": "%s#%d"%(get_hash_api(useApi), userId), "User-Agent": "%s#%d"%(get_hash_api(useApi), userId),