Merge pull request #12 from gordielachance/media-folders

Media folders
This commit is contained in:
gordielachance 2017-01-14 12:47:36 +01:00 committed by GitHub
commit 10bb432a14
10 changed files with 574 additions and 411 deletions

View File

@ -1,7 +1,9 @@
# Changelog
## v2.0.X
Released XXX
## v2.0.6
Released 14 January 2017
* Upgrade to simpleplugin 2.1.0
* Browse/Library menus (file structure vs ID3 tags)
* Added multilanguage support
## v2.0.5

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.audio.subsonic" name="Subsonic" version="2.0.5" provider-name="BasilFX,grosbouff">
<addon id="plugin.audio.subsonic" name="Subsonic" version="2.0.6" provider-name="BasilFX,grosbouff">
<requires>
<import addon="xbmc.python" version="2.14.0"/>
<import addon="script.module.dateutil" version="2.4.2"/>

View File

@ -140,6 +140,7 @@ class SubsonicClient(libsonic.Connection):
def getArtists(self, *args, **kwargs):
"""
(ID3 tags)
Improve the getArtists method. Ensures IDs are integers.
"""
@ -162,6 +163,7 @@ class SubsonicClient(libsonic.Connection):
def getArtist(self, *args, **kwargs):
"""
(ID3 tags)
Improve the getArtist method. Ensures IDs are integers.
"""
@ -209,6 +211,7 @@ class SubsonicClient(libsonic.Connection):
def getAlbum(self, *args, **kwargs):
"""
(ID3 tags)
Improve the getAlbum method. Ensures the IDs are real integers.
"""
@ -296,24 +299,17 @@ 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"]:
for item in self.walk_directory(index["id"]):
yield item
for artist in index["artist"]:
yield artist
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):
"""
@ -334,6 +330,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):
"""
@ -361,6 +363,7 @@ class SubsonicClient(libsonic.Connection):
def walk_artists(self):
"""
(ID3 tags)
Request all artists and iterate over each item.
"""
@ -372,6 +375,7 @@ class SubsonicClient(libsonic.Connection):
def walk_genres(self):
"""
(ID3 tags)
Request all genres and iterate over each item.
"""
@ -382,6 +386,7 @@ class SubsonicClient(libsonic.Connection):
def walk_albums(self, ltype, size=None, fromYear=None,toYear=None, genre=None, offset=None):
"""
(ID3 tags)
Request all albums for a given genre and iterate over each album.
"""
@ -403,7 +408,8 @@ class SubsonicClient(libsonic.Connection):
def walk_album(self, album_id):
"""
Request an alum and iterate over each item.
(ID3 tags)
Request an album and iterate over each item.
"""
response = self.getAlbum(album_id)

View File

@ -1,4 +1,4 @@
#v2.0.1
#v2.1.0
#https://github.com/romanvm/script.module.simpleplugin/releases
from simpleplugin import *

View File

@ -267,6 +267,16 @@ class Addon(object):
"""
return self._configdir
@property
def version(self):
"""
Addon version
:return: addon version
:rtype: str
"""
return self._addon.getAddonInfo('version')
def get_localized_string(self, id_):
"""
Get localized UI string
@ -274,7 +284,7 @@ class Addon(object):
:param id_: UI string ID
:type id_: int
:return: UI string in the current language
:rtype: unicode
:rtype: str
"""
return self._addon.getLocalizedString(id_).encode('utf-8')
@ -327,7 +337,7 @@ class Addon(object):
value = str(value)
self._addon.setSetting(id_, value)
def log(self, message, level=0):
def log(self, message, level=xbmc.LOGDEBUG):
"""
Add message to Kodi log starting with Addon ID
@ -339,7 +349,7 @@ class Addon(object):
"""
if isinstance(message, unicode):
message = message.encode('utf-8')
xbmc.log('{0}: {1}'.format(self.id, message), level)
xbmc.log('{0} [v.{1}]: {2}'.format(self.id, self.version, message), level)
def log_notice(self, message):
"""
@ -879,7 +889,6 @@ class Plugin(Addon):
self.log_debug('Creating listing from {0}'.format(str(context)))
if context.content is not None:
xbmcplugin.setContent(self._handle, context.content) # This must be at the beginning
listing = []
for item in context.listing:
is_folder = item.get('is_folder', True)
if item.get('list_item') is not None:
@ -889,8 +898,7 @@ class Plugin(Addon):
if item.get('is_playable'):
list_item.setProperty('IsPlayable', 'true')
is_folder = False
listing.append((item['url'], list_item, is_folder))
xbmcplugin.addDirectoryItems(self._handle, listing, len(listing))
xbmcplugin.addDirectoryItem(self._handle, item['url'], list_item, is_folder)
if context.sort_methods is not None:
[xbmcplugin.addSortMethod(self._handle, method) for method in context.sort_methods]
xbmcplugin.endOfDirectory(self._handle,
@ -912,4 +920,4 @@ class Plugin(Addon):
list_item = xbmcgui.ListItem(path=context.path)
else:
list_item = self.create_list_item(context.play_item)
xbmcplugin.setResolvedUrl(self._handle, context.succeeded, list_item)
xbmcplugin.setResolvedUrl(self._handle, context.succeeded, list_item)

860
main.py

File diff suppressed because it is too large Load Diff

View File

@ -73,7 +73,7 @@ msgid "Allow self signed certificates"
msgstr ""
msgctxt "#30017"
msgid "Cache (in minutes) - not yet implemented"
msgid "Cache (in minutes)"
msgstr ""
msgctxt "#30018"
@ -81,7 +81,7 @@ msgid "Cache datas time"
msgstr ""
msgctxt "#30019"
msgid "Artists"
msgid "Library"
msgstr ""
msgctxt "#30020"
@ -140,3 +140,15 @@ msgstr ""
msgctxt "#30035"
msgid "Download"
msgstr ""
msgctxt "#30036"
msgid "Starred tracks"
msgstr ""
msgctxt "#30037"
msgid "Random tracks"
msgstr ""
msgctxt "#30038"
msgid "Browse"
msgstr ""

View File

@ -46,7 +46,7 @@ msgstr "Télécharger"
msgctxt "#30009"
msgid "Download folder"
msgstr "Télécharger le répertoire"
msgstr "Répertoire de téléchargement"
msgctxt "#30010"
msgid "Streaming"
@ -73,16 +73,16 @@ msgid "Allow self signed certificates"
msgstr "Autoriser les certificats auto-signés"
msgctxt "#30017"
msgid "Cache (in minutes) - not yet implemented"
msgstr "Cache (en minutes) - pas encore implémenté"
msgid "Cache (in minutes)"
msgstr "Cache (en minutes)"
msgctxt "#30018"
msgid "Cache datas time"
msgstr "Durée du cache pour les données"
msgctxt "#30019"
msgid "Artists"
msgstr "Artistes"
msgid "Library"
msgstr "Bibliothèque"
msgctxt "#30020"
msgid "Albums"
@ -139,3 +139,15 @@ msgstr "Retirer des favoris Subsonic"
msgctxt "#30035"
msgid "Download"
msgstr "Télécharger"
msgctxt "#30036"
msgid "Starred tracks"
msgstr "Pistes favorites"
msgctxt "#30037"
msgid "Random tracks"
msgstr "Pistes au hasard"
msgctxt "#30038"
msgid "Browse"
msgstr "Parcourir"

View File

@ -73,16 +73,16 @@ msgid "Allow self signed certificates"
msgstr "Erlaube eigensignierte Zertifikate"
msgctxt "#30017"
msgid "Cache (in minutes) - not yet implemented"
msgstr "Speicher (in Minuten) - noch nicht eingebaut"
msgid "Cache (in minutes)"
msgstr "Speicher (in Minuten)"
msgctxt "#30018"
msgid "Cache datas time"
msgstr "Speicher Daten Zeit"
msgctxt "#30019"
msgid "Artists"
msgstr "Künstler"
msgid "Library"
msgstr "Bibliothek"
msgctxt "#30020"
msgid "Albums"
@ -140,3 +140,14 @@ msgctxt "#30035"
msgid "Download"
msgstr "Herunterladen"
msgctxt "#30036"
msgid "Starred tracks"
msgstr "Lieblings lieder"
msgctxt "#30037"
msgid "Random tracks"
msgstr "Zufällig lieder"
msgctxt "#30038"
msgid "Browse"
msgstr "Durchsuchen"

View File

@ -20,9 +20,9 @@
<category label="30013">
<setting label="30001" type="lsep" />
<setting label="30014" id="apiversion" type="labelenum" values="1.11.0|1.12.0|1.13.0|1.14.0" default="1.13.0"/>
<setting id="insecure" type="bool" default="false" />
<setting label="30016" type="lsep" />
<setting label="30018" id="cachetime" type="labelenum" default="5" values="1|5|15|30|60|120|180|720|1440"/>
<setting label="30016" id="insecure" type="bool" default="false" />
<setting label="30017" type="lsep" />
<setting label="30018" id="cachetime" type="labelenum" default="15" values="1|5|15|30|60|120|180|720|1440"/>
</category>
</settings>