mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 04:23:01 +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:
+5
-11
@@ -4,15 +4,17 @@ Contains all the album routes.
|
||||
|
||||
import random
|
||||
from dataclasses import asdict
|
||||
from typing import Any
|
||||
|
||||
from flask import Blueprint, request
|
||||
|
||||
from app.db.sqlite.albumcolors import SQLiteAlbumMethods as adb
|
||||
from app.db.sqlite.favorite import SQLiteFavoriteMethods as favdb
|
||||
from app.db.sqlite.lastfm.similar_artists import SQLiteLastFMSimilarArtists as lastfmdb
|
||||
from app.lib.albumslib import sort_by_track_no
|
||||
from app.models import FavType, Track
|
||||
from app.serializers.album import serialize_for_card
|
||||
from app.serializers.track import track_serializer
|
||||
from app.serializers.track import serialize_track
|
||||
from app.store.albums import AlbumStore
|
||||
from app.store.tracks import TrackStore
|
||||
from app.utils.hashing import create_hash
|
||||
@@ -83,7 +85,7 @@ def get_album_tracks_and_info():
|
||||
album.is_favorite = check_is_fav(albumhash, FavType.album)
|
||||
|
||||
return {
|
||||
"tracks": [track_serializer(t, remove_disc=False) for t in tracks],
|
||||
"tracks": [serialize_track(t, remove_disc=False) for t in tracks],
|
||||
"info": album,
|
||||
}
|
||||
|
||||
@@ -94,13 +96,7 @@ def get_album_tracks(albumhash: str):
|
||||
Returns all the tracks in the given album, sorted by disc and track number.
|
||||
"""
|
||||
tracks = TrackStore.get_tracks_by_albumhash(albumhash)
|
||||
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"])
|
||||
sort_by_track_no(tracks)
|
||||
|
||||
return {"tracks": tracks}
|
||||
|
||||
@@ -210,5 +206,3 @@ def get_similar_albums():
|
||||
pass
|
||||
|
||||
return {"albums": [serialize_for_card(a) for a in albums[:limit]]}
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ from showinfm import show_in_file_manager
|
||||
from app import settings
|
||||
from app.db.sqlite.settings import SettingsSQLMethods as db
|
||||
from app.lib.folderslib import GetFilesAndDirs, get_folders
|
||||
from app.serializers.track import track_serializer
|
||||
from app.serializers.track import serialize_track
|
||||
from app.store.tracks import TrackStore as store
|
||||
from app.utils.wintools import is_windows, win_replace_slash
|
||||
|
||||
@@ -142,7 +142,7 @@ def get_tracks_in_path():
|
||||
|
||||
tracks = store.get_tracks_in_path(path)
|
||||
tracks = sorted(tracks, key=lambda i: i.last_mod)
|
||||
tracks = (track_serializer(t) for t in tracks if Path(t.filepath).exists())
|
||||
tracks = (serialize_track(t) for t in tracks if Path(t.filepath).exists())
|
||||
|
||||
return {
|
||||
"tracks": list(tracks)[:300],
|
||||
|
||||
+4
-3
@@ -11,6 +11,7 @@ from PIL import UnidentifiedImageError, Image
|
||||
from app import models
|
||||
from app.db.sqlite.playlists import SQLitePlaylistMethods
|
||||
from app.lib import playlistlib
|
||||
from app.lib.albumslib import sort_by_track_no
|
||||
from app.models.track import Track
|
||||
from app.store.albums import AlbumStore
|
||||
from app.store.tracks import TrackStore
|
||||
@@ -69,7 +70,6 @@ def send_all_playlists():
|
||||
"""
|
||||
Gets all the playlists.
|
||||
"""
|
||||
# get the no_images query param
|
||||
no_images = request.args.get("no_images", False)
|
||||
|
||||
playlists = PL.get_all_playlists()
|
||||
@@ -141,7 +141,9 @@ def get_album_trackhashes(albumhash: str):
|
||||
Returns a list of trackhashes in an album.
|
||||
"""
|
||||
tracks = TrackStore.get_tracks_by_albumhash(albumhash)
|
||||
return [t.trackhash for t in tracks]
|
||||
tracks = sort_by_track_no(tracks)
|
||||
|
||||
return [t["trackhash"] for t in tracks]
|
||||
|
||||
|
||||
def get_artist_trackhashes(artisthash: str):
|
||||
@@ -410,7 +412,6 @@ def save_item_as_playlist():
|
||||
trackhashes = get_album_trackhashes(itemhash)
|
||||
elif itemtype == "artist":
|
||||
trackhashes = get_artist_trackhashes(itemhash)
|
||||
|
||||
else:
|
||||
trackhashes = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user