new 'Browse' top menu to list media folders

This commit is contained in:
rickybiscus 2017-01-08 11:09:54 +01:00
parent 5484614cc1
commit d9210dcaef
1 changed files with 37 additions and 3 deletions

40
main.py
View File

@ -8,7 +8,6 @@
import os import os
import xbmcaddon import xbmcaddon
lang = xbmcaddon.Addon()
import xbmcplugin import xbmcplugin
import xbmcgui import xbmcgui
import json import json
@ -16,7 +15,7 @@ import shutil
import dateutil.parser import dateutil.parser
from datetime import datetime from datetime import datetime
lang = xbmcaddon.Addon()
# Add the /lib folder to sys # Add the /lib folder to sys
sys.path.append(xbmc.translatePath(os.path.join(xbmcaddon.Addon("plugin.audio.subsonic").getAddonInfo("path"), "lib"))) sys.path.append(xbmc.translatePath(os.path.join(xbmcaddon.Addon("plugin.audio.subsonic").getAddonInfo("path"), "lib")))
@ -101,6 +100,11 @@ def root(params):
'name': lang.getLocalizedString(30022), 'name': lang.getLocalizedString(30022),
'callback': 'list_playlists', 'callback': 'list_playlists',
'thumb': None 'thumb': None
},
'folders': {
'name': 'Browse',
'callback': 'list_folders',
'thumb': None
} }
} }
@ -801,10 +805,40 @@ def list_playlists(params):
#content = None #string - current plugin content, e.g. movies or episodes. #content = None #string - current plugin content, e.g. movies or episodes.
) )
@plugin.action()
def list_folders(params):
# get connection
connection = get_connection()
if connection is False:
return
listing = []
# Get items
items = connection.walk_folders()
# Iterate through items
for item in items:
entry = {
'label': item.get('name'),
'url': plugin.get_url(
action= 'list_indexes',
folder_id= item.get('id'),
menu_id= params.get('menu_id')
)
}
listing.append(entry)
return plugin.create_listing(
listing
)
def get_entry_playlist(item,params): def get_entry_playlist(item,params):
image = connection.getCoverArtUrl(item.get('coverArt')) image = connection.getCoverArtUrl(item.get('coverArt'))
return { return {
'label': item['name'], 'label': item.get('name'),
'thumb': image, 'thumb': image,
'fanart': image, 'fanart': image,
'url': plugin.get_url( 'url': plugin.get_url(