mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-15 00:40:43 +08:00
- 新增媒体服务器优先级配置文件(_priority.json) - 调整模块加载顺序以支持优先级设置
This commit is contained in:
parent
1539b56717
commit
357c59eb55
7
media_servers/_priority.json
Normal file
7
media_servers/_priority.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[
|
||||||
|
"alist",
|
||||||
|
"alist_strm",
|
||||||
|
"alist_strm_gen",
|
||||||
|
"emby",
|
||||||
|
"plex"
|
||||||
|
]
|
||||||
@ -690,11 +690,22 @@ class Quark:
|
|||||||
|
|
||||||
def load_media_servers(media_servers_config, media_servers_dir="media_servers"):
|
def load_media_servers(media_servers_config, media_servers_dir="media_servers"):
|
||||||
media_servers = {}
|
media_servers = {}
|
||||||
available_modules = [
|
all_modules = [
|
||||||
f.replace(".py", "") for f in os.listdir(media_servers_dir) if f.endswith(".py")
|
f.replace(".py", "") for f in os.listdir(media_servers_dir) if f.endswith(".py")
|
||||||
]
|
]
|
||||||
|
# 调整模块优先级
|
||||||
|
priority_path = os.path.join(media_servers_dir, "_priority.json")
|
||||||
|
try:
|
||||||
|
with open(priority_path, encoding="utf-8") as f:
|
||||||
|
priority_modules = json.load(f)
|
||||||
|
if priority_modules:
|
||||||
|
all_modules = [
|
||||||
|
module for module in priority_modules if module in all_modules
|
||||||
|
] + [module for module in all_modules if module not in priority_modules]
|
||||||
|
except (FileNotFoundError, json.JSONDecodeError):
|
||||||
|
priority_modules = []
|
||||||
print(f"🧩 载入媒体库模块")
|
print(f"🧩 载入媒体库模块")
|
||||||
for module_name in available_modules:
|
for module_name in all_modules:
|
||||||
try:
|
try:
|
||||||
module = importlib.import_module(f"{media_servers_dir}.{module_name}")
|
module = importlib.import_module(f"{media_servers_dir}.{module_name}")
|
||||||
ServerClass = getattr(module, module_name.capitalize())
|
ServerClass = getattr(module, module_name.capitalize())
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user