use httpx instead of requests
This commit is contained in:
parent
5e83dfc8c5
commit
a4fe8208d9
@ -1,3 +1,3 @@
|
||||
requests
|
||||
httpx
|
||||
pycryptodome
|
||||
pytz
|
@ -1,24 +1,22 @@
|
||||
import base64
|
||||
import urllib3
|
||||
import zlib
|
||||
import re
|
||||
import httpx
|
||||
|
||||
def DownloadOrder():
|
||||
ua = 'Windows/3.0'
|
||||
content = b'game_id=SDGA&ver=1.50&serial=A63E01E0048&encode=UTF-8'
|
||||
body = base64.b64encode(zlib.compress(content))
|
||||
http = urllib3.PoolManager()
|
||||
r = http.request(
|
||||
'POST',
|
||||
r = httpx.post(
|
||||
'http://naominet.jp/sys/servlet/DownloadOrder',
|
||||
body = body,
|
||||
data = body,
|
||||
headers = {
|
||||
'Pragma': 'DFI',
|
||||
'User-Agent': ua,
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
)
|
||||
resp_data = r.data
|
||||
resp_data = r.content
|
||||
response = zlib.decompress(base64.b64decode(resp_data)).decode()
|
||||
return response
|
||||
|
||||
@ -26,15 +24,13 @@ def uri():
|
||||
data = DownloadOrder()
|
||||
pattern = r"https://[^\s]+"
|
||||
endpoint = re.search(pattern, data).group()
|
||||
http = urllib3.PoolManager()
|
||||
r = http.request(
|
||||
'GET',
|
||||
r = httpx.get(
|
||||
endpoint,
|
||||
headers = {
|
||||
'User-Agent': 'A63E01E0000',
|
||||
}
|
||||
)
|
||||
resp_data = r.data
|
||||
resp_data = r.content
|
||||
response = resp_data.decode()
|
||||
return response
|
||||
|
||||
|
21
sdga/sdgb.py
21
sdga/sdgb.py
@ -2,7 +2,7 @@ import json
|
||||
import zlib
|
||||
import pytz
|
||||
import hashlib
|
||||
import requests
|
||||
import httpx
|
||||
|
||||
from binascii import unhexlify, hexlify
|
||||
import socket
|
||||
@ -57,16 +57,15 @@ def sdgb_api(data, useApi, userId):
|
||||
data_def = zlib.compress(data)
|
||||
data_enc = aes.encrypt(data_def)
|
||||
endpoint = "https://mai2exp.sic-rd1.jp:42081/Maimai2Servlet/"
|
||||
requests.packages.urllib3.disable_warnings()
|
||||
r = requests.post(
|
||||
r = httpx.post(
|
||||
endpoint + get_hash_api(useApi),
|
||||
headers = {
|
||||
"User-Agent": "%s#%d"%(get_hash_api(useApi), userId),
|
||||
"User-Agent": "%s#%d"%(get_hash_api(useApi), userId),
|
||||
"Content-Type": "application/json",
|
||||
"Mai-Encoding": "1.51",
|
||||
"Accept-Encoding": "",
|
||||
"Charset": "UTF-8",
|
||||
"Content-Encoding": "deflate",
|
||||
"Charset": "UTF-8",
|
||||
"Content-Encoding": "deflate",
|
||||
"Expect": "100-continue"
|
||||
},
|
||||
data = data_enc
|
||||
@ -86,8 +85,8 @@ def felica(IDm):
|
||||
command_id = "0100" # ID = 1
|
||||
length = "3000" # 48
|
||||
gameId = "534447410000" # SDGA
|
||||
storeId = "bc310000"
|
||||
keychip_ID = "413633453031453032363400" # A63E01E0264
|
||||
storeId = "aa1e0000"
|
||||
keychip_ID = "413633453031453031383200" # A63E01E0264
|
||||
header = magic + version + command_id + length + "0000" + gameId + storeId + keychip_ID
|
||||
|
||||
IDm = str(IDm)
|
||||
@ -113,7 +112,7 @@ def felica(IDm):
|
||||
|
||||
decrypted_hex_stream = hexlify(decrypted_response).decode('utf-8')
|
||||
|
||||
return decrypted_hex_stream
|
||||
return decrypted_hex_stream[-24:-4]
|
||||
|
||||
def aimedb_api(accessCode):
|
||||
key = b'Copyright(C)SEGA'
|
||||
@ -123,8 +122,8 @@ def aimedb_api(accessCode):
|
||||
command_id = "0f00" # ID = 15
|
||||
length = "3000" # 48
|
||||
gameId = "534447410000" # SDGA
|
||||
storeId = "bc310000"
|
||||
keychip_ID = "413633453031453032363400" # A63E01E0264
|
||||
storeId = "aa1e0000"
|
||||
keychip_ID = "413633453031453031383200" # A63E01E0264
|
||||
header = magic + version + command_id + length + "0000" + gameId + storeId + keychip_ID
|
||||
|
||||
access_code = str(accessCode)
|
||||
|
@ -3,7 +3,7 @@ import zlib
|
||||
import pytz
|
||||
import base64
|
||||
import hashlib
|
||||
import requests
|
||||
import httpx
|
||||
|
||||
from datetime import datetime
|
||||
from Crypto.Cipher import AES
|
||||
@ -56,9 +56,8 @@ def sdgb_api(data, useApi, userId):
|
||||
data = data
|
||||
data_enc = aes.encrypt(data)
|
||||
data_def = zlib.compress(data_enc)
|
||||
requests.packages.urllib3.disable_warnings()
|
||||
endpoint = "https://maimai-gm.wahlap.com:42081/Maimai2Servlet/"
|
||||
r = requests.post(
|
||||
r = httpx.post(
|
||||
endpoint + get_hash_api(useApi),
|
||||
headers = {
|
||||
"User-Agent": "%s#%d"%(get_hash_api(useApi), userId),
|
||||
|
Loading…
x
Reference in New Issue
Block a user