use setters to manipulate artist and playlist objects

This commit is contained in:
geoffrey45
2023-03-26 18:57:25 +03:00
parent 5487dad27b
commit fe6c12d856
6 changed files with 33 additions and 23 deletions
+12 -5
View File
@@ -1,5 +1,5 @@
import dataclasses
import json
import dataclasses
from dataclasses import dataclass
from app.utils.hashing import create_hash
@@ -33,11 +33,18 @@ class Artist(ArtistMinimal):
colors: list[str] = dataclasses.field(default_factory=list)
is_favorite: bool = False
def __post_init__(self):
super(Artist, self).__init__(self.name)
def __init__(self, name: str):
super(Artist, self).__init__(name)
self.colors = json.loads(str(self.colors))
def set_trackcount(self, count: int):
self.trackcount = count
def set_albumcount(self, count: int):
self.albumcount = count
def set_duration(self, duration: int):
self.duration = duration
def set_colors(self, colors: list[str]):
self.colors = colors
# TODO: Use inheritance to create the classes in this file.
+11
View File
@@ -40,3 +40,14 @@ class Playlist:
else:
self.image = "None"
self.thumb = "None"
def set_duration(self, duration: int):
self.duration = duration
def clear_lists(self):
"""
Removes data from lists to make it lighter for sending
over the API.
"""
self.trackhashes = []
self.artisthashes = []