plugin.video.torrserve
|
Public Member Functions | |
def | __init__ (self, id_='') |
def | __getattr__ (self, item) |
def | __str__ (self) |
def | __repr__ (self) |
def | addon (self) |
def | id (self) |
def | name (self) |
def | path (self) |
def | icon (self) |
def | fanart (self) |
def | config_dir (self) |
def | version (self) |
def | get_localized_string (self, id_) |
def | get_setting (self, id_, convert=True) |
def | set_setting (self, id_, value) |
def | log (self, message, level=xbmc.LOGDEBUG) |
def | log_notice (self, message) |
def | log_warning (self, message) |
def | log_info (self, message) |
def | log_error (self, message) |
def | log_debug (self, message) |
def | get_storage (self, filename='storage.pcl') |
def | get_mem_storage (self, storage_id='', window_id=10000) |
def | cached (self, duration=10) |
def | mem_cached (self, duration=10) |
def | gettext (self, ui_string) |
def | initialize_gettext (self) |
Base addon class Provides access to basic addon parameters :param id_: addon id, e.g. 'plugin.video.foo' (optional) :type id_: str
def site-packages.torrserve.simpleplugin.Addon.__init__ | ( | self, | |
id_ = '' |
|||
) |
Class constructor :type id_: str
def site-packages.torrserve.simpleplugin.Addon.__getattr__ | ( | self, | |
item | |||
) |
Get addon setting as an Addon instance attribute E.g. addon.my_setting is equal to addon.get_setting('my_setting') :param item: :type item: str
def site-packages.torrserve.simpleplugin.Addon.addon | ( | self | ) |
Kodi Addon instance that represents this Addon :return: Addon instance :rtype: xbmcaddon.Addon
def site-packages.torrserve.simpleplugin.Addon.cached | ( | self, | |
duration = 10 |
|||
) |
Cached decorator Used to cache function return data Usage:: @plugin.cached(30) def my_func(*args, **kwargs): # Do some stuff return value :param duration: caching duration in min (positive values only) :type duration: int :raises ValueError: if duration is zero or negative
def site-packages.torrserve.simpleplugin.Addon.config_dir | ( | self | ) |
Addon config dir :return: path to the addon config dir :rtype: str
def site-packages.torrserve.simpleplugin.Addon.fanart | ( | self | ) |
Addon fanart :return: path to the addon fanart image :rtype: str
def site-packages.torrserve.simpleplugin.Addon.get_localized_string | ( | self, | |
id_ | |||
) |
Get localized UI string :param id_: UI string ID :type id_: int :return: UI string in the current language :rtype: str
def site-packages.torrserve.simpleplugin.Addon.get_mem_storage | ( | self, | |
storage_id = '' , |
|||
window_id = 10000 |
|||
) |
Creates an in-memory storage for this addon with :class:`dict`-like interface The storage can store picklable Python objects as long as Kodi is running and storage contents can be shared between Python processes. Different addons have separate storages, so storages with the same names created with this method do not conflict. Example:: addon = Addon() storage = addon.get_mem_storage() foo = storage['foo'] storage['bar'] = bar :param storage_id: optional storage ID (case-insensitive). :type storage_id: str :param window_id: the ID of a Kodi Window object where storage contents will be stored. :type window_id: int :return: in-memory storage for this addon :rtype: MemStorage
def site-packages.torrserve.simpleplugin.Addon.get_setting | ( | self, | |
id_, | |||
convert = True |
|||
) |
Get addon setting If ``convert=True``, 'bool' settings are converted to Python :class:`bool` values, and numeric strings to Python :class:`long` or :class:`float` depending on their format. .. note:: Settings can also be read via :class:`Addon` instance poperties named as the respective settings. I.e. ``addon.foo`` is equal to ``addon.get_setting('foo')``. :param id_: setting ID :type id_: str :param convert: try to guess and convert the setting to an appropriate type E.g. ``'1.0'`` will be converted to float ``1.0`` number, ``'true'`` to ``True`` and so on. :type convert: bool :return: setting value
def site-packages.torrserve.simpleplugin.Addon.get_storage | ( | self, | |
filename = 'storage.pcl' |
|||
) |
Get a persistent :class:`Storage` instance for storing arbitrary values between addon calls. A :class:`Storage` instance can be used as a context manager. Example:: with plugin.get_storage() as storage: storage['param1'] = value1 value2 = storage['param2'] .. note:: After exiting :keyword:`with` block a :class:`Storage` instance is invalidated. :param filename: the name of a storage file (optional) :type filename: str :return: Storage object :rtype: Storage
def site-packages.torrserve.simpleplugin.Addon.gettext | ( | self, | |
ui_string | |||
) |
Get a translated UI string from addon localization files. This function emulates GNU Gettext for more convenient access to localized addon UI strings. To reduce typing this method object can be assigned to a ``_`` (single underscore) variable. For using gettext emulation :meth:`Addon.initialize_gettext` method needs to be called first. See documentation for that method for more info about Gettext emulation. :param ui_string: a UI string from English :file:`strings.po`. :type ui_string: str :return: a UI string from translated :file:`strings.po`. :rtype: unicode :raises SimplePluginError: if :meth:`Addon.initialize_gettext` wasn't called first or if a string is not found in English :file:`strings.po`.
def site-packages.torrserve.simpleplugin.Addon.icon | ( | self | ) |
Addon icon :return: path to the addon icon image :rtype: str
def site-packages.torrserve.simpleplugin.Addon.id | ( | self | ) |
Addon ID :return: Addon ID, e.g. 'plugin.video.foo' :rtype: str
def site-packages.torrserve.simpleplugin.Addon.initialize_gettext | ( | self | ) |
Initialize GNU gettext emulation in addon Kodi localization system for addons is not very convenient because you need to operate with numeric string codes instead of UI strings themselves which reduces code readability and may lead to errors. The :class:`Addon` class provides facilities for emulating GNU Gettext localization system. This allows to use UI strings from addon's English :file:`strings.po` file instead of numeric codes to return localized strings from respective localized :file:`.po` files. This method returns :meth:`Addon.gettext` method object that can be assigned to a short alias to reduce typing. Traditionally, ``_`` (a single underscore) is used for this purpose. Example:: addon = simpleplugin.Addon() _ = addon.initialize_gettext() xbmcgui.Dialog().notification(_('Warning!'), _('Something happened')) In the preceding example the notification strings will be replaced with localized versions if these strings are translated. :return: :meth:`Addon.gettext` method object :raises SimplePluginError: if the addon's English :file:`strings.po` file is missing
def site-packages.torrserve.simpleplugin.Addon.log | ( | self, | |
message, | |||
level = xbmc.LOGDEBUG |
|||
) |
Add message to Kodi log starting with Addon ID :param message: message to be written into the Kodi log :type message: str :param level: log level. :mod:`xbmc` module provides the necessary symbolic constants. Default: ``xbmc.LOGDEBUG`` :type level: int
def site-packages.torrserve.simpleplugin.Addon.log_debug | ( | self, | |
message | |||
) |
Add debug message to the Kodi log :param message: message to write to the Kodi log :type message: str
def site-packages.torrserve.simpleplugin.Addon.log_error | ( | self, | |
message | |||
) |
Add ERROR message to the Kodi log :param message: message to write to the Kodi log :type message: str
def site-packages.torrserve.simpleplugin.Addon.log_info | ( | self, | |
message | |||
) |
Add INFO message to th Kodi log :param message: message to write to the Kodi log :type message: str
def site-packages.torrserve.simpleplugin.Addon.log_notice | ( | self, | |
message | |||
) |
Add NOTICE message to the Kodi log :param message: message to write to the Kodi log :type message: str
def site-packages.torrserve.simpleplugin.Addon.log_warning | ( | self, | |
message | |||
) |
Add WARNING message to the Kodi log :param message: message to write to the Kodi log :type message: str
def site-packages.torrserve.simpleplugin.Addon.mem_cached | ( | self, | |
duration = 10 |
|||
) |
In-memory cache decorator Usage:: @plugin.mem_cached(30) def my_func(*args, **kwargs): # Do some stuff return value :param duration: caching duration in min (positive values only) :type duration: int :raises ValueError: if duration is zero or negative
def site-packages.torrserve.simpleplugin.Addon.name | ( | self | ) |
Addon Name :return: Addon Name e.g. 'Foo' :rtype: str
def site-packages.torrserve.simpleplugin.Addon.path | ( | self | ) |
Addon path :return: path to the addon folder :rtype: str
def site-packages.torrserve.simpleplugin.Addon.set_setting | ( | self, | |
id_, | |||
value | |||
) |
Set addon setting Python :class:`bool` type are converted to ``'true'`` or ``'false'`` Non-string/non-unicode values are converted to strings. .. warning:: Setting values via :class:`Addon` instance properties is not supported! Values can only be set using :meth:`Addon.set_setting` method. :param id_: setting ID :type id_: str :param value: setting value
def site-packages.torrserve.simpleplugin.Addon.version | ( | self | ) |
Addon version :return: addon version :rtype: str