mirror of
https://gitea.tendokyu.moe/Hay1tsme/artemis.git
synced 2026-02-13 19:27:27 +08:00
Merge branch 'develop' into diva_handler_classes
This commit is contained in:
@@ -2,7 +2,8 @@ from datetime import datetime
|
||||
from typing import Any, List, Dict
|
||||
import logging
|
||||
import json
|
||||
from urllib import parse
|
||||
import urllib
|
||||
from threading import Thread
|
||||
|
||||
from core.config import CoreConfig
|
||||
from titles.diva.config import DivaConfig
|
||||
@@ -661,50 +662,66 @@ class DivaBase:
|
||||
|
||||
return pv_result
|
||||
|
||||
def handle_get_pv_pd_request(self, data: bytes) -> str:
|
||||
song_id = data["pd_pv_id_lst"].split(",")
|
||||
pv = ""
|
||||
def task_generateScoreData(self, data: Dict, pd_by_pv_id, song):
|
||||
|
||||
if int(song) > 0:
|
||||
# the request do not send a edition so just perform a query best score and ranking for each edition.
|
||||
# 0=ORIGINAL, 1=EXTRA
|
||||
pd_db_song_0 = self.data.score.get_best_user_score(
|
||||
data["pd_id"], int(song), data["difficulty"], edition=0
|
||||
)
|
||||
pd_db_song_1 = self.data.score.get_best_user_score(
|
||||
data["pd_id"], int(song), data["difficulty"], edition=1
|
||||
)
|
||||
|
||||
for song in song_id:
|
||||
if int(song) > 0:
|
||||
# the request do not send a edition so just perform a query best score and ranking for each edition.
|
||||
# 0=ORIGINAL, 1=EXTRA
|
||||
pd_db_song_0 = self.data.score.get_best_user_score(
|
||||
pd_db_ranking_0, pd_db_ranking_1 = None, None
|
||||
if pd_db_song_0:
|
||||
pd_db_ranking_0 = self.data.score.get_global_ranking(
|
||||
data["pd_id"], int(song), data["difficulty"], edition=0
|
||||
)
|
||||
pd_db_song_1 = self.data.score.get_best_user_score(
|
||||
|
||||
if pd_db_song_1:
|
||||
pd_db_ranking_1 = self.data.score.get_global_ranking(
|
||||
data["pd_id"], int(song), data["difficulty"], edition=1
|
||||
)
|
||||
|
||||
pd_db_ranking_0, pd_db_ranking_1 = None, None
|
||||
if pd_db_song_0:
|
||||
pd_db_ranking_0 = self.data.score.get_global_ranking(
|
||||
data["pd_id"], int(song), data["difficulty"], edition=0
|
||||
)
|
||||
pd_db_customize = self.data.pv_customize.get_pv_customize(
|
||||
data["pd_id"], int(song)
|
||||
)
|
||||
|
||||
if pd_db_song_1:
|
||||
pd_db_ranking_1 = self.data.score.get_global_ranking(
|
||||
data["pd_id"], int(song), data["difficulty"], edition=1
|
||||
)
|
||||
# generate the pv_result string with the ORIGINAL edition and the EXTRA edition appended
|
||||
pv_result = self._get_pv_pd_result(
|
||||
int(song), pd_db_song_0, pd_db_ranking_0, pd_db_customize, edition=0
|
||||
)
|
||||
pv_result += "," + self._get_pv_pd_result(
|
||||
int(song), pd_db_song_1, pd_db_ranking_1, pd_db_customize, edition=1
|
||||
)
|
||||
|
||||
pd_db_customize = self.data.pv_customize.get_pv_customize(
|
||||
data["pd_id"], int(song)
|
||||
)
|
||||
self.logger.debug(f"pv_result = {pv_result}")
|
||||
pd_by_pv_id.append(urllib.parse.quote(pv_result))
|
||||
else:
|
||||
pd_by_pv_id.append(urllib.parse.quote(f"{song}***"))
|
||||
pd_by_pv_id.append(",")
|
||||
|
||||
# generate the pv_result string with the ORIGINAL edition and the EXTRA edition appended
|
||||
pv_result = self._get_pv_pd_result(
|
||||
int(song), pd_db_song_0, pd_db_ranking_0, pd_db_customize, edition=0
|
||||
)
|
||||
pv_result += "," + self._get_pv_pd_result(
|
||||
int(song), pd_db_song_1, pd_db_ranking_1, pd_db_customize, edition=1
|
||||
)
|
||||
def handle_get_pv_pd_request(self, data: Dict) -> Dict:
|
||||
song_id = data["pd_pv_id_lst"].split(",")
|
||||
pv = ""
|
||||
|
||||
self.logger.debug(f"pv_result = {pv_result}")
|
||||
threads = []
|
||||
pd_by_pv_id = []
|
||||
|
||||
pv += parse.quote(pv_result)
|
||||
else:
|
||||
pv += parse.quote(f"{song}***")
|
||||
pv += ","
|
||||
for song in song_id:
|
||||
thread_ScoreData = Thread(target=self.task_generateScoreData(data, pd_by_pv_id, song))
|
||||
threads.append(thread_ScoreData)
|
||||
|
||||
for x in threads:
|
||||
x.start()
|
||||
|
||||
for x in threads:
|
||||
x.join()
|
||||
|
||||
for x in pd_by_pv_id:
|
||||
pv += x
|
||||
|
||||
response = ""
|
||||
response += f"&pd_by_pv_id={pv[:-1]}"
|
||||
|
||||
@@ -34,18 +34,18 @@ class DivaReader(BaseReader):
|
||||
pull_opt_rom = True
|
||||
|
||||
if not path.exists(f"{self.bin_dir}/ram"):
|
||||
self.logger.warn(f"Couldn't find ram folder in {self.bin_dir}, skipping")
|
||||
self.logger.warning(f"Couldn't find ram folder in {self.bin_dir}, skipping")
|
||||
pull_bin_ram = False
|
||||
|
||||
if not path.exists(f"{self.bin_dir}/rom"):
|
||||
self.logger.warn(f"Couldn't find rom folder in {self.bin_dir}, skipping")
|
||||
self.logger.warning(f"Couldn't find rom folder in {self.bin_dir}, skipping")
|
||||
pull_bin_rom = False
|
||||
|
||||
if self.opt_dir is not None:
|
||||
opt_dirs = self.get_data_directories(self.opt_dir)
|
||||
else:
|
||||
pull_opt_rom = False
|
||||
self.logger.warn("No option directory specified, skipping")
|
||||
self.logger.warning("No option directory specified, skipping")
|
||||
|
||||
if pull_bin_ram:
|
||||
self.read_ram(f"{self.bin_dir}/ram")
|
||||
@@ -139,7 +139,7 @@ class DivaReader(BaseReader):
|
||||
else:
|
||||
continue
|
||||
else:
|
||||
self.logger.warn(f"Databank folder not found in {ram_root_dir}, skipping")
|
||||
self.logger.warning(f"Databank folder not found in {ram_root_dir}, skipping")
|
||||
|
||||
def read_rom(self, rom_root_dir: str) -> None:
|
||||
self.logger.info(f"Read ROM from {rom_root_dir}")
|
||||
@@ -150,7 +150,7 @@ class DivaReader(BaseReader):
|
||||
elif path.exists(f"{rom_root_dir}/pv_db.txt"):
|
||||
file_path = f"{rom_root_dir}/pv_db.txt"
|
||||
else:
|
||||
self.logger.warn(
|
||||
self.logger.warning(
|
||||
f"Cannot find pv_db.txt or mdata_pv_db.txt in {rom_root_dir}, skipping"
|
||||
)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user