from flask import Blueprint, request # Import necessary functions
from kbinxml import KBinXML
from lz77 import lz77_compress
from urllib.parse import parse_qs
from variables.protocols import Respond
import re
bp = Blueprint(
"getResources", __name__, url_prefix="/"
) # Create a Blueprint for this route section
getServices = '\n 0\n 0\n \n 63\n \n addPoint\n url/iidx/needAuth/AddPoint\n \n \n addPointDirect\n url/iidx/needAuth/AddPointDirect\n \n \n cancelReserveChangePoint\n url/iidx/needAuth/CancelReserveChangePoint\n \n \n cancelReserveConsumeItem\n url/iidx/needAuth/CancelReserveConsumeItem\n \n \n checkChampionshipInfo\n url/needlessAuth/CheckChampionshipInfo\n \n \n checkGameStart\n url/common/needAuth/CheckGameStart\n \n \n checkGameVersion\n url/needlessAuth/CheckGameVersion\n \n \n checkPlayData\n url/iidx/needAuth/CheckPlayData\n \n \n checkPlayableMusicList\n url/iidx/needAuth/CheckPlayableMusicList\n \n \n checkSendLogAvailable\n url/needlessAuth/CheckSendLogAvailable\n \n \n checkTakeover\n url/iidx/needAuth/CheckTakeover\n \n \n checkUpdate\n url/needlessAuth/CheckUpdate\n \n \n checkVersion\n url/needlessAuth/CheckLauncherVersion\n \n \n consumeItem\n url/iidx/needAuth/ConsumeItem\n \n \n gameEnd\n url/iidx/needAuth/GameEnd\n \n \n getAdvertise\n url/needlessAuth/GetAdvertise\n \n \n getChampionshipInfo\n url/needlessAuth/GetChampionshipInfo\n \n \n getChampionshipRank\n url/iidx/needAuth/GetChampionshipRank\n \n \n getChampionshipRecord\n url/iidx/needAuth/GetChampionshipRecord\n \n \n getClearRate\n url/needlessAuth/GetClearRate\n \n \n getCompeScoreData\n url/iidx/needAuth/GetCompeScoreData\n \n \n getCustomizeSetting\n url/iidx/needAuth/GetCustomizeSetting\n \n \n getDownloadResource\n https://d1rc4pwxnc0pe0.cloudfront.net/v3/resource/distribution/ondemand\n \n \n getGoodsList\n url/needlessAuth/GetGoodsList\n \n \n getHash\n url/needlessAuth/GetHash\n \n \n getInformation\n url/needlessAuth/GetInformation\n \n \n getItemList\n url/iidx/needAuth/GetItemList\n \n \n getItemNum\n url/iidx/needAuth/GetItemNum\n \n \n getMusicData\n url/iidx/needAuth/GetMusicData\n \n \n getMusicGhost\n url/iidx/needAuth/GetMusicGhost\n \n \n getMusicList\n url/iidx/needAuth/GetMusicList\n \n \n getPackageList\n url/needlessAuth/GetPackageList\n \n \n getPlayData\n url/iidx/needAuth/GetPlayData\n \n \n getPlayableMusicList\n url/iidx/needAuth/GetPlayableMusicList\n \n \n getPointList\n url/iidx/needAuth/GetPointList\n \n \n getPrivilegeClient\n url/iidx/needAuth/GetPrivilegeClient\n \n \n getPrivilegeServer\n url/iidx/needAuth/GetPrivilegeServer\n \n \n getResourceInfo\n url/needlessAuth/GetFile\n \n \n getRival\n url/iidx/needAuth/GetRival\n \n \n getRivalChallenge\n url/iidx/needAuth/GetRivalChallenge\n \n \n getRivalInfo\n url/iidx/needAuth/GetRivalInfo\n \n \n getServerClock\n url/preProcess/GetServerClock\n \n \n getServerState\n url/preProcess/GetServerState\n \n \n getServerValues\n url/common/needAuth/GetServerValues\n \n \n getServices\n url/iidx/preProcess/GetServices\n \n \n getTemporaryFiles\n url/needlessAuth/GetTemporaryFiles\n \n \n heartbeat\n url/common/needAuth/Heartbeat\n \n \n loginEX\n https://p.eagate.573.jp/game/eac2dx/infinitas/API/page/loginEX.html\n \n \n registPlayer\n url/iidx/needAuth/RegistPlayer\n \n \n reportMusicResult\n url/iidx/needAuth/ReportMusicResult\n \n \n reserveChangePoint\n url/iidx/needAuth/ReserveChangePoint\n \n \n reserveConsumeItem\n url/iidx/needAuth/ReserveConsumeItem\n \n \n saveChampionshipRecord\n url/iidx/needAuth/SaveChampionshipRecord\n \n \n savePlayData\n url/iidx/needAuth/SavePlayData\n \n \n sendGradeCertificationLog\n url/iidx/needAuth/SendGradeCertificationLog\n \n \n sendLog\n url/needlessAuth/SendLog\n \n \n unlockMusic\n url/iidx/needAuth/UnlockMusic\n \n \n uploadFile\n url/needlessAuth/UploadFileMultipart\n \n \n urlAgreement\n https://p.eagate.573.jp/game/infinitas/2/jump/agreement.html\n \n \n urlEaShop\n https://p.eagate.573.jp/game/eac2dx/jump/eashop.html\n \n \n urlKAC5th\n http://p.eagate.573.jp/game/kac5th/detail.html?id=infinitas&group=outline&lang=ja\n \n \n usePoint\n url/iidx/needAuth/UsePoint\n \n \n usePointDirect\n url/iidx/needAuth/UsePointDirect\n \n \n'
getServicesEACNET = '\n 0\n 0\n \n 18\n \n acRelay\n url/eacnet/needAuth/AcRelay\n \n \n cancelReserveConsumeItem\n url/eacnet/needAuth/CancelReserveConsumeItem\n \n \n checkGameStart\n url/common/needAuth/CheckGameStart\n \n \n checkVersion\n url/needlessAuth/CheckVersion\n \n \n consumeItem\n url/eacnet/needAuth/ConsumeItem\n \n \n getGoodsList\n url/needlessAuth/GetGoodsList\n \n \n getHash\n url/needlessAuth/GetHash\n \n \n getItemList\n url/eacnet/needAuth/GetItemList\n \n \n getLauncherData\n url/needlessAuth/GetLauncherData\n \n \n getResourceInfo\n url/needlessAuth/GetResourceInfo\n \n \n getServerClock\n url/preProcess/GetServerClock\n \n \n getServerState\n url/preProcess/GetServerStatus\n \n \n getServices\n url/eacnet/preProcess/GetServices\n \n \n getSubscriptionStatus\n url/eacnet/needAuth/GetSubscriptionStatus\n \n \n getUserIDs\n url/eacnet/needAuth/GetUserId\n \n \n heartbeat\n url/common/needAuth/Heartbeat\n \n \n reserveConsumeItem\n url/eacnet/needAuth/ReserveConsumeItem\n \n \n uploadFile\n url/needlessAuth/UploadFile\n \n \n'
@bp.route("/", methods=["GET", "POST"])
@bp.route(
"/game/konasteapp/APIEX/servletex/pre_process/GetServices", methods=["GET", "POST"]
)
def handle_request():
if request.method == "POST":
# Access post data
post_data = request.get_data().decode("UTF-8")
print(request.url_root)
variables = parse_qs(post_data)
headers = request.headers
host = request.host
if variables["protocol_version"][0] == "P2D:2015091800":
response = KBinXML(
re.sub(r"url/", "http://" + host + "/", getServices).encode()
) # re.sub() with host
else:
response = KBinXML(
re.sub(r"url/", "http://" + host + "/", getServicesEACNET).encode()
) # re.sub() with host
binary_data = response.to_binary()
if isinstance(binary_data, str):
binary_data = binary_data.encode("utf-8")
return Respond(binary_data,variables["protocol_version"][0])
elif request.method == "GET":
# GET logic
# Example: Return a simple response
return "Server Online & Accepting Requests."
return "Invalid request method"
# Optional: You can define more routes within this file