配合模块进行的各种更改和 fix

This commit is contained in:
Your Name
2025-02-04 15:39:36 +08:00
parent 6daf529b2f
commit 0abc04b94a
8 changed files with 302 additions and 16 deletions

View File

@@ -1,4 +1,5 @@
import rapidjson as json
from Config import *
from typing import Dict, Union
# 定义音乐数据库的类型注解
@@ -8,9 +9,15 @@ MusicDBType = Dict[int, Dict[str, Union[int, str]]]
__all__ = ['musicDB']
# 读取并解析 JSON 文件
with open('./maimaiDX-Api/Data/musicDB.json', 'r', encoding='utf-8') as f:
# 使用 json.load 直接从文件对象读取 JSON 数据
data = json.load(f)
try:
with open(musicDBPath, 'r', encoding='utf-8') as f:
data = json.load(f)
except FileNotFoundError:
try:
with open(musicDBPathFallback, 'r', encoding='utf-8') as f:
data = json.load(f)
except:
raise FileNotFoundError("musicDB.json 文件不存在!")
# 将 JSON 数据转换为指定格式的字典
musicDB: MusicDBType = {int(k): v for k, v in data.items()}