Make repeated getAlbumList2 requests with offset to get all albums
This commit is contained in:
parent
89093e7064
commit
713845090c
1 changed files with 14 additions and 2 deletions
|
@ -410,9 +410,9 @@ class SubsonicApi:
|
||||||
return songs
|
return songs
|
||||||
return []
|
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:
|
try:
|
||||||
response = self.connection.getAlbumList2(ltype=ltype, size=size)
|
response = self.connection.getAlbumList2(ltype=ltype, size=size, offset=offset)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Connecting to subsonic failed when loading album list."
|
"Connecting to subsonic failed when loading album list."
|
||||||
|
@ -429,6 +429,18 @@ class SubsonicApi:
|
||||||
return albums
|
return albums
|
||||||
return []
|
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):
|
def get_albums_as_refs(self, artist_id=None):
|
||||||
albums = (
|
albums = (
|
||||||
self.get_raw_album_list("alphabeticalByName")
|
self.get_raw_album_list("alphabeticalByName")
|
||||||
|
|
Loading…
Add table
Reference in a new issue