mirror of
https://github.com/drmext/MonkeyBusiness.git
synced 2025-02-13 00:54:35 +01:00
GITADORA endpoints for frontend
This commit is contained in:
parent
11827f967b
commit
789c28f198
@ -8,7 +8,7 @@ for experimental local testing and playing
|
||||
|
||||
## Instructions
|
||||
|
||||
1. Install [python](https://www.python.org/ftp/python/3.11.3/python-3.11.3-amd64.exe) with "Add python.exe to PATH" checked
|
||||
1. Install [python](https://www.python.org/ftp/python/3.11.4/python-3.11.4-amd64.exe) with "Add python.exe to PATH" checked
|
||||
|
||||
1. Run [start.bat (Windows)](start.bat) or [start.sh (Linux)](start.sh)
|
||||
|
||||
@ -60,3 +60,7 @@ Scores can be [imported](utils/db) from any network
|
||||
Extract [BounceTrippy](https://github.com/drmext/BounceTrippy/releases) webui to the server folder
|
||||
|
||||
- DDR
|
||||
|
||||
- IIDX
|
||||
|
||||
- GITADORA
|
||||
|
175
modules/gitadora/api.py
Normal file
175
modules/gitadora/api.py
Normal file
@ -0,0 +1,175 @@
|
||||
from fastapi import APIRouter, Request, Response
|
||||
|
||||
from core_common import core_process_request, core_prepare_response, E
|
||||
|
||||
from tinydb import Query, where
|
||||
from core_database import get_db
|
||||
from pydantic import BaseModel
|
||||
|
||||
import config
|
||||
import utils.card as conv
|
||||
|
||||
|
||||
router = APIRouter(prefix="/gfdm", tags=["api_gfdm"])
|
||||
|
||||
|
||||
class GFDM_Profile_Main_Items(BaseModel):
|
||||
card: str
|
||||
pin: str
|
||||
|
||||
|
||||
class GFDM_Profile_Version_Items(BaseModel):
|
||||
game_version: int
|
||||
name: str
|
||||
title: str
|
||||
rival_card_ids: list = []
|
||||
|
||||
|
||||
@router.get("/profiles")
|
||||
async def gfdm_profiles():
|
||||
return get_db().table("gitadora_profile").all()
|
||||
|
||||
|
||||
@router.get("/profiles/{gitadora_id}")
|
||||
async def gfdm_profile_id(gitadora_id: str):
|
||||
gitadora_id = int("".join([i for i in gitadora_id if i.isnumeric()]))
|
||||
return get_db().table("gitadora_profile").get(where("gitadora_id") == gitadora_id)
|
||||
|
||||
|
||||
@router.patch("/profiles/{gitadora_id}")
|
||||
async def gfdm_profile_id_patch(gitadora_id: str, item: GFDM_Profile_Main_Items):
|
||||
gitadora_id = int("".join([i for i in gitadora_id if i.isnumeric()]))
|
||||
profile = (
|
||||
get_db().table("gitadora_profile").get(where("gitadora_id") == gitadora_id)
|
||||
)
|
||||
|
||||
profile["card"] = item.card
|
||||
profile["pin"] = item.pin
|
||||
|
||||
get_db().table("gitadora_profile").upsert(
|
||||
profile, where("gitadora_id") == gitadora_id
|
||||
)
|
||||
return Response(status_code=204)
|
||||
|
||||
|
||||
@router.patch("/profiles/{gitadora_id}/{version}")
|
||||
async def gfdm_profile_id_version_patch(
|
||||
gitadora_id: str, version: int, item: GFDM_Profile_Version_Items
|
||||
):
|
||||
gitadora_id = int("".join([i for i in gitadora_id if i.isnumeric()]))
|
||||
profile = (
|
||||
get_db().table("gitadora_profile").get(where("gitadora_id") == gitadora_id)
|
||||
)
|
||||
game_profile = profile["version"].get(str(version), {})
|
||||
|
||||
game_profile["game_version"] = item.game_version
|
||||
game_profile["name"] = item.name
|
||||
game_profile["title"] = item.title
|
||||
game_profile["rival_card_ids"] = item.rival_card_ids
|
||||
|
||||
profile["version"][str(version)] = game_profile
|
||||
get_db().table("gitadora_profile").upsert(
|
||||
profile, where("gitadora_id") == gitadora_id
|
||||
)
|
||||
return Response(status_code=204)
|
||||
|
||||
|
||||
@router.get("/card/{card}")
|
||||
async def gfdm_card_to_profile(card: str):
|
||||
card = card.upper()
|
||||
lookalike = {
|
||||
"I": "1",
|
||||
"O": "0",
|
||||
"Q": "0",
|
||||
"V": "U",
|
||||
}
|
||||
for k, v in lookalike.items():
|
||||
card = card.replace(k, v)
|
||||
if card.startswith("E004") or card.startswith("012E"):
|
||||
card = "".join([c for c in card if c in "0123456789ABCDEF"])
|
||||
uid = card
|
||||
kid = conv.to_konami_id(card)
|
||||
else:
|
||||
card = "".join([c for c in card if c in conv.valid_characters])
|
||||
uid = conv.to_uid(card)
|
||||
kid = card
|
||||
profile = get_db().table("gitadora_profile").get(where("card") == uid)
|
||||
return profile
|
||||
|
||||
|
||||
@router.get("/drummania/scores")
|
||||
async def dm_scores():
|
||||
return get_db().table("drummania_scores").all()
|
||||
|
||||
|
||||
@router.get("/guitarfreaks/scores")
|
||||
async def gf_scores():
|
||||
return get_db().table("guitarfreaks_scores").all()
|
||||
|
||||
|
||||
@router.get("/drummania/scores/{gitadora_id}")
|
||||
async def dm_scores_id(gitadora_id: str):
|
||||
gitadora_id = int("".join([i for i in gitadora_id if i.isnumeric()]))
|
||||
return (
|
||||
get_db().table("drummania_scores").search((where("gitadora_id") == gitadora_id))
|
||||
)
|
||||
|
||||
|
||||
@router.get("/guitarfreaks/scores/{gitadora_id}")
|
||||
async def gf_scores_id(gitadora_id: str):
|
||||
gitadora_id = int("".join([i for i in gitadora_id if i.isnumeric()]))
|
||||
return (
|
||||
get_db()
|
||||
.table("guitarfreaks_scores")
|
||||
.search((where("gitadora_id") == gitadora_id))
|
||||
)
|
||||
|
||||
|
||||
@router.get("/drummania/scores_best")
|
||||
async def dm_scores_best():
|
||||
return get_db().table("drummania_scores_best").all()
|
||||
|
||||
|
||||
@router.get("/guitarfreaks/scores_best")
|
||||
async def gf_scores_best():
|
||||
return get_db().table("guitarfreaks_scores_best").all()
|
||||
|
||||
|
||||
@router.get("/drummania/scores_best/{gitadora_id}")
|
||||
async def dm_scores_best_id(gitadora_id: str):
|
||||
gitadora_id = int("".join([i for i in gitadora_id if i.isnumeric()]))
|
||||
return (
|
||||
get_db()
|
||||
.table("drummania_scores_best")
|
||||
.search((where("gitadora_id") == gitadora_id))
|
||||
)
|
||||
|
||||
|
||||
@router.get("/guitarfreaks/scores_best/{gitadora_id}")
|
||||
async def gf_scores_best_id(gitadora_id: str):
|
||||
gitadora_id = int("".join([i for i in gitadora_id if i.isnumeric()]))
|
||||
return (
|
||||
get_db()
|
||||
.table("guitarfreaks_scores_best")
|
||||
.search((where("gitadora_id") == gitadora_id))
|
||||
)
|
||||
|
||||
|
||||
@router.get("/drummania/mcode/{mcode}/all")
|
||||
async def dm_scores_id(mcode: int):
|
||||
return get_db().table("drummania_scores").search((where("mcode") == mcode))
|
||||
|
||||
|
||||
@router.get("/guitarfreaks/mcode/{mcode}/all")
|
||||
async def gf_scores_id(mcode: int):
|
||||
return get_db().table("guitarfreaks_scores").search((where("mcode") == mcode))
|
||||
|
||||
|
||||
@router.get("/drummania/mcode/{mcode}/best")
|
||||
async def dm_scores_id_best(mcode: int):
|
||||
return get_db().table("drummania_scores_best").search((where("mcode") == mcode))
|
||||
|
||||
|
||||
@router.get("/guitarfreaks/mcode/{mcode}/best")
|
||||
async def gf_scores_id_best(mcode: int):
|
||||
return get_db().table("guitarfreaks_scores_best").search((where("mcode") == mcode))
|
@ -68,18 +68,18 @@ class IIDX_Profile_Version_Items(BaseModel):
|
||||
skin_customize_flag_frame: Optional[int]
|
||||
skin_customize_flag_bgm: Optional[int]
|
||||
skin_customize_flag_lane: Optional[int]
|
||||
sp_rival_1_iidx_id: Optional[int]
|
||||
sp_rival_2_iidx_id: Optional[int]
|
||||
sp_rival_3_iidx_id: Optional[int]
|
||||
sp_rival_4_iidx_id: Optional[int]
|
||||
sp_rival_5_iidx_id: Optional[int]
|
||||
sp_rival_6_iidx_id: Optional[int]
|
||||
dp_rival_1_iidx_id: Optional[int]
|
||||
dp_rival_2_iidx_id: Optional[int]
|
||||
dp_rival_3_iidx_id: Optional[int]
|
||||
dp_rival_4_iidx_id: Optional[int]
|
||||
dp_rival_5_iidx_id: Optional[int]
|
||||
dp_rival_6_iidx_id: Optional[int]
|
||||
sp_rival_1_iidx_id: Optional[int] = 0
|
||||
sp_rival_2_iidx_id: Optional[int] = 0
|
||||
sp_rival_3_iidx_id: Optional[int] = 0
|
||||
sp_rival_4_iidx_id: Optional[int] = 0
|
||||
sp_rival_5_iidx_id: Optional[int] = 0
|
||||
sp_rival_6_iidx_id: Optional[int] = 0
|
||||
dp_rival_1_iidx_id: Optional[int] = 0
|
||||
dp_rival_2_iidx_id: Optional[int] = 0
|
||||
dp_rival_3_iidx_id: Optional[int] = 0
|
||||
dp_rival_4_iidx_id: Optional[int] = 0
|
||||
dp_rival_5_iidx_id: Optional[int] = 0
|
||||
dp_rival_6_iidx_id: Optional[int] = 0
|
||||
|
||||
|
||||
@router.get("/profiles")
|
||||
@ -269,7 +269,7 @@ async def iidx_receive_mdb(file: UploadFile = File(...)) -> bytes:
|
||||
return Response(status_code=422)
|
||||
else:
|
||||
# video_music_list.xml to fix broken characters in title/artist
|
||||
# (this should be a seperate route)
|
||||
# (this should be a separate route)
|
||||
try:
|
||||
with open(iidx_metadata, "r", encoding="utf-8") as f:
|
||||
music_data = json.load(f)
|
||||
|
@ -20,7 +20,7 @@ if exist .venv\Lib\site-packages\ujson*.pyd (
|
||||
|
||||
echo:
|
||||
echo Install python with "Add python.exe to PATH" checked
|
||||
echo https://www.python.org/ftp/python/3.11.2/python-3.11.2-amd64.exe
|
||||
echo https://www.python.org/ftp/python/3.11.4/python-3.11.4-amd64.exe
|
||||
echo:
|
||||
|
||||
pause
|
||||
|
Loading…
x
Reference in New Issue
Block a user