mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
A LOTTTT ...
+ fix help text + run populate once when -nps flag is used + update app version + sort tracks by track and disc no. when saving to playlist + serialize search results + update tags.artist -> tags.artists + update tags.albumartist -> tags.albumartists + remove artist images from serialized albums + add function to serialize artists for cards + misc
This commit is contained in:
@@ -9,6 +9,10 @@ def album_serializer(album: Album, to_remove: set[str]) -> dict:
|
||||
for key in to_remove:
|
||||
album_dict.pop(key, None)
|
||||
|
||||
# remove artist images
|
||||
for artist in album_dict["albumartists"]:
|
||||
artist.pop("image", None)
|
||||
|
||||
return album_dict
|
||||
|
||||
|
||||
@@ -16,7 +20,7 @@ def serialize_for_card(album: Album):
|
||||
props_to_remove = {
|
||||
"duration",
|
||||
"count",
|
||||
"albumartist_hashes",
|
||||
"albumartists_hashes",
|
||||
"og_title",
|
||||
"base_title",
|
||||
"genres",
|
||||
|
||||
+17
-19
@@ -1,25 +1,23 @@
|
||||
# from dataclasses import asdict
|
||||
from dataclasses import asdict
|
||||
|
||||
from app.models.artist import Artist
|
||||
|
||||
|
||||
# def album_serializer(album: Artist, to_remove: set[str]) -> ArtistMinimal:
|
||||
# album_dict = asdict(album)
|
||||
def serialize_for_card(artist: Artist):
|
||||
artist_dict = asdict(artist)
|
||||
|
||||
# to_remove.update(key for key in album_dict.keys() if key.startswith("is_"))
|
||||
# for key in to_remove:
|
||||
# album_dict.pop(key, None)
|
||||
props_to_remove = {
|
||||
"is_favorite",
|
||||
"trackcount",
|
||||
"duration",
|
||||
"albumcount",
|
||||
}
|
||||
|
||||
# return album_dict
|
||||
for key in props_to_remove:
|
||||
artist_dict.pop(key, None)
|
||||
|
||||
return artist_dict
|
||||
|
||||
|
||||
# Traceback (most recent call last):
|
||||
# File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
|
||||
# self.run()
|
||||
# File "/usr/lib/python3.10/threading.py", line 953, in run
|
||||
# self._target(*self._args, **self._kwargs)
|
||||
# File "/usr/lib/python3.10/multiprocessing/pool.py", line 579, in _handle_results
|
||||
# task = get()
|
||||
# File "/usr/lib/python3.10/multiprocessing/connection.py", line 251, in recv
|
||||
# return _ForkingPickler.loads(buf.getbuffer())
|
||||
# File "/home/cwilvx/.cache/pypoetry/virtualenvs/swing_music_player-xIXBgWdk-py3.10/lib/python3.10/site-packages/requests/exceptions.py", line 41, in __init__
|
||||
# CompatJSONDecodeError.__init__(self, *args)
|
||||
# TypeError: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'
|
||||
def serialize_for_cards(artists: list[Artist]):
|
||||
return [serialize_for_card(a) for a in artists]
|
||||
|
||||
@@ -3,7 +3,7 @@ from dataclasses import asdict
|
||||
from app.models.track import Track
|
||||
|
||||
|
||||
def track_serializer(track: Track, to_remove: set = {}, remove_disc=True) -> dict:
|
||||
def serialize_track(track: Track, to_remove: set = {}, remove_disc=True) -> dict:
|
||||
album_dict = asdict(track)
|
||||
props = {
|
||||
"date",
|
||||
@@ -14,6 +14,7 @@ def track_serializer(track: Track, to_remove: set = {}, remove_disc=True) -> dic
|
||||
"copyright",
|
||||
"disc",
|
||||
"track",
|
||||
"artist_hashes",
|
||||
}.union(to_remove)
|
||||
|
||||
if not remove_disc:
|
||||
@@ -26,10 +27,15 @@ def track_serializer(track: Track, to_remove: set = {}, remove_disc=True) -> dic
|
||||
for key in props:
|
||||
album_dict.pop(key, None)
|
||||
|
||||
to_remove_images = ["artists", "albumartists"]
|
||||
for key in to_remove_images:
|
||||
for artist in album_dict[key]:
|
||||
artist.pop("image", None)
|
||||
|
||||
return album_dict
|
||||
|
||||
|
||||
def serialize_tracks(
|
||||
tracks: list[Track], _remove: set = {}, remove_disc=True
|
||||
) -> list[dict]:
|
||||
return [track_serializer(t, _remove, remove_disc) for t in tracks]
|
||||
return [serialize_track(t, _remove, remove_disc) for t in tracks]
|
||||
|
||||
Reference in New Issue
Block a user