mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
fix: get all favorite tracks endpoint
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
- Auth
|
- Auth
|
||||||
- New artists/albums Sort by: last played, no. of streams, total stream duration
|
- New artists/albums Sort by: last played, no. of streams, total stream duration
|
||||||
- Option to show now playing track info on tab title. Go to Settings > Appearance to enable
|
- Option to show now playing track info on tab title. Go to Settings > Appearance to enable
|
||||||
|
- You can select which disc to play in an album
|
||||||
|
- Internal Backup and restore
|
||||||
|
|
||||||
## Improvements
|
## Improvements
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
- Create 2 way relationships, such that if an artist A is similar to another B with a certain weight,
|
- Create 2 way relationships, such that if an artist A is similar to another B with a certain weight,
|
||||||
then artist B is similar to A with the same weight, unless overwritten.
|
then artist B is similar to A with the same weight, unless overwritten.
|
||||||
- Clean up tempfiles after transcoding
|
- Clean up tempfiles after transcoding
|
||||||
|
- Double sort artist tracks for consistency (alphabetically then by other field. eg. playcount)
|
||||||
|
|
||||||
# Bug fixes
|
# Bug fixes
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -2,7 +2,6 @@
|
|||||||
Contains all the artist(s) routes.
|
Contains all the artist(s) routes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from dataclasses import asdict
|
|
||||||
import math
|
import math
|
||||||
import random
|
import random
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@@ -48,6 +47,9 @@ def get_artist(path: ArtistHashSchema, query: TrackLimitSchema):
|
|||||||
return {"error": "Artist not found"}, 404
|
return {"error": "Artist not found"}, 404
|
||||||
|
|
||||||
tracks = TrackStore.get_tracks_by_trackhashes(entry.trackhashes)
|
tracks = TrackStore.get_tracks_by_trackhashes(entry.trackhashes)
|
||||||
|
tracks = sorted(tracks, key=lambda t: t.title)
|
||||||
|
tracks = sorted(tracks, key= lambda t: t.playcount, reverse=True)
|
||||||
|
print([{t.title, t.playcount, t.trackhash} for t in tracks])
|
||||||
tcount = len(tracks)
|
tcount = len(tracks)
|
||||||
|
|
||||||
artist = entry.artist
|
artist = entry.artist
|
||||||
@@ -162,6 +164,8 @@ def get_all_artist_tracks(path: ArtistHashSchema):
|
|||||||
Returns all artists by a given artist.
|
Returns all artists by a given artist.
|
||||||
"""
|
"""
|
||||||
tracks = ArtistStore.get_artist_tracks(path.artisthash)
|
tracks = ArtistStore.get_artist_tracks(path.artisthash)
|
||||||
|
tracks = sorted(tracks, key=lambda t: t.title)
|
||||||
|
tracks = sorted(tracks, key= lambda t: t.playcount, reverse=True)
|
||||||
return serialize_tracks(tracks)
|
return serialize_tracks(tracks)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -131,9 +131,8 @@ def get_favorite_tracks(query: GetAllOfTypeQuery):
|
|||||||
Get favorite tracks
|
Get favorite tracks
|
||||||
"""
|
"""
|
||||||
tracks, total = FavoritesTable.get_fav_tracks(query.start, query.limit)
|
tracks, total = FavoritesTable.get_fav_tracks(query.start, query.limit)
|
||||||
|
|
||||||
tracks.reverse()
|
tracks.reverse()
|
||||||
tracks = TrackTable.get_tracks_by_trackhashes([t.hash for t in tracks])
|
tracks = TrackStore.get_tracks_by_trackhashes([t.hash for t in tracks])
|
||||||
|
|
||||||
return {"tracks": serialize_tracks(tracks), "total": total}
|
return {"tracks": serialize_tracks(tracks), "total": total}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -13,7 +13,6 @@ from flask_openapi3 import APIBlueprint, FileStorage
|
|||||||
|
|
||||||
from app import models
|
from app import models
|
||||||
from app.api.apischemas import GenericLimitSchema
|
from app.api.apischemas import GenericLimitSchema
|
||||||
from app.db.libdata import TrackTable
|
|
||||||
from app.db.userdata import PlaylistTable
|
from app.db.userdata import PlaylistTable
|
||||||
from app.lib import playlistlib
|
from app.lib import playlistlib
|
||||||
from app.lib.albumslib import sort_by_track_no
|
from app.lib.albumslib import sort_by_track_no
|
||||||
@@ -57,7 +56,7 @@ def get_path_trackhashes(path: str):
|
|||||||
"""
|
"""
|
||||||
Returns a list of trackhashes in a folder.
|
Returns a list of trackhashes in a folder.
|
||||||
"""
|
"""
|
||||||
tracks = TrackTable.get_tracks_in_path(path)
|
tracks = TrackStore.get_tracks_in_path(path)
|
||||||
return [t.trackhash for t in tracks]
|
return [t.trackhash for t in tracks]
|
||||||
|
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ def get_album_trackhashes(albumhash: str):
|
|||||||
"""
|
"""
|
||||||
Returns a list of trackhashes in an album.
|
Returns a list of trackhashes in an album.
|
||||||
"""
|
"""
|
||||||
tracks = TrackTable.get_tracks_by_albumhash(albumhash)
|
tracks = TrackStore.get_tracks_by_albumhash(albumhash)
|
||||||
tracks = sort_by_track_no(tracks)
|
tracks = sort_by_track_no(tracks)
|
||||||
|
|
||||||
return [t.trackhash for t in tracks]
|
return [t.trackhash for t in tracks]
|
||||||
@@ -75,7 +74,8 @@ def get_artist_trackhashes(artisthash: str):
|
|||||||
"""
|
"""
|
||||||
Returns a list of trackhashes for an artist.
|
Returns a list of trackhashes for an artist.
|
||||||
"""
|
"""
|
||||||
tracks = TrackTable.get_tracks_by_artisthash(artisthash)
|
tracks = TrackStore.get_tracks_by_artisthash(artisthash)
|
||||||
|
tracks = sorted(tracks, key= lambda t: t.playcount, reverse=True)
|
||||||
return [t.trackhash for t in tracks]
|
return [t.trackhash for t in tracks]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -225,6 +225,10 @@ class FavoritesTable(Base):
|
|||||||
res = result.fetchall()
|
res = result.fetchall()
|
||||||
|
|
||||||
if start == 0:
|
if start == 0:
|
||||||
|
# if limit == -1, return all
|
||||||
|
if limit == -1:
|
||||||
|
limit = len(res)
|
||||||
|
|
||||||
return res[:limit], len(res)
|
return res[:limit], len(res)
|
||||||
|
|
||||||
return res, -1
|
return res, -1
|
||||||
|
|||||||
Reference in New Issue
Block a user