1
0
mirror of synced 2025-02-15 18:02:39 +01:00

Merge pull request 'Fix mai2 photo merge problem and Add UserScoreRankingAPI handler' (#2) from mai2_tournament_support into develop

Reviewed-on: https://gitea.tendokyu.moe/SoulGateKey/artemis/pulls/2
This commit is contained in:
SoulGateKey 2024-11-12 05:42:20 +00:00
commit 7a307b4d69
2 changed files with 72 additions and 68 deletions

View File

@ -963,3 +963,6 @@ class Mai2Base:
userRecommendSelectionMusicIdList: list[int]
"""
return {"userId": data["userId"], "userRecommendSelectionMusicIdList": []}
async def handle_get_user_score_ranking_api_request(self, data: Dict) ->Dict:
return {"userId": data["userId"], "userScoreRanking": []}

View File

@ -383,14 +383,14 @@ class Mai2Frontend(FE_Base):
return Response(status_code=404)
if path.exists(f"{out_folder}"):
print("path exists")
self.logger.info(f"Photo Path Exist.")
max_idx = 0
p = ImageFile.Parser()
for _, _, files in walk("out_folder"):
for _, _, files in walk(f"{out_folder}"):
if not files:
break
matcher = re.match("^(\d+)_(\d+)$", files[0])
matcher = re.match(r"^(\d+)_(\d+)\.bin$", files[0])
if not matcher:
break
@ -405,11 +405,12 @@ class Mai2Frontend(FE_Base):
return Response(status_code=500)
for i in range(max_idx + 1):
with open(f"{out_folder}/{i}_{max_idx}", "rb") as f:
with open(f"{out_folder}/{i}_{max_idx}.bin", "rb") as f:
p.feed(f.read())
try:
im = p.close()
im.save(f"{out_folder}.jpeg")
self.logger.info(f"{out_folder}.jpeg generated.")
except Exception as e:
self.logger.error(f"{photo_id} failed PIL validation! - {e}")
@ -417,7 +418,7 @@ class Mai2Frontend(FE_Base):
shutil.rmtree(out_folder)
if path.exists(f"{out_folder}.jpeg"):
print(f"{out_folder}.jpeg exists")
self.logger.info(f"{out_folder}.jpeg exists")
return FileResponse(f"{out_folder}.jpeg")
return Response(status_code=404)