diff --git a/supysonic/api/albums_songs.py b/supysonic/api/albums_songs.py index 434b8d9..6e72dbd 100644 --- a/supysonic/api/albums_songs.py +++ b/supysonic/api/albums_songs.py @@ -1,7 +1,7 @@ # This file is part of Supysonic. # Supysonic is a Python implementation of the Subsonic server API. # -# Copyright (C) 2013-2022 Alban 'spl0k' Féron +# Copyright (C) 2013-2023 Alban 'spl0k' Féron # # Distributed under terms of the GNU AGPLv3 license. @@ -84,7 +84,7 @@ def album_list(): }, ) elif ltype == "newest": - query = query.order_by(Folder.created.desc()).distinct() + query = query.order_by(Folder.created.desc()) elif ltype == "highest": query = query.join(RatingFolder, JOIN.LEFT_OUTER).order_by( fn.avg(RatingFolder.rating).desc() @@ -98,7 +98,7 @@ def album_list(): elif ltype == "starred": query = query.join(StarredFolder).where(StarredFolder.user == request.user) elif ltype == "alphabeticalByName": - query = query.order_by(Folder.name).distinct() + query = query.order_by(Folder.name) elif ltype == "alphabeticalByArtist": parent = Folder.alias() query = query.join(parent).order_by(parent.name, Folder.name) @@ -212,7 +212,7 @@ def songs_by_genre(): { "song": [ t.as_subsonic_child(request.user, request.client) - for t in query.limit(count, offset) + for t in query.limit(count).offset(offset) ] }, ) diff --git a/tests/api/test_album_songs.py b/tests/api/test_album_songs.py index 848f8a5..055983c 100644 --- a/tests/api/test_album_songs.py +++ b/tests/api/test_album_songs.py @@ -1,7 +1,7 @@ # This file is part of Supysonic. # Supysonic is a Python implementation of the Subsonic server API. # -# Copyright (C) 2017-2022 Alban 'spl0k' Féron +# Copyright (C) 2017-2023 Alban 'spl0k' Féron # # Distributed under terms of the GNU AGPLv3 license. @@ -267,6 +267,26 @@ class AlbumSongsTestCase(ApiTestBase): self._make_request("getStarred2", tag="starred2") self._make_request("getStarred2", {"musicFolderId": 1}, tag="starred2") + def test_get_songs_by_genre(self): + self._make_request("getSongsByGenre", error=10) + self._make_request( + "getSongsByGenre", {"genre": "genre", "musicFolderId": "idid"}, error=0 + ) + self._make_request( + "getSongsByGenre", {"genre": "genre", "musicFolderId": 1234567890}, error=70 + ) + self._make_request( + "getSongsByGenre", {"genre": "genre", "count": "three"}, error=0 + ) + self._make_request( + "getSongsByGenre", {"genre": "genre", "offset": "four"}, error=0 + ) + + rv, child = self._make_request( + "getSongsByGenre", {"genre": "Lampshade"}, tag="songsByGenre" + ) + self.assertEqual(len(child), 1) + if __name__ == "__main__": unittest.main()