WIP : list_indexes function (not working yet)

This commit is contained in:
rickybiscus 2017-01-08 11:11:05 +01:00
parent d9210dcaef
commit 7d26333ce0
2 changed files with 39 additions and 2 deletions

View File

@ -296,12 +296,12 @@ class SubsonicClient(libsonic.Connection):
else:
return super(SubsonicClient, self)._doBinReq(*args, **kwargs)
def walk_index(self):
def walk_index(self, folder_id=None):
"""
Request Subsonic's index and iterate each item.
"""
response = self.getIndexes()
response = self.getIndexes(folder_id)
for index in response["indexes"]["index"]:
for index in index["artist"]:
@ -334,6 +334,12 @@ class SubsonicClient(libsonic.Connection):
for child in response["playlist"]["entry"]:
yield child
def walk_folders(self):
response = self.getMusicFolders()
for child in response["musicFolders"]["musicFolder"]:
yield child
def walk_directory(self, directory_id):
"""

31
main.py
View File

@ -805,6 +805,37 @@ def list_playlists(params):
#content = None #string - current plugin content, e.g. movies or episodes.
)
@plugin.action()
def list_indexes(params):
# get connection
connection = get_connection()
if connection is False:
return
listing = []
# Get items
folder_id = params.get('folder_id')
items = connection.walk_index(folder_id)
plugin.log('list_indexes:')
# Iterate through items
for item in items:
entry = {
'label': item.get('name'),
'url': plugin.get_url(
action= 'list_albums',
artist_id= item.get('id'),
menu_id= params.get('menu_id')
)
}
listing.append(entry)
return plugin.create_listing(
listing
)
@plugin.action()
def list_folders(params):
# get connection