Browse/Library menus (file structure vs ID3 tags)
This commit is contained in:
parent
3ed7b231cc
commit
c6e9cc92e8
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## v2.0.X
|
## v2.0.X
|
||||||
Released XXX
|
Released XXX
|
||||||
|
* Browse/Library menus (file structure vs ID3 tags)
|
||||||
* Added multilanguage support
|
* Added multilanguage support
|
||||||
|
|
||||||
## v2.0.5
|
## v2.0.5
|
||||||
|
|
|
@ -140,6 +140,7 @@ class SubsonicClient(libsonic.Connection):
|
||||||
|
|
||||||
def getArtists(self, *args, **kwargs):
|
def getArtists(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
(ID3 tags)
|
||||||
Improve the getArtists method. Ensures IDs are integers.
|
Improve the getArtists method. Ensures IDs are integers.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -162,6 +163,7 @@ class SubsonicClient(libsonic.Connection):
|
||||||
|
|
||||||
def getArtist(self, *args, **kwargs):
|
def getArtist(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
(ID3 tags)
|
||||||
Improve the getArtist method. Ensures IDs are integers.
|
Improve the getArtist method. Ensures IDs are integers.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -209,6 +211,7 @@ class SubsonicClient(libsonic.Connection):
|
||||||
|
|
||||||
def getAlbum(self, *args, **kwargs):
|
def getAlbum(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
(ID3 tags)
|
||||||
Improve the getAlbum method. Ensures the IDs are real integers.
|
Improve the getAlbum method. Ensures the IDs are real integers.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -304,16 +307,9 @@ class SubsonicClient(libsonic.Connection):
|
||||||
response = self.getIndexes(folder_id)
|
response = self.getIndexes(folder_id)
|
||||||
|
|
||||||
for index in response["indexes"]["index"]:
|
for index in response["indexes"]["index"]:
|
||||||
for index in index["artist"]:
|
for artist in index["artist"]:
|
||||||
for item in self.walk_directory(index["id"]):
|
yield artist
|
||||||
yield item
|
|
||||||
|
|
||||||
for child in response["indexes"]["child"]:
|
|
||||||
if child.get("isDir"):
|
|
||||||
for child in self.walk_directory(child["id"]):
|
|
||||||
yield child
|
|
||||||
else:
|
|
||||||
yield child
|
|
||||||
|
|
||||||
def walk_playlists(self):
|
def walk_playlists(self):
|
||||||
"""
|
"""
|
||||||
|
@ -367,6 +363,7 @@ class SubsonicClient(libsonic.Connection):
|
||||||
|
|
||||||
def walk_artists(self):
|
def walk_artists(self):
|
||||||
"""
|
"""
|
||||||
|
(ID3 tags)
|
||||||
Request all artists and iterate over each item.
|
Request all artists and iterate over each item.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -409,7 +406,7 @@ class SubsonicClient(libsonic.Connection):
|
||||||
|
|
||||||
def walk_album(self, album_id):
|
def walk_album(self, album_id):
|
||||||
"""
|
"""
|
||||||
Request an alum and iterate over each item.
|
Request an album and iterate over each item.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
response = self.getAlbum(album_id)
|
response = self.getAlbum(album_id)
|
||||||
|
|
125
main.py
125
main.py
|
@ -81,9 +81,14 @@ def root(params):
|
||||||
listing = []
|
listing = []
|
||||||
|
|
||||||
menus = {
|
menus = {
|
||||||
'artists': {
|
'folders': {
|
||||||
|
'name': 'Browse',
|
||||||
|
'callback': 'browse_folders',
|
||||||
|
'thumb': None
|
||||||
|
},
|
||||||
|
'library': {
|
||||||
'name': lang.getLocalizedString(30019),
|
'name': lang.getLocalizedString(30019),
|
||||||
'callback': 'list_artists',
|
'callback': 'browse_library',
|
||||||
'thumb': None
|
'thumb': None
|
||||||
},
|
},
|
||||||
'albums': {
|
'albums': {
|
||||||
|
@ -100,11 +105,6 @@ 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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ def root(params):
|
||||||
#succeeded = True, #if False Kodi won’t open a new listing and stays on the current level.
|
#succeeded = True, #if False Kodi won’t open a new listing and stays on the current level.
|
||||||
#update_listing = False, #if True, Kodi won’t open a sub-listing but refresh the current one.
|
#update_listing = False, #if True, Kodi won’t open a sub-listing but refresh the current one.
|
||||||
#cache_to_disk = True, #cache this view to disk.
|
#cache_to_disk = True, #cache this view to disk.
|
||||||
#sort_methods = None, #he list of integer constants representing virtual folder sort methods.
|
sort_methods = None, #he list of integer constants representing virtual folder sort methods.
|
||||||
#view_mode = None, #a numeric code for a skin view mode. View mode codes are different in different skins except for 50 (basic listing).
|
#view_mode = None, #a numeric code for a skin view mode. View mode codes are different in different skins except for 50 (basic listing).
|
||||||
#content = None #string - current plugin content, e.g. ‘movies’ or ‘episodes’.
|
#content = None #string - current plugin content, e.g. ‘movies’ or ‘episodes’.
|
||||||
)
|
)
|
||||||
|
@ -256,7 +256,7 @@ def menu_tracks(params):
|
||||||
|
|
||||||
@plugin.action()
|
@plugin.action()
|
||||||
#@plugin.cached(cachetime) #if cache is enabled, cache data for the following function
|
#@plugin.cached(cachetime) #if cache is enabled, cache data for the following function
|
||||||
def list_artists(params):
|
def browse_library(params):
|
||||||
|
|
||||||
# get connection
|
# get connection
|
||||||
connection = get_connection()
|
connection = get_connection()
|
||||||
|
@ -806,38 +806,7 @@ def list_playlists(params):
|
||||||
)
|
)
|
||||||
|
|
||||||
@plugin.action()
|
@plugin.action()
|
||||||
def list_indexes(params):
|
def browse_folders(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
|
# get connection
|
||||||
connection = get_connection()
|
connection = get_connection()
|
||||||
|
|
||||||
|
@ -854,7 +823,7 @@ def list_folders(params):
|
||||||
entry = {
|
entry = {
|
||||||
'label': item.get('name'),
|
'label': item.get('name'),
|
||||||
'url': plugin.get_url(
|
'url': plugin.get_url(
|
||||||
action= 'list_indexes',
|
action= 'browse_indexes',
|
||||||
folder_id= item.get('id'),
|
folder_id= item.get('id'),
|
||||||
menu_id= params.get('menu_id')
|
menu_id= params.get('menu_id')
|
||||||
|
|
||||||
|
@ -863,11 +832,79 @@ def list_folders(params):
|
||||||
listing.append(entry)
|
listing.append(entry)
|
||||||
|
|
||||||
if len(listing) == 1:
|
if len(listing) == 1:
|
||||||
plugin.log('One single Media Folder found; do return listing from list_indexes()...')
|
plugin.log('One single Media Folder found; do return listing from browse_indexes()...')
|
||||||
return list_indexes(params)
|
return browse_indexes(params)
|
||||||
else:
|
else:
|
||||||
return plugin.create_listing(listing)
|
return plugin.create_listing(listing)
|
||||||
|
|
||||||
|
@plugin.action()
|
||||||
|
def browse_indexes(params):
|
||||||
|
# get connection
|
||||||
|
connection = get_connection()
|
||||||
|
|
||||||
|
if connection is False:
|
||||||
|
return
|
||||||
|
|
||||||
|
listing = []
|
||||||
|
|
||||||
|
# Get items
|
||||||
|
# optional folder ID
|
||||||
|
folder_id = params.get('folder_id')
|
||||||
|
items = connection.walk_index(folder_id)
|
||||||
|
|
||||||
|
# Iterate through items
|
||||||
|
for item in items:
|
||||||
|
entry = {
|
||||||
|
'label': item.get('name'),
|
||||||
|
'url': plugin.get_url(
|
||||||
|
action= 'list_directory',
|
||||||
|
id= item.get('id'),
|
||||||
|
menu_id= params.get('menu_id')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
listing.append(entry)
|
||||||
|
|
||||||
|
return plugin.create_listing(
|
||||||
|
listing
|
||||||
|
)
|
||||||
|
|
||||||
|
@plugin.action()
|
||||||
|
def list_directory(params):
|
||||||
|
# get connection
|
||||||
|
connection = get_connection()
|
||||||
|
|
||||||
|
if connection is False:
|
||||||
|
return
|
||||||
|
|
||||||
|
listing = []
|
||||||
|
|
||||||
|
# Get items
|
||||||
|
id = params.get('id')
|
||||||
|
items = connection.walk_directory(id)
|
||||||
|
|
||||||
|
# Iterate through items
|
||||||
|
for item in items:
|
||||||
|
|
||||||
|
#is a directory
|
||||||
|
if (item.get('isDir')==True):
|
||||||
|
entry = {
|
||||||
|
'label': item.get('title'),
|
||||||
|
'url': plugin.get_url(
|
||||||
|
action= 'list_directory',
|
||||||
|
id= item.get('id'),
|
||||||
|
menu_id= params.get('menu_id')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
entry = get_entry_track(item,params)
|
||||||
|
|
||||||
|
|
||||||
|
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 {
|
||||||
|
|
|
@ -81,7 +81,7 @@ msgid "Cache datas time"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#30019"
|
msgctxt "#30019"
|
||||||
msgid "Artists"
|
msgid "Library"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#30020"
|
msgctxt "#30020"
|
||||||
|
|
|
@ -46,7 +46,7 @@ msgstr "Télécharger"
|
||||||
|
|
||||||
msgctxt "#30009"
|
msgctxt "#30009"
|
||||||
msgid "Download folder"
|
msgid "Download folder"
|
||||||
msgstr "Télécharger le répertoire"
|
msgstr "Répertoire de téléchargement"
|
||||||
|
|
||||||
msgctxt "#30010"
|
msgctxt "#30010"
|
||||||
msgid "Streaming"
|
msgid "Streaming"
|
||||||
|
@ -81,8 +81,8 @@ msgid "Cache datas time"
|
||||||
msgstr "Durée du cache pour les données"
|
msgstr "Durée du cache pour les données"
|
||||||
|
|
||||||
msgctxt "#30019"
|
msgctxt "#30019"
|
||||||
msgid "Artists"
|
msgid "Library"
|
||||||
msgstr "Artistes"
|
msgstr "Bibliothèque"
|
||||||
|
|
||||||
msgctxt "#30020"
|
msgctxt "#30020"
|
||||||
msgid "Albums"
|
msgid "Albums"
|
||||||
|
|
|
@ -81,8 +81,8 @@ msgid "Cache datas time"
|
||||||
msgstr "Speicher Daten Zeit"
|
msgstr "Speicher Daten Zeit"
|
||||||
|
|
||||||
msgctxt "#30019"
|
msgctxt "#30019"
|
||||||
msgid "Artists"
|
msgid "Library"
|
||||||
msgstr "Künstler"
|
msgstr "Bibliothek"
|
||||||
|
|
||||||
msgctxt "#30020"
|
msgctxt "#30020"
|
||||||
msgid "Albums"
|
msgid "Albums"
|
||||||
|
|
Loading…
Reference in New Issue