Covers every method of xbmcswift2
The Plugin objects encapsulates all the properties and methods necessary for running an XBMC plugin. The plugin instance is a central place for registering view functions and keeping track of plugin state.
Usually the plugin instance is created in the main addon.py file for the plugin. Typical creation looks like this:
from xbmcswift2 import Plugin
plugin = Plugin('Hello XBMC')
Changed in version 0.2: The addon_id and filepath parameters are now optional. They will now default to the correct values.
Parameters: |
|
---|
Adds ListItems to the XBMC interface. Each item in the provided list should either be instances of xbmcswift2.ListItem, or regular dictionaries that will be passed to xbmcswift2.ListItem.from_dict. Returns the list of ListItems.
Parameters: | items – An iterable of items where each item is either a dictionary with keys/values suitable for passing to xbmcswift2.ListItem.from_dict() or an instance of xbmcswift2.ListItem. |
---|
A wrapper for xbmcplugin.addSortMethod(). You can use dir(xbmcswift2.SortMethod) to list all available sort methods.
Parameters: |
|
---|
Adds the provided list of items to the specified playlist. Available playlists include video and music.
This method adds a URL rule for routing purposes. The provided name can be different from the view function name if desired. The provided name is what is used in url_for to build a URL.
The route decorator provides the same functionality.
The list of currently added items.
Even after repeated calls to add_items(), this property will contain the complete list of added items.
This plugin’s wrapped instance of xbmcaddon.Addon.
A decorator that will cache the output of the wrapped function. The key used for the cache is the function name as well as the *args and **kwargs passed to the function.
Parameters: | TTL – time to live in minutes |
---|
Note
For route caching, you should use xbmcswift2.Plugin.cached_route().
A decorator to add a route to a view and also apply caching. The url_rule, name and options arguments are the same arguments for the route function. The TTL argument if given will passed along to the caching decorator.
Clears the storage that caches results when using xbmcswift2.Plugin.cached_route() or xbmcswift2.Plugin.cached().
Wrapper for xbmcplugin.endOfDirectory. Records state in self._end_of_directory.
Typically it is not necessary to call this method directly, as calling finish() will call this method.
Adds the provided items to the XBMC interface.
Parameters: |
|
---|---|
Returns: | a list of all ListItems added to the XBMC interface. |
Returns the settings value for the provided key. If converter is str, unicode, bool or int the settings value will be returned converted to the provided type. If choices is an instance of list or tuple its item at position of the settings value be returned. .. note:: It is suggested to always use unicode for text-settings
because else xbmc returns utf-8 encoded strings.
Parameters: |
|
---|
Returns a storage for the given name. The returned storage is a fully functioning python dictionary and is designed to be used that way. It is usually not necessary for the caller to load or save the storage manually. If the storage does not already exist, it will be created.
See also
xbmcswift2.TimedStorage for more details.
Parameters: |
|
---|
Returns the localized string from strings.xml for the given stringid.
Attempts to return a view_mode_id for a given view_mode taking into account the current skin. If not view_mode_id can be found, None is returned. ‘thumbnail’ is currently the only suppported view_mode.
The current plugin’s handle. Equal to plugin.request.handle.
The id for the addon instance.
Displays the keyboard input window to the user. If the user does not cancel the modal, the value entered by the user will be returned.
Parameters: |
|
---|
Returns a list of existing stores. The returned names can then be used to call get_storage().
The log instance for the plugin. Returns an instance of the stdlib’s logging.Logger. This log will print to STDOUT when running in CLI mode and will forward messages to XBMC’s log when running in XBMC. Some examples:
plugin.log.debug('Debug message')
plugin.log.warning('Warning message')
plugin.log.error('Error message')
The addon’s name
Displays a temporary notification message to the user. If title is not provided, the plugin name will be used. To have a blank title, pass ‘’ for the title argument. The delay argument is in milliseconds.
Opens the settings dialog within XBMC
Used when you need to redirect to another view, and you only have the final plugin:// url.
Registers a module with a plugin. Requires a url_prefix that will then enable calls to url_for.
Parameters: |
|
---|
The current Request.
Raises an Exception if the request hasn’t been initialized yet via run().
A decorator to add a route to a view. name is used to differentiate when there are multiple routes for a given view.
The main entry point for a plugin.
Sets the content type for the plugin.
Takes a url or a listitem to be played. Used in conjunction with a playable list item with a path that calls back into your addon.
Parameters: |
|
---|
Calls XBMC’s Container.SetViewMode. Requires an integer view_mode_id
A full path to the storage folder for this plugin’s addon data.
Returns a valid XBMC plugin URL for the given endpoint name. endpoint can be the literal name of a function, or it can correspond to the name keyword arguments passed to the route decorator.
Raises AmbiguousUrlException if there is more than one possible view for the given endpoint name.
A wrapper for the xbmcgui.ListItem class. The class keeps track of any set properties that xbmcgui doesn’t expose getters for.
Adds context menu items. If replace_items is True all previous context menu items will be removed.
Adds stream details
Returns a tuple of list item properties: (path, the wrapped xbmcgui.ListItem, is_folder)
Returns the wrapped xbmcgui.ListItem
A ListItem constructor for setting a lot of properties not available in the regular __init__ method. Useful to collect all the properties in a dict and then use the **dct to call this method.
Returns the list of currently set context_menu items.
Returns the listitem’s icon image
Returns True if the listitem is playable, False if it is a directory
Sets the listitem’s label
Returns the listitem’s label2
Returns the listitem’s path
Returns True if the video was played.
Returns the property associated with the given key
Returns the listitem’s thumbnail image
Returns the listitem’s icon image
Returns True if the listitem is selected.
Sets the listitem’s label
Returns the listitem’s label2
Returns the listitem’s path
Returns True if the listitem is playable, False if it is a directory
Sets the listitems selected status to the provided value. Defaults to True.
Returns True if the listitem is selected.
Sets the listitem’s icon image
Sets the listitems info
Sets the listitem’s playable flag
Returns the listitem’s label
Sets the listitem’s label2
Sets the listitem’s path
Sets the played status of the listitem. Used to differentiate between a resolved video versus a playable item. Has no effect on XBMC, it is strictly used for xbmcswift2.
Sets a property for the given key and value
Sets the listitem’s thumbnail image
Returns the listitem’s thumbnail image
The request objects contains all the arguments passed to the plugin via the command line.
Parameters: |
|
---|
The current request’s handle, an integer.
The entire request url.
This module contains wrapper functions for XBMC built-in functions.
copyright: |
|
---|---|
license: | GPLv3, see LICENSE for more details. |
This action will run an addon in the background for the provided URL.
See ‘XBMC.RunPlugin()’ at http://wiki.xbmc.org/index.php?title=List_of_built-in_functions.
This action will update the current container view with provided url.
See ‘XBMC.Container.Update()’ at http://wiki.xbmc.org/index.php?title=List_of_built-in_functions.
Modules are basically mini plugins except they don’t have any functionality until they are registered with a Plugin.
Adds ListItems to the XBMC interface. Each item in the provided list should either be instances of xbmcswift2.ListItem, or regular dictionaries that will be passed to xbmcswift2.ListItem.from_dict. Returns the list of ListItems.
Parameters: | items – An iterable of items where each item is either a dictionary with keys/values suitable for passing to xbmcswift2.ListItem.from_dict() or an instance of xbmcswift2.ListItem. |
---|
A wrapper for xbmcplugin.addSortMethod(). You can use dir(xbmcswift2.SortMethod) to list all available sort methods.
Parameters: |
|
---|
Adds the provided list of items to the specified playlist. Available playlists include video and music.
This method adds a URL rule for routing purposes. The provided name can be different from the view function name if desired. The provided name is what is used in url_for to build a URL.
The route decorator provides the same functionality.
Returns this module’s added_items
Returns the module’s addon
Returns the module’s cache_path.
A decorator that will cache the output of the wrapped function. The key used for the cache is the function name as well as the *args and **kwargs passed to the function.
Parameters: | TTL – time to live in minutes |
---|
Note
For route caching, you should use xbmcswift2.Plugin.cached_route().
Clears the storage that caches results when using xbmcswift2.Plugin.cached_route() or xbmcswift2.Plugin.cached().
Wrapper for xbmcplugin.endOfDirectory. Records state in self._end_of_directory.
Typically it is not necessary to call this method directly, as calling finish() will call this method.
Adds the provided items to the XBMC interface.
Parameters: |
|
---|---|
Returns: | a list of all ListItems added to the XBMC interface. |
Returns the settings value for the provided key. If converter is str, unicode, bool or int the settings value will be returned converted to the provided type. If choices is an instance of list or tuple its item at position of the settings value be returned. .. note:: It is suggested to always use unicode for text-settings
because else xbmc returns utf-8 encoded strings.
Parameters: |
|
---|
Returns a storage for the given name. The returned storage is a fully functioning python dictionary and is designed to be used that way. It is usually not necessary for the caller to load or save the storage manually. If the storage does not already exist, it will be created.
See also
xbmcswift2.TimedStorage for more details.
Parameters: |
|
---|
Returns the localized string from strings.xml for the given stringid.
Attempts to return a view_mode_id for a given view_mode taking into account the current skin. If not view_mode_id can be found, None is returned. ‘thumbnail’ is currently the only suppported view_mode.
Returns this module’s handle
Displays the keyboard input window to the user. If the user does not cancel the modal, the value entered by the user will be returned.
Parameters: |
|
---|
Returns a list of existing stores. The returned names can then be used to call get_storage().
Returns the registered plugin’s log.
Displays a temporary notification message to the user. If title is not provided, the plugin name will be used. To have a blank title, pass ‘’ for the title argument. The delay argument is in milliseconds.
Opens the settings dialog within XBMC
Returns the plugin this module is registered to, or raises a RuntimeError if not registered.
Used when you need to redirect to another view, and you only have the final plugin:// url.
Returns the current request
A decorator to add a route to a view. name is used to differentiate when there are multiple routes for a given view.
Sets the content type for the plugin.
Takes a url or a listitem to be played. Used in conjunction with a playable list item with a path that calls back into your addon.
Parameters: |
|
---|
Calls XBMC’s Container.SetViewMode. Requires an integer view_mode_id
Returns a valid XBMC plugin URL for the given endpoint name. endpoint can be the literal name of a function, or it can correspond to the name keyword arguments passed to the route decorator.
Currently, view names must be unique across all plugins and modules. There are not namespace prefixes for modules.
Sets or gets the url prefix of the module.
Raises an Exception if this module is not registered with a Plugin.
A dict with the ability to persist to disk and TTL for items.
Calls sync
Handles the writing of the dict to the file object
Initially fills the underlying dictionary with keys, values and timestamps.
Load the dict from the file object
If key is not found, d is returned if given, otherwise KeyError is raised.
as a 2-tuple; but raise KeyError if D is empty.
Returns the wrapped dict
Write the dict to disk
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v