swingmusic/app/serializers/favorites_serializer.py
geoffrey45 51a5502efc add parsers to clean track titles .ie. remove remaster info
+ use getters to read flags
+ use the largest limit to get recent favorites
+ misc
2023-05-05 17:49:59 +03:00

40 lines
979 B
Python

from app.models import Track, Album, Artist
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,
"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,
}