replaced walk_album_list_genre() with walk_album_list()

+ new ‘album_list_size’ setting
This commit is contained in:
gordielachance 2016-09-20 01:09:28 +02:00
parent fb01d0eaa9
commit f929cdbdef
3 changed files with 16 additions and 7 deletions

View File

@ -31,8 +31,9 @@ class Plugin(object):
self.username = addon.getSetting("username")
self.password = addon.getSetting("password")
self.random_count = addon.getSetting("random_count")
self.bitrate = addon.getSetting("bitrate")
self.random_count = int(addon.getSetting("random_count"))
self.album_list_size = int(addon.getSetting("album_list_size"))
self.bitrate = int(addon.getSetting("bitrate"))
self.transcode_format = addon.getSetting("transcode_format")
# Create connection
@ -229,11 +230,12 @@ class Plugin(object):
Display album list by genre menu.
"""
size = self.album_list_size
genre = self.addon_args["foldername"][0].decode("utf-8")
xbmcplugin.setContent(self.addon_handle, "albums")
for album in self.connection.walk_album_list_genre(genre):
for album in self.connection.walk_album_list('byGenre',size,None,None,genre):
self.add_album(album, show_artist=True)
xbmcplugin.endOfDirectory(self.addon_handle)

View File

@ -391,16 +391,22 @@ class SubsonicClient(libsonic.Connection):
for genre in response["genres"]["genre"]:
yield genre
def walk_album_list_genre(self, genre):
def walk_album_list(self, ltype, size=10, fromYear=None,toYear=None, genre=None):
"""
Request all albums for a given genre and iterate over each album.
"""
if ltype == 'byGenre' and genre is None:
return
if ltype == 'byYear' and (fromYear is None or toYear is None):
return
offset = 0
while True:
response = self.getAlbumList2(
ltype="byGenre", genre=genre, size=500, offset=offset)
ltype=ltype, size=size, offset=offset, fromYear=fromYear, toYear=toYear, genre=genre)
if not response["albumList2"]["album"]:
break
@ -408,7 +414,7 @@ class SubsonicClient(libsonic.Connection):
for album in response["albumList2"]["album"]:
yield album
offset += 500
offset += size
def walk_album(self, album_id):
"""

View File

@ -4,6 +4,7 @@
<setting id="username" type="text" label="Username" default="guest3"/>
<setting id="password" type="text" option="hidden" label="Password" default="guest"/>
<setting id="random_count" type="labelenum" label="Random songs" values="10|15|20|25"/>
<setting id="album_list_size" type="labelenum" label="Albums list items" default="50" values="50|100|200|250|500"/>
<setting id="transcode_format" type="labelenum" label="Transcode format" values="mp3|raw|flv|ogg"/>
<setting id="bitrate" type="labelenum" label="Bitrate" values="320|256|224|192|160|128|112|96|80|64|56|48|40|32"/>
</settings>