mirror of
https://github.com/qwerfd2/Groove_Coaster_2_Server.git
synced 2025-12-21 19:20:11 +00:00
fixes
This commit is contained in:
@@ -19,29 +19,27 @@ async def batch_handler(request: Request):
|
|||||||
if platform not in ["Android", "iOS"]:
|
if platform not in ["Android", "iOS"]:
|
||||||
return HTMLResponse(content="Invalid platform", status_code=400)
|
return HTMLResponse(content="Invalid platform", status_code=400)
|
||||||
|
|
||||||
query = batch_tokens.select().where(batch_tokens.c.token == token)
|
query = batch_tokens.select().where(batch_tokens.c.batch_token == token)
|
||||||
result = await player_database.fetch_one(query)
|
result = await player_database.fetch_one(query)
|
||||||
|
|
||||||
if not result:
|
if not result:
|
||||||
return HTMLResponse(content="Invalid token", status_code=400)
|
return HTMLResponse(content="Invalid token", status_code=400)
|
||||||
|
|
||||||
if result['expire_at'] < int(time.time()):
|
if result['expire_at'] < datetime.utcnow():
|
||||||
return HTMLResponse(content="Token expired", status_code=400)
|
return HTMLResponse(content="Token expired", status_code=400)
|
||||||
|
|
||||||
uses_left = result['uses_left']
|
uses_left = result['uses_left']
|
||||||
if uses_left > 0:
|
if uses_left > 0:
|
||||||
uses_left -= 1
|
uses_left -= 1
|
||||||
|
update_query = batch_tokens.update().where(batch_tokens.c.batch_token == token).values(
|
||||||
|
uses_left=uses_left,
|
||||||
|
updated_at=datetime.utcnow()
|
||||||
|
)
|
||||||
|
await player_database.execute(update_query)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
uses_left = -1
|
|
||||||
return HTMLResponse(content="No uses left", status_code=400)
|
return HTMLResponse(content="No uses left", status_code=400)
|
||||||
|
|
||||||
update_query = batch_tokens.update().where(batch_tokens.c.token == token).values(
|
|
||||||
uses_left=uses_left,
|
|
||||||
updated_at=datetime.utcnow()
|
|
||||||
)
|
|
||||||
await player_database.execute(update_query)
|
|
||||||
|
|
||||||
with open(os.path.join('api/config/', 'download_manifest.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join('api/config/', 'download_manifest.json'), 'r', encoding='utf-8') as f:
|
||||||
stage_manifest = json.load(f)
|
stage_manifest = json.load(f)
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ async def serve_file(request: Request):
|
|||||||
|
|
||||||
if os.path.isfile(file_path):
|
if os.path.isfile(file_path):
|
||||||
# get size of file
|
# get size of file
|
||||||
if AUTHORIZATION_MODE != 0:
|
if AUTHORIZATION_MODE != 0 and not batch_result:
|
||||||
file_size = os.path.getsize(file_path)
|
file_size = os.path.getsize(file_path)
|
||||||
await log_download(bind_result['user_id'], filename, file_size)
|
await log_download(bind_result['user_id'], filename, file_size)
|
||||||
return FileResponse(file_path)
|
return FileResponse(file_path)
|
||||||
|
|||||||
@@ -14,13 +14,15 @@ To use it, you need to
|
|||||||
|
|
||||||
4) Generate a `batch_token` in the database through some means (database edit, discord bot, etc.). The schema of the table is as follows:
|
4) Generate a `batch_token` in the database through some means (database edit, discord bot, etc.). The schema of the table is as follows:
|
||||||
|
|
||||||
- id: auto generated primary key, ignore
|
- `id`: auto generated primary key, simply ignore
|
||||||
|
|
||||||
- token: The key string itself. Required field
|
- `batch_token`: The key string itself. Required field, String value
|
||||||
|
|
||||||
- expire_at: Unix timestamp integer of the expiration time. Required field.
|
- `expire_at`: Datetime string of when the token expires. Required field, String value (e.g. 2026-11-27 06:37:48.170791)
|
||||||
|
|
||||||
- sid, verification_name, verification_id: Not required in the public version. Fields for bots to link with 3rd party accounts.
|
- `uses_left`: Amount of uses the token can accrude before it stops working. Each time it queries the `/batch` api, this count will decrease by 1. Required field, Integer value.
|
||||||
|
|
||||||
|
- `auth_id`, `created_at`, `updated_at`: Simply left blank for local uses.
|
||||||
|
|
||||||
5) Open the app and enter the server base URL and token, click download and wait!
|
5) Open the app and enter the server base URL and token, click download and wait!
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -1,3 +1,23 @@
|
|||||||
This is a base64 string for the server to deliver the save data to the client (user table, data field)
|
This is a base64 string for the server to deliver the save data to the client.
|
||||||
|
|
||||||
|
It unlocks all the songs and difficulties. Avatars and items are not unlocked.
|
||||||
|
|
||||||
|
For 7002 and prior:
|
||||||
|
|
||||||
|
Paste the B64 string into `player.db`'s `user` table.
|
||||||
|
|
||||||
|
Find the row of your user and paste the content into the `data` field.
|
||||||
|
|
||||||
|
Save the database.
|
||||||
|
|
||||||
|
|
||||||
|
For 7003:
|
||||||
|
|
||||||
|
Open `player.db` and go to `accounts` table. Find the `id` of your account.
|
||||||
|
|
||||||
|
Create a `save` folder at the server root directory if it is not already there.
|
||||||
|
|
||||||
|
Create a new text file called `{YOUR_ACCOUNT_ID}.dat`, for example, `1.dat`.
|
||||||
|
|
||||||
|
Open that file and paste the B64 string in, and save.
|
||||||
|
|
||||||
It unlocks all the songs and difficulties.
|
|
||||||
Reference in New Issue
Block a user