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:
mungai-njoroge
2023-08-10 10:30:42 +03:00
parent 5cf188dd38
commit 0a703dcc0f
20 changed files with 149 additions and 103 deletions
+17 -1
View File
@@ -2,11 +2,15 @@
Contains methods relating to albums.
"""
from dataclasses import asdict
from typing import Any
from alive_progress import alive_bar
from app.logger import log
from app.models.track import Track
from app.store.albums import AlbumStore
from app.store.tracks import TrackStore
from app.logger import log
def validate_albums():
@@ -25,3 +29,15 @@ def validate_albums():
if album.albumhash not in album_hashes:
AlbumStore.remove_album(album)
bar()
def sort_by_track_no(tracks: list[Track]) -> list[dict[str, Any]]:
tracks = [asdict(t) for t in tracks]
for t in tracks:
track = str(t["track"]).zfill(3)
t["_pos"] = int(f"{t['disc']}{track}")
tracks = sorted(tracks, key=lambda t: t["_pos"])
return tracks