added pagination for albums
This commit is contained in:
@ -380,7 +380,7 @@ class SubsonicClient(libsonic.Connection):
|
||||
for genre in response["genres"]["genre"]:
|
||||
yield genre
|
||||
|
||||
def walk_albums(self, ltype, size=None, from_year=None,to_year=None, genre=None):
|
||||
def walk_albums(self, ltype, size=None, from_year=None,to_year=None, genre=None, offset=None):
|
||||
"""
|
||||
Request all albums for a given genre and iterate over each album.
|
||||
"""
|
||||
@ -390,20 +390,16 @@ class SubsonicClient(libsonic.Connection):
|
||||
|
||||
if ltype == 'byYear' and (from_year is None or to_year is None):
|
||||
return
|
||||
|
||||
offset = 0
|
||||
|
||||
while True:
|
||||
response = self.getAlbumList2(
|
||||
ltype=ltype, genre=genre, size=size, offset=offset)
|
||||
response = self.getAlbumList2(
|
||||
ltype=ltype, genre=genre, size=size, offset=offset)
|
||||
|
||||
if not response["albumList2"]["album"]:
|
||||
break
|
||||
if not response["albumList2"]["album"]:
|
||||
return
|
||||
|
||||
for album in response["albumList2"]["album"]:
|
||||
yield album
|
||||
for album in response["albumList2"]["album"]:
|
||||
yield album
|
||||
|
||||
offset += size
|
||||
|
||||
def walk_album(self, album_id):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user