mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-06 19:25:34 +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)
|
limit = int(limit)
|
||||||
|
|
||||||
all_albums = AlbumStore.get_albums_by_artisthash(artisthash)
|
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)
|
all_tracks = TrackStore.get_tracks_by_artisthash(artisthash)
|
||||||
|
|
||||||
track_albums = set(t.albumhash for t in all_tracks)
|
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))
|
missing_albums = AlbumStore.get_albums_by_hashes(list(missing_album_hashes))
|
||||||
all_albums.extend(missing_albums)
|
all_albums.extend(missing_albums)
|
||||||
|
|
||||||
|
# end check
|
||||||
|
|
||||||
def get_album_tracks(albumhash: str):
|
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:
|
for a in all_albums:
|
||||||
a.check_type()
|
a.check_type()
|
||||||
|
@ -416,7 +416,9 @@ def save_item_as_playlist():
|
|||||||
if len(trackhashes) == 0:
|
if len(trackhashes) == 0:
|
||||||
return {"error": "No tracks founds"}, 404
|
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)
|
playlist = insert_playlist(playlist_name, image)
|
||||||
|
|
||||||
@ -441,5 +443,9 @@ def save_item_as_playlist():
|
|||||||
)
|
)
|
||||||
|
|
||||||
PL.add_tracks_to_playlist(playlist.id, trackhashes)
|
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
|
return {"playlist": playlist}, 201
|
||||||
|
Loading…
x
Reference in New Issue
Block a user