mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
🔶 add update_playlist route
This commit is contained in:
+17
-3
@@ -100,10 +100,10 @@ class Playlist:
|
||||
|
||||
playlistid: str
|
||||
name: str
|
||||
image: str
|
||||
tracks: List[Track]
|
||||
_pre_tracks: list = field(init=False, repr=False)
|
||||
lastUpdated: int
|
||||
image: str
|
||||
description: str = ""
|
||||
count: int = 0
|
||||
"""A list of track objects in the playlist"""
|
||||
@@ -112,7 +112,7 @@ class Playlist:
|
||||
self.playlistid = data["_id"]["$oid"]
|
||||
self.name = data["name"]
|
||||
self.description = data["description"]
|
||||
self.image = ""
|
||||
self.image = self.create_img_link(data["image"])
|
||||
self._pre_tracks = data["pre_tracks"]
|
||||
self.tracks = []
|
||||
self.lastUpdated = data["lastUpdated"]
|
||||
@@ -124,8 +124,14 @@ class Playlist:
|
||||
"""
|
||||
return create_playlist_tracks(self._pre_tracks)
|
||||
|
||||
def create_img_link(self, image: str):
|
||||
if image:
|
||||
return settings.IMG_PLAYLIST_URI + image
|
||||
|
||||
return settings.IMG_PLAYLIST_URI + ""
|
||||
|
||||
def update_count(self):
|
||||
self.count = len(self.tracks)
|
||||
self.count = len(self._pre_tracks)
|
||||
|
||||
def add_track(self, track):
|
||||
if track not in self._pre_tracks:
|
||||
@@ -137,6 +143,14 @@ class Playlist:
|
||||
def update_desc(self, desc):
|
||||
self.description = desc
|
||||
|
||||
def update_playlist(self, data: dict):
|
||||
self.name = data["name"]
|
||||
self.description = data["description"]
|
||||
self.lastUpdated = data["lastUpdated"]
|
||||
|
||||
if data["image"]:
|
||||
self.image = self.create_img_link(data["image"])
|
||||
|
||||
|
||||
@dataclass
|
||||
class Folder:
|
||||
|
||||
Reference in New Issue
Block a user