mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
b9ad07441a
+ allow sorting all items with those two + add methods to update scrobble info
28 lines
530 B
Python
28 lines
530 B
Python
from dataclasses import asdict
|
|
|
|
from app.models.artist import Artist
|
|
|
|
|
|
def serialize_for_card(artist: Artist):
|
|
try:
|
|
artist_dict = asdict(artist)
|
|
except TypeError:
|
|
return {}
|
|
|
|
props_to_remove = {
|
|
"is_favorite",
|
|
"trackcount",
|
|
"duration",
|
|
"albumcount",
|
|
"playcount",
|
|
}
|
|
|
|
for key in props_to_remove:
|
|
artist_dict.pop(key, None)
|
|
|
|
return artist_dict
|
|
|
|
|
|
def serialize_for_cards(artists: list[Artist]):
|
|
return [serialize_for_card(a) for a in artists]
|