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
+3 -4
View File
@@ -199,10 +199,9 @@ def get_artist(artisthash: str):
if acount == 0 and tcount < 10:
limit = tcount
artist.trackcount = tcount
artist.albumcount = acount
artist.duration = sum(t.duration for t in tracks)
artist.set_trackcount(tcount)
artist.set_albumcount(acount)
artist.set_duration(sum(t.duration for t in tracks))
artist.is_favorite = favdb.check_is_favorite(artisthash, FavType.artist)
+3 -5
View File
@@ -80,8 +80,7 @@ def send_all_playlists():
playlist.images = get_first_4_images(playlist.trackhashes)
playlist.images = [img['image'] for img in playlist.images]
playlist.trackhashes = []
playlist.artisthashes = []
playlist.clear_lists()
playlists.sort(
key=lambda p: datetime.strptime(p.last_updated, "%Y-%m-%d %H:%M:%S"),
@@ -163,7 +162,7 @@ def get_playlist(playlistid: str):
duration = sum(t.duration for t in tracks)
playlist.last_updated = date_string_to_time_passed(playlist.last_updated)
playlist.duration = duration
playlist.set_duration(duration)
if not playlist.has_image:
playlist.images = get_first_4_images(playlist.trackhashes)
@@ -172,8 +171,7 @@ def get_playlist(playlistid: str):
# swap 3rd image with first (3rd image is the visible image in UI)
playlist.images[2], playlist.images[0] = playlist.images[0], playlist.images[2]
playlist.trackhashes = []
playlist.artisthashes = []
playlist.clear_lists()
return {"info": playlist, "tracks": tracks}