mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-06 03:05:35 +00:00
rewrite calculating album date in api/artist.py
+ add images and track count to created playlist object
This commit is contained in:
parent
f2addf4d0f
commit
a629f12e39
@ -91,6 +91,8 @@ def get_artist_albums(artisthash: str):
|
||||
limit = int(limit)
|
||||
|
||||
all_albums = AlbumStore.get_albums_by_artisthash(artisthash)
|
||||
|
||||
# start: check for missing albums. ie. compilations and features
|
||||
all_tracks = TrackStore.get_tracks_by_artisthash(artisthash)
|
||||
|
||||
track_albums = set(t.albumhash for t in all_tracks)
|
||||
@ -100,8 +102,15 @@ def get_artist_albums(artisthash: str):
|
||||
missing_albums = AlbumStore.get_albums_by_hashes(list(missing_album_hashes))
|
||||
all_albums.extend(missing_albums)
|
||||
|
||||
# end check
|
||||
|
||||
def get_album_tracks(albumhash: str):
|
||||
return [t for t in all_tracks if t.albumhash == albumhash]
|
||||
tracks = [t for t in all_tracks if t.albumhash == albumhash]
|
||||
|
||||
if len(tracks) > 0:
|
||||
return tracks
|
||||
|
||||
return TrackStore.get_tracks_by_albumhash(albumhash)
|
||||
|
||||
for a in all_albums:
|
||||
a.check_type()
|
||||
|
@ -416,7 +416,9 @@ def save_item_as_playlist():
|
||||
if len(trackhashes) == 0:
|
||||
return {"error": "No tracks founds"}, 404
|
||||
|
||||
image = itemhash + ".webp" if itemtype != "folder" and itemtype != "tracks" else None
|
||||
image = (
|
||||
itemhash + ".webp" if itemtype != "folder" and itemtype != "tracks" else None
|
||||
)
|
||||
|
||||
playlist = insert_playlist(playlist_name, image)
|
||||
|
||||
@ -441,5 +443,9 @@ def save_item_as_playlist():
|
||||
)
|
||||
|
||||
PL.add_tracks_to_playlist(playlist.id, trackhashes)
|
||||
playlist.set_count(len(trackhashes))
|
||||
|
||||
images = get_first_4_images(trackhashes=trackhashes)
|
||||
playlist.images = [img["image"] for img in images]
|
||||
|
||||
return {"playlist": playlist}, 201
|
||||
|
Loading…
x
Reference in New Issue
Block a user