diff --git a/supysonic/api/albums_songs.py b/supysonic/api/albums_songs.py index 6e72dbd..9544b3d 100644 --- a/supysonic/api/albums_songs.py +++ b/supysonic/api/albums_songs.py @@ -270,9 +270,11 @@ def get_starred(): return request.formatter( "starred", { - "artist": [sf.as_subsonic_artist(request.user) for sf in arq], - "album": [sf.as_subsonic_child(request.user) for sf in alq], - "song": [st.as_subsonic_child(request.user, request.client) for st in trq], + "artist": [sf.starred.as_subsonic_artist(request.user) for sf in arq], + "album": [sf.starred.as_subsonic_child(request.user) for sf in alq], + "song": [ + st.starred.as_subsonic_child(request.user, request.client) for st in trq + ], }, ) @@ -306,8 +308,10 @@ def get_starred_id3(): return request.formatter( "starred2", { - "artist": [sa.as_subsonic_artist(request.user) for sa in arq], - "album": [sa.as_subsonic_album(request.user) for sa in alq], - "song": [st.as_subsonic_child(request.user, request.client) for st in trq], + "artist": [sa.starred.as_subsonic_artist(request.user) for sa in arq], + "album": [sa.starred.as_subsonic_album(request.user) for sa in alq], + "song": [ + st.starred.as_subsonic_child(request.user, request.client) for st in trq + ], }, ) diff --git a/tests/api/test_album_songs.py b/tests/api/test_album_songs.py index 17578f8..833aa39 100644 --- a/tests/api/test_album_songs.py +++ b/tests/api/test_album_songs.py @@ -7,7 +7,17 @@ import unittest -from supysonic.db import Folder, Artist, Album, Track +from supysonic.db import ( + Folder, + Artist, + Album, + Track, + StarredArtist, + StarredAlbum, + StarredFolder, + StarredTrack, + User, +) from .apitestbase import ApiTestBase @@ -260,11 +270,22 @@ class AlbumSongsTestCase(ApiTestBase): def test_now_playing(self): self._make_request("getNowPlaying", tag="nowPlaying") + def _create_starred_info(self): + user = User.select().first() + StarredArtist.create(user=user, starred=Artist.select().first()) + StarredAlbum.create(user=user, starred=Album.select().first()) + StarredTrack.create(user=user, starred=Track.select().first()) + StarredFolder.create(user=user, starred=Folder.select().first()) + def test_get_starred(self): + self._create_starred_info() + self._make_request("getStarred", tag="starred") self._make_request("getStarred", {"musicFolderId": 1}, tag="starred") def test_get_starred2(self): + self._create_starred_info() + self._make_request("getStarred2", tag="starred2") self._make_request("getStarred2", {"musicFolderId": 1}, tag="starred2")