blob: f11e9306b38f7a335cca3f5daed087894e77ba79 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
from dataclasses import dataclass, asdict, field
import json
@dataclass
class AlbumList:
name: str
album_keys: list[str]
@dataclass
class Config:
# Immich server
immich_url: str = ""
immich_api_key: str = ""
# Display
image_duration: float = 10.0
transition_duration: float = 0.5
max_framerate: float = 30.0
auto_transition: bool = True
display_size: str = "preview" # 'fullsize', 'preview', 'thumbnail'
# Cache
max_cache_assets: int = 100
# Albums data
album_lists: list[AlbumList] = field(default_factory=list)
album_list_selected: int = None
def __post_init__(self):
self.album_lists = [ AlbumList(*a) for a in self.album_lists ]
def __dict__(self):
return asdict(self)
@classmethod
def load(cls, filepath):
with open(filepath, "r") as fp:
return cls(**json.load(fp))
def save(self, filepath):
with open(filepath, "w") as fp:
json.dump(asdict(self), fp, indent=2)
|