Snapshot of the existing codebase before working through the TASKS.md backlog. Real library data (data/) and the iTunes import fixture (itunes-test-library/) are gitignored. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
27 lines
650 B
Python
27 lines
650 B
Python
import json
|
|
import os
|
|
from pathlib import Path
|
|
|
|
|
|
def config_path() -> Path:
|
|
base = os.environ.get("XDG_CONFIG_HOME", str(Path.home() / ".config"))
|
|
return Path(base) / "lintunes" / "config.json"
|
|
|
|
|
|
def load_config() -> dict:
|
|
path = config_path()
|
|
if path.exists():
|
|
try:
|
|
with open(path, "r", encoding="utf-8") as f:
|
|
return json.load(f)
|
|
except (ValueError, OSError):
|
|
pass
|
|
return {}
|
|
|
|
|
|
def save_config(config: dict):
|
|
path = config_path()
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
with open(path, "w", encoding="utf-8") as f:
|
|
json.dump(config, f, indent=2)
|