Files
SDGB-API/MusicDB.py
2025-10-13 18:15:05 +08:00

20 lines
518 B
Python

import rapidjson as json
from Config import *
from typing import Dict, Union
MusicDBType = Dict[int, Dict[str, Union[int, str]]]
__all__ = ['musicDB']
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 文件不存在!")
musicDB: MusicDBType = {int(k): v for k, v in data.items()}