mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-06 19:25:34 +00:00
41 lines
1.0 KiB
Python
41 lines
1.0 KiB
Python
from app.models import Album, Artist, Track
|
|
|
|
|
|
def recent_fav_track_serializer(track: Track) -> dict:
|
|
"""
|
|
Simplifies a track object into a dictionary to remove unused
|
|
properties on the client.
|
|
"""
|
|
return {
|
|
"image": track.image,
|
|
"title": track.title,
|
|
"trackhash": track.trackhash,
|
|
"filepath": track.filepath,
|
|
}
|
|
|
|
|
|
def recent_fav_album_serializer(album: Album) -> dict:
|
|
"""
|
|
Simplifies an album object into a dictionary to remove unused
|
|
properties on the client.
|
|
"""
|
|
return {
|
|
"image": album.image,
|
|
"title": album.og_title,
|
|
"albumhash": album.albumhash,
|
|
"artist": album.albumartists[0].name,
|
|
"colors": album.colors,
|
|
}
|
|
|
|
|
|
def recent_fav_artist_serializer(artist: Artist) -> dict:
|
|
"""
|
|
Simplifies an artist object into a dictionary to remove unused
|
|
properties on the client.
|
|
"""
|
|
return {
|
|
"image": artist.image,
|
|
"name": artist.name,
|
|
"artisthash": artist.artisthash,
|
|
}
|