add routes to get all albums and artists with sort

+ rewrite load all albums + artist logic with itertools.groupby
+ add a function to convert seconds to string
This commit is contained in:
mungai-njoroge
2023-12-08 09:20:51 +03:00
parent 7f87cde96c
commit 336360d509
12 changed files with 265 additions and 29 deletions
+11
View File
@@ -27,6 +27,7 @@ class Album:
colors: list[str] = dataclasses.field(default_factory=list)
date: str = ""
created_date: int = 0
og_title: str = ""
base_title: str = ""
is_soundtrack: bool = False
@@ -40,6 +41,7 @@ class Album:
versions: list[str] = dataclasses.field(default_factory=list)
def __post_init__(self):
self.title = self.title.strip()
self.og_title = self.title
self.image = self.albumhash + ".webp"
@@ -202,3 +204,12 @@ class Album:
dates = (int(t.date) for t in tracks if t.date)
self.date = datetime.datetime.fromtimestamp(min(dates)).year
def set_count(self, count: int):
self.count = count
def set_duration(self, duration: int):
self.duration = duration
def set_created_date(self, created_date: int):
self.created_date = created_date
+4
View File
@@ -36,6 +36,7 @@ class Artist(ArtistMinimal):
duration: int = 0
colors: list[str] = dataclasses.field(default_factory=list)
is_favorite: bool = False
created_date: float = 0.0
def __post_init__(self):
super(Artist, self).__init__(self.name)
@@ -51,3 +52,6 @@ class Artist(ArtistMinimal):
def set_colors(self, colors: list[str]):
self.colors = colors
def set_created_date(self, created_date: float):
self.created_date = created_date