major server manager overhaul
This commit is contained in:
@@ -2,6 +2,8 @@ from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
import subprocess
|
||||
import logging
|
||||
import shutil
|
||||
import json
|
||||
import os
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -14,6 +16,8 @@ logging.basicConfig(
|
||||
]
|
||||
)
|
||||
|
||||
SETTINGS_FILE = "resources/config/app_settings.json"
|
||||
|
||||
def check_gpu_support():
|
||||
try:
|
||||
logger.debug("Checking ffmpeg for CUDA support...")
|
||||
@@ -29,12 +33,48 @@ def check_gpu_support():
|
||||
return False
|
||||
|
||||
class Settings(BaseSettings):
|
||||
samba_server_ip: str
|
||||
samba_username: str
|
||||
samba_password: str
|
||||
samba_server_ip: str = "127.0.0.1"
|
||||
samba_username: str = "guest"
|
||||
samba_password: str = ""
|
||||
comicvine_api_key: str | None = None
|
||||
qbittorrent_url: str | None = None
|
||||
qbittorrent_username: str | None = None
|
||||
qbittorrent_password: str | None = None
|
||||
gpu_enabled: bool = check_gpu_support()
|
||||
|
||||
# Defaults
|
||||
default_comics_path: str = "/comics/manga"
|
||||
default_videos_path: str = "/videos"
|
||||
|
||||
model_config = SettingsConfigDict(env_file=".env")
|
||||
# Stash Integration
|
||||
stash_enabled: bool = False
|
||||
stash_db_path: str = "stash.sqlite"
|
||||
stash_remote_db_path: str = "/appdata/stashapp/config/stash-go.sqlite"
|
||||
stash_generated_path: str = "/media/stashapp/generated"
|
||||
stash_remote_base: str = "/media/videos"
|
||||
stash_container_base: str = "/data"
|
||||
stash_share: str = "main"
|
||||
|
||||
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
|
||||
|
||||
def load_from_json(self):
|
||||
if os.path.exists(SETTINGS_FILE):
|
||||
try:
|
||||
with open(SETTINGS_FILE, 'r') as f:
|
||||
data = json.load(f)
|
||||
for key, value in data.items():
|
||||
if hasattr(self, key):
|
||||
setattr(self, key, value)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to load settings: {e}")
|
||||
|
||||
def save_to_json(self):
|
||||
try:
|
||||
os.makedirs(os.path.dirname(SETTINGS_FILE), exist_ok=True)
|
||||
with open(SETTINGS_FILE, 'w') as f:
|
||||
json.dump(self.model_dump(), f, indent=4)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to save settings: {e}")
|
||||
|
||||
settings = Settings()
|
||||
settings.load_from_json()
|
||||
|
||||
Reference in New Issue
Block a user