Compare commits

..

1 Commits

Author SHA1 Message Date
Katboi01 dde3c27eb0 uncommited changes 2024-12-26 16:02:30 +01:00
8 changed files with 105 additions and 68 deletions

6
app.py
View File

@ -3,7 +3,7 @@ from flask_restful import Api
from modules.KF3.database import Database as KF3DB from modules.KF3.database import Database as KF3DB
from modules.Kingdom.database import Database as KFKDB from modules.Kingdom.database import Database as KFKDB
from modules.proxy import AgreementProxy, LaunchProxy, UpdateProxy from modules.JapariSling.database import Database as KFSL
app = Flask(__name__) app = Flask(__name__)
app.config['JSON_AS_ASCII'] = False app.config['JSON_AS_ASCII'] = False
@ -11,11 +11,9 @@ app.databases = {}
api = Api(app) api = Api(app)
api.add_resource(LaunchProxy, "/DMM/launch")
api.add_resource(UpdateProxy, "/DMM/filelist", "/DMM/update")
api.add_resource(AgreementProxy, "/DMM/agreement")
KF3DB(api) KF3DB(api)
KFKDB(api) KFKDB(api)
KFSL(api)
if __name__ == '__main__': if __name__ == '__main__':
app.run(host='127.0.0.1', port=8080, debug=True) app.run(host='127.0.0.1', port=8080, debug=True)

View File

@ -0,0 +1,7 @@
from typing import List
from .construct_serialized import ConstructSerialized
class ConstructLevel:
Name : str
Description : str
Objects : List[ConstructSerialized]

View File

@ -0,0 +1,13 @@
class SVector3:
x : float
y : float
z : float
class ConstructSerialized:
Id : int
Variant : int
Position : SVector3
Rotation : SVector3
Width : float
Height : float
Properties : int

View File

@ -0,0 +1,15 @@
from .endpoints.get import Get
from .endpoints.upload import Upload
class Database:
def __init__(self, api) -> None:
app = api.app
if "JapariSling" in app.databases:
del app.databases["JapariSling"]
app.databases["JapariSling"] = self
api.add_resource(Upload, "/JapariSling/Upload")
api.add_resource(Get, "/JapariSling/Get")

View File

@ -0,0 +1,23 @@
import os
import json
from flask_restful import Resource
from flask import abort, request, current_app as app
class Get(Resource):
def get(self):
dir_name = os.path.join(app.root_path, 'data', 'JapariSling')
files = [json.loads(read_file(os.path.join(dir_name, f))) for f in os.listdir(dir_name) if os.path.isfile(os.path.join(dir_name, f))]
files = files[:10]
files = {"levels": files}
response = app.response_class(
response = json.dumps(files),
status=200,
mimetype='application/json'
)
response.headers.add("Access-Control-Allow-Origin", "*")
return response
def read_file(path):
with open(path, 'r') as f:
return f.read()

View File

@ -0,0 +1,29 @@
import os
import json
from flask_restful import Resource
from ..classes.construct_level import ConstructLevel
from flask import abort, request, current_app as app
class Upload(Resource):
def post(self):
cl = request.content_length
if cl is not None and cl > 1024:
abort(413)
content = request.json
if "Name" not in content:
abort(400)
filename = os.path.join(app.root_path, 'data', 'JapariSling', content["Name"] + '.json')
with open(filename, "wt") as text_file:
text_file.write(json.dumps(content, ensure_ascii=False, indent=1))
response = app.response_class(
response="level uploaded",
status=200,
mimetype='text/plain'
)
response.headers.add("Access-Control-Allow-Origin", "*")
return response

View File

@ -239,24 +239,24 @@ async def manual():
downloaded_cache = {} downloaded_cache = {}
downloaded_files = {} downloaded_files = {}
# async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
# param = encode(json.dumps({"version":"1.0.0","dmm_viewer_id":0,"platform":1})) param = encode(json.dumps({"version":"1.0.0","dmm_viewer_id":0,"platform":1}))
# request = await download_bytes(servers[0] + "paradesv/common/GetUrl.do?param=" + param, session) request = await download_bytes(servers[0] + "paradesv/common/GetUrl.do?param=" + param, session)
# result = gzip.decompress(request) result = gzip.decompress(request)
# response = json.loads(result) response = json.loads(result)
# asset_bundle_url = response["asset_bundle_url"] asset_bundle_url = response["asset_bundle_url"]
# urlName = asset_bundle_url.split("-")[2] urlName = asset_bundle_url.split("-")[2]
# print("downloading from", servers[0]) print("downloading from", servers[0])
# downloaded_cache = await download_cache(urlName, servers[0]) downloaded_cache = await download_cache(urlName, servers[0])
# downloaded_files = await download_files(urlName, asset_bundle_url, "Windows") downloaded_files = await download_files(urlName, asset_bundle_url, "Windows")
# if downloaded_cache != [] and downloaded_cache != None: if downloaded_cache != [] and downloaded_cache != None:
# with open("/var/www/html/Katworks/KF/assets/KF3/lastUpdate_prod_cache.json", "wt", encoding="utf-8") as file: with open("/var/www/html/Katworks/KF/assets/KF3/lastUpdate_prod_cache.json", "wt", encoding="utf-8") as file:
# json.dump(downloaded_cache, file, ensure_ascii=False, indent=1) json.dump(downloaded_cache, file, ensure_ascii=False, indent=1)
# if downloaded_files != [] and downloaded_files != None: if downloaded_files != [] and downloaded_files != None:
# with open("/var/www/html/Katworks/KF/assets/KF3/lastUpdate_prod_files.json", "wt", encoding="utf-8") as file: with open("/var/www/html/Katworks/KF/assets/KF3/lastUpdate_prod_files.json", "wt", encoding="utf-8") as file:
# json.dump(downloaded_files, file, ensure_ascii=False, indent=1) json.dump(downloaded_files, file, ensure_ascii=False, indent=1)
print("downloading from", servers[1]) print("downloading from", servers[1])
asset_bundle_url = "https://parade-mobile-develop01-app.kemono-friends-3.jp/AssetBundles/0.0.0/latest" asset_bundle_url = "https://parade-mobile-develop01-app.kemono-friends-3.jp/AssetBundles/0.0.0/latest"

View File

@ -1,48 +0,0 @@
from flask_restful import Resource
from flask import current_app as app, request, Request
import requests
def relayRequest(user_request : Request, url, headers):
with requests.Session() as session:
requests.utils.add_dict_to_cookiejar(session.cookies, user_request.cookies)
response = session.post(url, headers=headers, data=request.data)
result = app.response_class(
response=response.text,
status=200,
mimetype='application/json'
)
result.headers.add("Access-Control-Allow-Origin", "*")
return result
class LaunchProxy(Resource):
def post(self):
url = "https://apidgp-gameplayer.games.dmm.com/v5/launch/cl"
headers = {"User-Agent": "DMMGamePlayer5-Win/5.3.12 Electron/32.1.0",
"Client-App": "DMMGamePlayer5",
"Client-version": "5.3.12",
"Content-Type": "application/json"}
return relayRequest(request, url, headers)
class UpdateProxy(Resource):
def post(self):
url = "https://apidgp-gameplayer.games.dmm.com/v5/r2/launch/cl"
headers = {"User-Agent": "DMMGamePlayer5-Win/5.3.12 Electron/32.1.0",
"Client-App": "DMMGamePlayer5",
"Client-version": "5.3.12",
"Content-Type": "application/json"}
return relayRequest(request, url, headers)
class AgreementProxy(Resource):
def post(self):
url = "https://apidgp-gameplayer.games.dmm.com/v5/agreement/confirm/client"
headers = {"User-Agent": "DMMGamePlayer5-Win/5.3.12 Electron/32.1.0",
"Client-App": "DMMGamePlayer5",
"Client-version": "5.3.12",
"Content-Type": "application/json"}
return relayRequest(request, url, headers)