From 713845090cee75e08af1bebb23c6a329a71565ef Mon Sep 17 00:00:00 2001 From: Bryn Edwards Date: Sat, 14 Mar 2020 18:43:53 +0000 Subject: [PATCH 1/5] Make repeated getAlbumList2 requests with offset to get all albums --- mopidy_subidy/subsonic_api.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/mopidy_subidy/subsonic_api.py b/mopidy_subidy/subsonic_api.py index e8b4ad2..78c789c 100644 --- a/mopidy_subidy/subsonic_api.py +++ b/mopidy_subidy/subsonic_api.py @@ -410,9 +410,9 @@ class SubsonicApi: return songs return [] - def get_raw_album_list(self, ltype, size=MAX_LIST_RESULTS): + def get_more_albums(self, ltype, size=MAX_LIST_RESULTS, offset=0): try: - response = self.connection.getAlbumList2(ltype=ltype, size=size) + response = self.connection.getAlbumList2(ltype=ltype, size=size, offset=offset) except Exception: logger.warning( "Connecting to subsonic failed when loading album list." @@ -429,6 +429,18 @@ class SubsonicApi: return albums return [] + def get_raw_album_list(self, ltype, size=MAX_LIST_RESULTS): + offset = 0 + total = [] + albums = self.get_more_albums(ltype, size, offset) + total = albums + while len(albums) == size: + # try getting more albums + offset = offset + size + albums = self.get_more_albums(ltype, size, offset) + total = total + albums + return total + def get_albums_as_refs(self, artist_id=None): albums = ( self.get_raw_album_list("alphabeticalByName") From ee3e36408ddd7c21b4bff45de3a605fa52114a2b Mon Sep 17 00:00:00 2001 From: Bryn Edwards Date: Sat, 14 Mar 2020 18:57:55 +0000 Subject: [PATCH 2/5] formatting --- mopidy_subidy/subsonic_api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mopidy_subidy/subsonic_api.py b/mopidy_subidy/subsonic_api.py index 78c789c..4afec91 100644 --- a/mopidy_subidy/subsonic_api.py +++ b/mopidy_subidy/subsonic_api.py @@ -412,7 +412,9 @@ class SubsonicApi: def get_more_albums(self, ltype, size=MAX_LIST_RESULTS, offset=0): try: - response = self.connection.getAlbumList2(ltype=ltype, size=size, offset=offset) + response = self.connection.getAlbumList2( + ltype=ltype, size=size, offset=offset + ) except Exception: logger.warning( "Connecting to subsonic failed when loading album list." From 584209c1347e6a0c20577da29a8211fb91a7f434 Mon Sep 17 00:00:00 2001 From: Bryn Edwards Date: Wed, 25 Mar 2020 08:03:46 +0000 Subject: [PATCH 3/5] comment --- mopidy_subidy/subsonic_api.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mopidy_subidy/subsonic_api.py b/mopidy_subidy/subsonic_api.py index 4afec91..dfa1db1 100644 --- a/mopidy_subidy/subsonic_api.py +++ b/mopidy_subidy/subsonic_api.py @@ -432,12 +432,18 @@ class SubsonicApi: return [] def get_raw_album_list(self, ltype, size=MAX_LIST_RESULTS): + """ + Subsonic servers don't offer any way to retrieve the total number + of albums to get, and the spec states that the max number returned + for `getAlbumList2` is 500. To get all the albums, we make a + `getAlbumList2` request each time the response contains 500 albums. If + it does not, we assume we have all the albums and return them. + """ offset = 0 total = [] albums = self.get_more_albums(ltype, size, offset) total = albums while len(albums) == size: - # try getting more albums offset = offset + size albums = self.get_more_albums(ltype, size, offset) total = total + albums From cf588481c638d7b911109b96ae138c194dd33029 Mon Sep 17 00:00:00 2001 From: Frederick Date: Thu, 19 Nov 2020 09:06:50 +0100 Subject: [PATCH 4/5] Add note about maintenance --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index bf10e40..dc5e316 100644 --- a/README.rst +++ b/README.rst @@ -14,6 +14,8 @@ Mopidy-Subidy :target: https://codecov.io/gh/Prior99/mopidy-subidy :alt: Test coverage +**This library is actively looking for maintainers to help out as I do not have the time or need to maintain this anymore. Please contact me if you feel that you could maintain this.** + A Subsonic backend for Mopidy using `py-sonic `_. From e8493923c1c15db1424d41444aa799c81a337e57 Mon Sep 17 00:00:00 2001 From: Frederick Date: Thu, 19 Nov 2020 09:14:44 +0100 Subject: [PATCH 5/5] Update version --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 2bff96f..9610cce 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = Mopidy-Subidy -version = 1.0.0 +version = 1.1.0 url = https://github.com/Prior99/mopidy-subidy author = prior99 author_email = fgnodtke@cronosx.de