xbmcaddon¶
Kodi’s addon class.
Classes
|
Kodi's addon class. |
|
Add-on settings |
- class xbmcaddon.Addon(id: str | None = None)[source]¶
Bases:
object
Kodi’s addon class.
Offers classes and functions that manipulate the add-on settings, information and localization.
Creates a new AddOn class.
- Parameters:
id – [opt] string - id of the addon as specified inaddon.xml
Note
Specifying the addon id is not needed. Important however is that the addon folder has the same name as the AddOn id provided inaddon.xml. You can optionally specify the addon id from another installed addon to retrieve settings from it.
@python_v13 id is optional as it will be auto detected for this add-on instance.
Example:
.. self.Addon = xbmcaddon.Addon() self.Addon = xbmcaddon.Addon('script.foo.bar') ..
- getLocalizedString(id: int) str [source]¶
Returns an addon’s localized ‘string’.
- Parameters:
id – integer - id# for string you want to localize.
- Returns:
Localized ‘string’
@python_v13 id is optional as it will be auto detected for this add-on instance.
Example:
.. locstr = self.Addon.`getLocalizedString`(32000) ..
- getSettings() Settings [source]¶
Returns a wrapper around the addon’s settings.
- Returns:
Settings wrapper
@python_v20 New function added.
Example:
.. settings = self.Addon.getSettings() ..
- getSetting(id: str) str [source]¶
Returns the value of a setting as string.
- Parameters:
id – string - id of the setting that the module needs to access.
- Returns:
Setting as a string
@python_v13 id is optional as it will be auto detected for this add-on instance.
Example:
.. apikey = self.Addon.getSetting('apikey') ..
- getSettingBool(id: str) bool [source]¶
Returns the value of a setting as a boolean.
- Parameters:
id – string - id of the setting that the module needs to access.
- Returns:
Setting as a boolean
@python_v18 New function added.
@python_v20 Deprecated. Use `Settings.getBool()` instead.
Example:
.. enabled = self.Addon.getSettingBool('enabled') ..
- getSettingInt(id: str) int [source]¶
Returns the value of a setting as an integer.
- Parameters:
id – string - id of the setting that the module needs to access.
- Returns:
Setting as an integer
@python_v18 New function added.
@python_v20 Deprecated. Use `Settings.getInt()` instead.
Example:
.. max = self.Addon.getSettingInt('max') ..
- getSettingNumber(id: str) float [source]¶
Returns the value of a setting as a floating point number.
- Parameters:
id – string - id of the setting that the module needs to access.
- Returns:
Setting as a floating point number
@python_v18 New function added.
@python_v20 Deprecated. Use `Settings.getNumber()` instead.
Example:
.. max = self.Addon.getSettingNumber('max') ..
- getSettingString(id: str) str [source]¶
Returns the value of a setting as a string.
- Parameters:
id – string - id of the setting that the module needs to access.
- Returns:
Setting as a string
@python_v18 New function added.
@python_v20 Deprecated. Use `Settings.getString()` instead.
Example:
.. apikey = self.Addon.getSettingString('apikey') ..
- setSetting(id: str, value: str) None [source]¶
Sets a script setting.
- Parameters:
id – string - id of the setting that the module needs to access.
value – string - value of the setting.
Note
You can use the above as keywords for arguments.
@python_v13 id is optional as it will be auto detected for this add-on instance.
Example:
.. self.Addon.`setSetting`(id='username', value='teamkodi') ..
- setSettingBool(id: str, value: bool) bool [source]¶
Sets a script setting.
- Parameters:
id – string - id of the setting that the module needs to access.
value – boolean - value of the setting.
- Returns:
True if the value of the setting was set, false otherwise
Note
You can use the above as keywords for arguments.
@python_v18 New function added.
@python_v20 Deprecated. Use `Settings.setBool()` instead.
Example:
.. self.Addon.setSettingBool(id='enabled', value=True) ..
- setSettingInt(id: str, value: int) bool [source]¶
Sets a script setting.
- Parameters:
id – string - id of the setting that the module needs to access.
value – integer - value of the setting.
- Returns:
True if the value of the setting was set, false otherwise
Note
You can use the above as keywords for arguments.
@python_v18 New function added.
@python_v20 Deprecated. Use `Settings.setInt()` instead.
Example:
.. self.Addon.setSettingInt(id='max', value=5) ..
- setSettingNumber(id: str, value: float) bool [source]¶
Sets a script setting.
- Parameters:
id – string - id of the setting that the module needs to access.
value – float - value of the setting.
- Returns:
True if the value of the setting was set, false otherwise
Note
You can use the above as keywords for arguments.
@python_v18 New function added.
@python_v20 Deprecated. Use `Settings.setNumber()` instead.
Example:
.. self.Addon.setSettingNumber(id='max', value=5.5) ..
- setSettingString(id: str, value: str) bool [source]¶
Sets a script setting.
- Parameters:
id – string - id of the setting that the module needs to access.
value – string or unicode - value of the setting.
- Returns:
True if the value of the setting was set, false otherwise
Note
You can use the above as keywords for arguments.
@python_v18 New function added.
@python_v20 Deprecated. Use `Settings.setString()` instead.
Example:
.. self.Addon.setSettingString(id='username', value='teamkodi') ..
- openSettings() None [source]¶
Opens this scripts settings dialog.
Example:
.. self.Addon.openSettings() ..
- getAddonInfo(id: str) str [source]¶
Returns the value of an addon property as a string.
- Parameters:
id – string - id of the property that the module needs to access.
Choices for the property are
author
changelog
description
disclaimer
fanart
icon
id
name
path
profile
stars
summary
type
version
- Returns:
AddOn property as a string
Example:
.. version = self.Addon.getAddonInfo('version') ..
- class xbmcaddon.Settings[source]¶
Bases:
object
Add-on settings
This wrapper provides access to the settings specific to an add-on. It supports reading and writing specific setting values.
@python_v20 New class added.
Example:
... settings = xbmcaddon.Addon('id').getSettings() ...
- getBool(id: str) bool [source]¶
Returns the value of a setting as a boolean.
- Parameters:
id – string - id of the setting that the module needs to access.
- Returns:
bool - Setting as a boolean
@python_v20 New function added.
Example:
.. enabled = settings.getBool('enabled') ..
- getInt(id: str) int [source]¶
Returns the value of a setting as an integer.
- Parameters:
id – string - id of the setting that the module needs to access.
- Returns:
integer - Setting as an integer
@python_v20 New function added.
Example:
.. max = settings.getInt('max') ..
- getNumber(id: str) float [source]¶
Returns the value of a setting as a floating point number.
- Parameters:
id – string - id of the setting that the module needs to access.
- Returns:
float - Setting as a floating point number
@python_v20 New function added.
Example:
.. max = settings.getNumber('max') ..
- getString(id: str) str [source]¶
Returns the value of a setting as a unicode string.
- Parameters:
id – string - id of the setting that the module needs to access.
- Returns:
string - Setting as a unicode string
@python_v20 New function added.
Example:
.. apikey = settings.getString('apikey') ..
- getBoolList(id: str) List[bool] [source]¶
Returns the value of a setting as a list of booleans.
- Parameters:
id – string - id of the setting that the module needs to access.
- Returns:
list - Setting as a list of booleans
@python_v20 New function added.
Example:
.. enabled = settings.getBoolList('enabled') ..
- getIntList(id: str) List[int] [source]¶
Returns the value of a setting as a list of integers.
- Parameters:
id – string - id of the setting that the module needs to access.
- Returns:
list - Setting as a list of integers
@python_v20 New function added.
Example:
.. ids = settings.getIntList('ids') ..
- getNumberList(id: str) List[float] [source]¶
Returns the value of a setting as a list of floating point numbers.
- Parameters:
id – string - id of the setting that the module needs to access.
- Returns:
list - Setting as a list of floating point numbers
@python_v20 New function added.
Example:
.. max = settings.getNumberList('max') ..
- getStringList(id: str) List[str] [source]¶
Returns the value of a setting as a list of unicode strings.
- Parameters:
id – string - id of the setting that the module needs to access.
- Returns:
list - Setting as a list of unicode strings
@python_v20 New function added.
Example:
.. views = settings.getStringList('views') ..
- setBool(id: str, value: bool) None [source]¶
Sets the value of a setting.
- Parameters:
id – string - id of the setting that the module needs to access.
value – bool - value of the setting.
- Returns:
bool - True if the value of the setting was set, false otherwise
Note
You can use the above as keywords for arguments.
@python_v20 New function added.
Example:
.. settings.setBool(id='enabled', value=True) ..
- setInt(id: str, value: int) None [source]¶
Sets the value of a setting.
- Parameters:
id – string - id of the setting that the module needs to access.
value – integer - value of the setting.
- Returns:
bool - True if the value of the setting was set, false otherwise
Note
You can use the above as keywords for arguments.
@python_v20 New function added.
Example:
.. settings.setInt(id='max', value=5) ..
- setNumber(id: str, value: float) None [source]¶
Sets the value of a setting.
- Parameters:
id – string - id of the setting that the module needs to access.
value – float - value of the setting.
- Returns:
bool - True if the value of the setting was set, false otherwise
Note
You can use the above as keywords for arguments.
@python_v20 New function added.
Example:
.. settings.setNumber(id='max', value=5.5) ..
- setString(id: str, value: str) None [source]¶
Sets the value of a setting.
- Parameters:
id – string - id of the setting that the module needs to access.
value – string or unicode - value of the setting.
- Returns:
bool - True if the value of the setting was set, false otherwise
Note
You can use the above as keywords for arguments.
@python_v20 New function added.
Example:
.. settings.setString(id='username', value='teamkodi') ..
- setBoolList(id: str, values: List[bool]) None [source]¶
Sets the boolean values of a list setting.
- Parameters:
id – string - id of the setting that the module needs to access.
values – list of boolean - values of the setting.
- Returns:
bool - True if the values of the setting were set, false otherwise
Note
You can use the above as keywords for arguments.
@python_v20 New function added.
Example:
.. settings.setBoolList(id='enabled', values=[ True, False ]) ..
- setIntList(id: str, values: List[int]) None [source]¶
Sets the integer values of a list setting.
- Parameters:
id – string - id of the setting that the module needs to access.
values – list of int - values of the setting.
- Returns:
bool - True if the values of the setting were set, false otherwise
Note
You can use the above as keywords for arguments.
@python_v20 New function added.
Example:
.. settings.setIntList(id='max', values=[ 5, 23 ]) ..
- setNumberList(id: str, values: List[float]) None [source]¶
Sets the floating point values of a list setting.
- Parameters:
id – string - id of the setting that the module needs to access.
values – list of float - values of the setting.
- Returns:
bool - True if the values of the setting were set, false otherwise
Note
You can use the above as keywords for arguments.
@python_v20 New function added.
Example:
.. settings.setNumberList(id='max', values=[ 5.5, 5.8 ]) ..
- setStringList(id: str, values: List[str]) None [source]¶
Sets the string values of a list setting.
- Parameters:
id – string - id of the setting that the module needs to access.
values – list of string or unicode - values of the setting.
- Returns:
bool - True if the values of the setting were set, false otherwise
Note
You can use the above as keywords for arguments.
@python_v20 New function added.
Example:
.. settings.setStringList(id='username', values=[ 'team', 'kodi' ]) ..