18 lines
532 B
Python
18 lines
532 B
Python
import json
|
|
from pathlib import Path
|
|
|
|
CACHE_FILE = Path(__file__).resolve().parent / "cache.json"
|
|
|
|
def load_cache():
|
|
try:
|
|
if not CACHE_FILE.exists():
|
|
with open(CACHE_FILE, "w") as f:
|
|
json.dump({"added_artists": [], "similar_cache": {}}, f)
|
|
with open(CACHE_FILE, "r") as f:
|
|
return json.load(f)
|
|
except Exception:
|
|
return {"added_artists": [], "similar_cache": {}}
|
|
|
|
def save_cache(cache):
|
|
with open(CACHE_FILE, "w") as f:
|
|
json.dump(cache, f, indent=2)
|