modularize src

+ merge main.py and manage.py
+ move start logic to swingmusic/__main__.py
+ add a run.py on the project root
This commit is contained in:
cwilvx
2025-05-25 20:35:54 +03:00
parent 76fc97e088
commit 86fabcd5e3
171 changed files with 658 additions and 627 deletions
+42
View File
@@ -0,0 +1,42 @@
from dataclasses import asdict
from swingmusic.models.artist import Artist
def serialize_for_card(artist: Artist, include: set[str] = set()):
try:
artist_dict = asdict(artist)
except TypeError:
return {}
props_to_remove = {
"is_favorite",
"trackcount",
"duration",
"albumcount",
"playcount",
"playduration",
"playcount",
"lastplayed",
"id",
"genres",
"genrehashes",
"extra",
"created_date",
"date",
"fav_userids",
"_score",
}
if include:
props_to_remove = props_to_remove - include
for key in props_to_remove:
artist_dict.pop(key, None)
artist_dict["type"] = "artist"
return artist_dict
def serialize_for_cards(artists: list[Artist]):
return [serialize_for_card(a) for a in artists]