simpleplugin 2.1.0
This commit is contained in:
parent
0344163cd5
commit
290fa837b3
|
@ -1,4 +1,4 @@
|
||||||
#v2.0.1
|
#v2.1.0
|
||||||
#https://github.com/romanvm/script.module.simpleplugin/releases
|
#https://github.com/romanvm/script.module.simpleplugin/releases
|
||||||
|
|
||||||
from simpleplugin import *
|
from simpleplugin import *
|
|
@ -267,6 +267,16 @@ class Addon(object):
|
||||||
"""
|
"""
|
||||||
return self._configdir
|
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_):
|
def get_localized_string(self, id_):
|
||||||
"""
|
"""
|
||||||
Get localized UI string
|
Get localized UI string
|
||||||
|
@ -274,7 +284,7 @@ class Addon(object):
|
||||||
:param id_: UI string ID
|
:param id_: UI string ID
|
||||||
:type id_: int
|
:type id_: int
|
||||||
:return: UI string in the current language
|
:return: UI string in the current language
|
||||||
:rtype: unicode
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
return self._addon.getLocalizedString(id_).encode('utf-8')
|
return self._addon.getLocalizedString(id_).encode('utf-8')
|
||||||
|
|
||||||
|
@ -327,7 +337,7 @@ class Addon(object):
|
||||||
value = str(value)
|
value = str(value)
|
||||||
self._addon.setSetting(id_, 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
|
Add message to Kodi log starting with Addon ID
|
||||||
|
|
||||||
|
@ -339,7 +349,7 @@ class Addon(object):
|
||||||
"""
|
"""
|
||||||
if isinstance(message, unicode):
|
if isinstance(message, unicode):
|
||||||
message = message.encode('utf-8')
|
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):
|
def log_notice(self, message):
|
||||||
"""
|
"""
|
||||||
|
@ -879,7 +889,6 @@ class Plugin(Addon):
|
||||||
self.log_debug('Creating listing from {0}'.format(str(context)))
|
self.log_debug('Creating listing from {0}'.format(str(context)))
|
||||||
if context.content is not None:
|
if context.content is not None:
|
||||||
xbmcplugin.setContent(self._handle, context.content) # This must be at the beginning
|
xbmcplugin.setContent(self._handle, context.content) # This must be at the beginning
|
||||||
listing = []
|
|
||||||
for item in context.listing:
|
for item in context.listing:
|
||||||
is_folder = item.get('is_folder', True)
|
is_folder = item.get('is_folder', True)
|
||||||
if item.get('list_item') is not None:
|
if item.get('list_item') is not None:
|
||||||
|
@ -889,8 +898,7 @@ class Plugin(Addon):
|
||||||
if item.get('is_playable'):
|
if item.get('is_playable'):
|
||||||
list_item.setProperty('IsPlayable', 'true')
|
list_item.setProperty('IsPlayable', 'true')
|
||||||
is_folder = False
|
is_folder = False
|
||||||
listing.append((item['url'], list_item, is_folder))
|
xbmcplugin.addDirectoryItem(self._handle, item['url'], list_item, is_folder)
|
||||||
xbmcplugin.addDirectoryItems(self._handle, listing, len(listing))
|
|
||||||
if context.sort_methods is not None:
|
if context.sort_methods is not None:
|
||||||
[xbmcplugin.addSortMethod(self._handle, method) for method in context.sort_methods]
|
[xbmcplugin.addSortMethod(self._handle, method) for method in context.sort_methods]
|
||||||
xbmcplugin.endOfDirectory(self._handle,
|
xbmcplugin.endOfDirectory(self._handle,
|
||||||
|
@ -912,4 +920,4 @@ class Plugin(Addon):
|
||||||
list_item = xbmcgui.ListItem(path=context.path)
|
list_item = xbmcgui.ListItem(path=context.path)
|
||||||
else:
|
else:
|
||||||
list_item = self.create_list_item(context.play_item)
|
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)
|
Loading…
Reference in New Issue