Python xbmcaddon.Addon() Examples
The following are 30 code examples for showing how to use xbmcaddon.Addon(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
xbmcaddon
, or try the search function
.
Example 1
Project: script.module.inputstreamhelper Author: emilsvennesson File: __init__.py License: MIT License | 6 votes |
def _install_inputstream(self): """Install inputstream addon.""" from xbmc import executebuiltin from xbmcaddon import Addon try: # See if there's an installed repo that has it executebuiltin('InstallAddon({})'.format(self.inputstream_addon), wait=True) # Check if InputStream add-on exists! Addon('{}'.format(self.inputstream_addon)) log(0, 'InputStream add-on installed from repo.') return True except RuntimeError: log(3, 'InputStream add-on not installed.') return False
Example 2
Project: plugin.video.emby Author: MediaBrowser File: utils.py License: GNU General Public License v3.0 | 6 votes |
def settings(setting, value=None): ''' Get or add add-on settings. getSetting returns unicode object. ''' addon = xbmcaddon.Addon(addon_id()) if value is not None: if setting.endswith('.bool'): setting = setting.replace('.bool', "") value = "true" if value else "false" addon.setSetting(setting, value) else: result = addon.getSetting(setting.replace('.bool', "")) if result and setting.endswith('.bool'): result = result in ("true", "1") return result
Example 3
Project: plugin.video.emby Author: MediaBrowser File: loginmanual.py License: GNU General Public License v3.0 | 6 votes |
def _add_editcontrol(self, x, y, height, width, password=0): media = os.path.join(xbmcaddon.Addon(addon_id()).getAddonInfo('path'), 'resources', 'skins', 'default', 'media') control = xbmcgui.ControlEdit(0, 0, 0, 0, label="User", font="font13", textColor="FF52b54b", disabledColor="FF888888", focusTexture="-", noFocusTexture="-", isPassword=password) control.setPosition(x, y) control.setHeight(height) control.setWidth(width) self.addControl(control) return control
Example 4
Project: plugin.video.emby Author: MediaBrowser File: loginconnect.py License: GNU General Public License v3.0 | 6 votes |
def _add_editcontrol(self, x, y, height, width, password=0): media = os.path.join(xbmcaddon.Addon(addon_id()).getAddonInfo('path'), 'resources', 'skins', 'default', 'media') control = xbmcgui.ControlEdit(0, 0, 0, 0, label="User", font="font13", textColor="FF52b54b", disabledColor="FF888888", focusTexture="-", noFocusTexture="-", isPassword=password) control.setPosition(x, y) control.setHeight(height) control.setWidth(width) self.addControl(control) return control
Example 5
Project: plugin.video.emby Author: MediaBrowser File: servermanual.py License: GNU General Public License v3.0 | 6 votes |
def _add_editcontrol(self, x, y, height, width): media = os.path.join(xbmcaddon.Addon(addon_id()).getAddonInfo('path'), 'resources', 'skins', 'default', 'media') control = xbmcgui.ControlEdit(0, 0, 0, 0, label="User", font="font13", textColor="FF52b54b", disabledColor="FF888888", focusTexture="-", noFocusTexture="-") control.setPosition(x, y) control.setHeight(height) control.setWidth(width) self.addControl(control) return control
Example 6
Project: plugin.video.emby Author: MediaBrowser File: context.py License: GNU General Public License v3.0 | 6 votes |
def action_menu(self): selected = self._selected_option.decode('utf-8') if selected == OPTIONS['Refresh']: self.server['api'].refresh_item(self.item['Id']) elif selected == OPTIONS['AddFav']: self.server['api'].favorite(self.item['Id'], True) elif selected == OPTIONS['RemoveFav']: self.server['api'].favorite(self.item['Id'], False) elif selected == OPTIONS['Addon']: xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)') elif selected == OPTIONS['Delete']: self.delete_item()
Example 7
Project: script.tvguide.fullscreen Author: primaeval File: ResetDatabase.py License: GNU General Public License v2.0 | 6 votes |
def deleteDB(): try: xbmc.log("[script.tvguide.fullscreen] Deleting database...", xbmc.LOGDEBUG) dbPath = xbmc.translatePath(xbmcaddon.Addon(id = 'script.tvguide.fullscreen').getAddonInfo('profile')) dbPath = os.path.join(dbPath, 'source.db') delete_file(dbPath) passed = not os.path.exists(dbPath) if passed: xbmc.log("[script.tvguide.fullscreen] Deleting database...PASSED", xbmc.LOGDEBUG) else: xbmc.log("[script.tvguide.fullscreen] Deleting database...FAILED", xbmc.LOGDEBUG) return passed except Exception, e: xbmc.log('[script.tvguide.fullscreen] Deleting database...EXCEPTION', xbmc.LOGDEBUG) return False
Example 8
Project: script.tvguide.fullscreen Author: primaeval File: vpnapi.py License: GNU General Public License v2.0 | 6 votes |
def __init__(self): # Class initialisation. Fails with a RuntimeError exception if VPN Manager add-on is not available, or too old self.filtered_addons = [] self.filtered_windows = [] self.primary_vpns = [] self.last_updated = 0 self.refreshLists() self.default = self.getConnected() xbmc.log("VPN Mgr API : Default is " + self.default, level=xbmc.LOGDEBUG) self.timeout = 30 if not xbmc.getCondVisibility("System.HasAddon(service.vpn.manager)"): xbmc.log("VPN Mgr API : VPN Manager is not installed, cannot use filtering", level=xbmc.LOGERROR) raise RuntimeError("VPN Manager is not installed") else: v = int((xbmcaddon.Addon("service.vpn.manager").getAddonInfo("version").strip()).replace(".","")) if v < 310: raise RuntimeError("VPN Manager " + str(v) + " installed, but needs to be v3.1.0 or later")
Example 9
Project: bugatsinho.github.io Author: bugatsinho File: control.py License: GNU General Public License v3.0 | 6 votes |
def openSettings(query=None, id=addonInfo('id')): idle() execute('Addon.OpenSettings({0})'.format(id)) if query is not None: try: c, f = query.split('.') if float(addon('xbmc.addon').getAddonInfo('version')[:4]) > 17.6: execute('SetFocus(-{0})'.format(100 - int(c))) if int(f): execute('SetFocus(-{0})'.format(80 - int(f))) else: execute('SetFocus({0})'.format(100 + int(c))) if int(f): execute('SetFocus({0})'.format(200 + int(f))) except Exception: pass # Alternative method
Example 10
Project: bugatsinho.github.io Author: bugatsinho File: control.py License: GNU General Public License v3.0 | 6 votes |
def openSettings(query=None, id=addonInfo('id')): try: idle() execute('Addon.OpenSettings({0})'.format(id)) if query is None: raise Exception() c, f = query.split('.') execute('SetFocus(%i)' % (int(c) + 100)) execute('SetFocus(%i)' % (int(f) + 200)) except: return # Alternative method
Example 11
Project: bugatsinho.github.io Author: bugatsinho File: control.py License: GNU General Public License v3.0 | 6 votes |
def openSettings(query=None, id=addonInfo('id')): try: idle() execute('Addon.OpenSettings({0})'.format(id)) if query is None: raise Exception() c, f = query.split('.') execute('SetFocus(%i)' % (int(c) + 100)) execute('SetFocus(%i)' % (int(f) + 200)) except: return # Alternative method
Example 12
Project: bugatsinho.github.io Author: bugatsinho File: cache.py License: GNU General Public License v3.0 | 6 votes |
def clear(table=None): try: execute('Dialog.Close(busydialog)') if table == None: table = ['rel_list', 'rel_lib'] elif not type(table) == list: table = [table] yes = dialog.yesno(heading=xbmcaddon.Addon().getAddonInfo('name'), line1=xbmcaddon.Addon().getLocalizedString(30401).encode('utf-8')) if not yes: return dbcon = database.connect(os.path.join(dataPath, 'cache.db')) dbcur = dbcon.cursor() for t in table: try: dbcur.execute("DROP TABLE IF EXISTS %s" % t) dbcur.execute("VACUUM") dbcon.commit() except: pass dialog.notification(heading=xbmcaddon.Addon().getAddonInfo('name'), message=xbmcaddon.Addon().getLocalizedString(30402).encode('utf-8'), time=2000, sound=False) except: pass
Example 13
Project: bugatsinho.github.io Author: bugatsinho File: control.py License: GNU General Public License v3.0 | 6 votes |
def openSettings(query=None, id=addonInfo('id')): try: idle() execute('Addon.OpenSettings({0})'.format(id)) if query is None: raise Exception() c, f = query.split('.') execute('SetFocus(%i)' % (int(c) + 100)) execute('SetFocus(%i)' % (int(f) + 200)) except: return # Alternative method
Example 14
Project: bugatsinho.github.io Author: bugatsinho File: cache.py License: GNU General Public License v3.0 | 6 votes |
def clear(table=None): try: execute('Dialog.Close(busydialog)') if table == None: table = ['rel_list', 'rel_lib'] elif not type(table) == list: table = [table] yes = dialog.yesno(heading=xbmcaddon.Addon().getAddonInfo('name'), line1=xbmcaddon.Addon().getLocalizedString(30401).encode('utf-8')) if not yes: return dbcon = database.connect(os.path.join(dataPath, 'cache.db')) dbcur = dbcon.cursor() for t in table: try: dbcur.execute("DROP TABLE IF EXISTS %s" % t) dbcur.execute("VACUUM") dbcon.commit() except: pass dialog.notification(heading=xbmcaddon.Addon().getAddonInfo('name'), message=xbmcaddon.Addon().getLocalizedString(30402).encode('utf-8'), time=2000, sound=False) except: pass
Example 15
Project: bugatsinho.github.io Author: bugatsinho File: control.py License: GNU General Public License v3.0 | 6 votes |
def openSettings(query=None, id=addonInfo('id')): idle() execute('Addon.OpenSettings({0})'.format(id)) if query is not None: try: c, f = query.split('.') if float(addon('xbmc.addon').getAddonInfo('version')[:4]) > 17.6: execute('SetFocus(-{0})'.format(100 - int(c))) if int(f): execute('SetFocus(-{0})'.format(80 - int(f))) else: execute('SetFocus({0})'.format(100 + int(c))) if int(f): execute('SetFocus({0})'.format(200 + int(f))) except Exception: pass # Alternative method
Example 16
Project: bugatsinho.github.io Author: bugatsinho File: control.py License: GNU General Public License v3.0 | 6 votes |
def openSettings(query=None, id=addonInfo('id')): try: idle() execute('Addon.OpenSettings({0})'.format(id)) if query is None: raise Exception() c, f = query.split('.') execute('SetFocus(%i)' % (int(c) + 100)) execute('SetFocus(%i)' % (int(f) + 200)) except BaseException: return # Alternative method
Example 17
Project: plugin.video.netflix Author: CastagnaIT File: config_wizard.py License: MIT License | 6 votes |
def _set_isa_addon_settings(is_4k_capable, hdcp_override): """Method for self-configuring of InputStream Adaptive add-on""" try: is_helper = inputstreamhelper.Helper('mpd') if not is_helper.check_inputstream(): show_ok_dialog(get_local_string(30154), get_local_string(30046)) return except Exception as exc: # pylint: disable=broad-except # Captures all types of ISH internal errors import traceback error(g.py2_decode(traceback.format_exc(), 'latin-1')) raise InputStreamHelperError(str(exc)) isa_addon = Addon('inputstream.adaptive') isa_addon.setSettingBool('HDCPOVERRIDE', hdcp_override) if isa_addon.getSettingInt('STREAMSELECTION') == 1: # Stream selection must never be set to 'Manual' or cause problems with the streams isa_addon.setSettingInt('STREAMSELECTION', 0) # 'Ignore display' should only be set when Kodi display resolution is not 4K isa_addon.setSettingBool('IGNOREDISPLAY', is_4k_capable and (getScreenWidth() != 3840 or getScreenHeight() != 2160))
Example 18
Project: service.vpn.manager Author: Zomboided File: vpnplatform.py License: GNU General Public License v2.0 | 6 votes |
def copySystemdFiles(): # Delete any existing openvpn.service and copy openvpn service file to config directory service_source = getAddonPath(True, "openvpn.service") service_dest = getSystemdPath("system.d/openvpn.service") debugTrace("Copying openvpn.service " + service_source + " to " + service_dest) if not fakeSystemd(): if xbmcvfs.exists(service_dest): xbmcvfs.delete(service_dest) xbmcvfs.copy(service_source, service_dest) if not xbmcvfs.exists(service_dest): raise IOError('Failed to copy service ' + service_source + " to " + service_dest) # Delete any existing openvpn.config and copy first VPN to openvpn.config config_source = sudo_setting = xbmcaddon.Addon(getID()).getSetting("1_vpn_validated") if service_source == "": errorTrace("vpnplatform.py", "Nothing has been validated") config_dest = getSystemdPath("openvpn.config") debugTrace("Copying openvpn.config " + config_source + " to " + config_dest) if not fakeSystemd(): if xbmcvfs.exists(config_dest): xbmcvfs.delete(config_dest) xbmcvfs.copy(config_source, config_dest) if not xbmcvfs.exists(config_dest): raise IOError('Failed to copy service ovpn ' + config_source + " to " + config_dest)
Example 19
Project: service.vpn.manager Author: Zomboided File: vpnplatform.py License: GNU General Public License v2.0 | 6 votes |
def checkVPNInstall(addon): # Check that openvpn plugin exists (this was an issue with OE6), there's # another check below that validates that the command actually works if not fakeConnection(): p = getPlatform() dialog_msg = "" if p == platforms.RPI: command_path = getAddonPath(False, "network.openvpn/bin/openvpn") if xbmcvfs.exists(command_path): # Check the version that's installed vpn_addon = xbmcaddon.Addon("network.openvpn") version = vpn_addon.getAddonInfo("version") version = version.replace(".", "") if int(version) >= 600: return True dialog_msg = "OpenVPN executable not available. Install the openvpn plugin, version 6.0.1 or greater from the OpenELEC unofficial repo." # Display error message xbmcgui.Dialog().ok(addon.getAddonInfo("name"), dialog_msg) return True
Example 20
Project: service.vpn.manager Author: Zomboided File: alternativeShellfire.py License: GNU General Public License v2.0 | 6 votes |
def checkForShellfireUpdates(vpn_provider): # See if the current stored tokens have changed addon = xbmcaddon.Addon(getID()) current = addon.getSetting("vpn_locations_list") # If nothing has been selected/validated, then it doesn't matter if there's updates or not if current == "": return False # Likewise, if nothing is connected, then it doesn't matter yet if addon.getSetting("1_vpn_validated") == "": return False debugTrace("Checking for updates for " + current) # Get the list of services and see if the current ID is still the same services = getServices() if services == None: return False for s in services: # Look for the current service/id. If it's found nothing has been updated if s == current: return False # If we didn't find the service/id, then it's changed, so there are updates return True
Example 21
Project: service.vpn.manager Author: Zomboided File: sysbox.py License: GNU General Public License v2.0 | 6 votes |
def popupSysBox(): if not getID() == "": addon = xbmcaddon.Addon(getID()) dialog_text_l = "" dialog_text_r = "" data_left = getSystemData(addon, True, True, False, False) data_right = getSystemData(addon, False, False, False, True) for line in data_left: if line.startswith("[B]") and not dialog_text_l == "": dialog_text_l = dialog_text_l + "\n" dialog_text_l = dialog_text_l + line + "\n" for line in data_right: if line.startswith("[B]") and not dialog_text_r == "": dialog_text_r = dialog_text_r + "\n" dialog_text_r = dialog_text_r + line + "\n" showInfoBox("System Information", dialog_text_l, dialog_text_r) else: errorTrace("sysbox.py", "VPN service is not ready")
Example 22
Project: service.vpn.manager Author: Zomboided File: ipinfo.py License: GNU General Public License v2.0 | 6 votes |
def getAutoSource(): # If the VPN has changed, then reset all the numbers addon = xbmcaddon.Addon(getID()) last_vpn = addon.getSetting("ip_service_last_vpn") current_vpn = addon.getSetting("vpn_provider_validated") if (not last_vpn == current_vpn): addon.setSetting("ip_service_last_vpn", current_vpn) resetIPServices() # Get the last source we tried to use from the home window or use the first if this is first time through source = xbmcgui.Window(10000).getProperty("VPN_Manager_Last_IP_Service") if source == "": # Record that we're using the first one xbmcgui.Window(10000).setProperty("VPN_Manager_Last_IP_Service", ip_sources[1]) return ip_sources[1] else: index = ip_sources.index(source) if index > 1: if getWorkingValue(index) >= getErrorValue(index - 1): setWorkingValue(index, 0) index = index - 1 return ip_sources[index]
Example 23
Project: script.module.inputstreamhelper Author: emilsvennesson File: __init__.py License: MIT License | 5 votes |
def _inputstream_version(self): """Return the requested inputstream version""" from xbmcaddon import Addon try: addon = Addon(self.inputstream_addon) except RuntimeError: return None from .unicodes import to_unicode return to_unicode(addon.getAddonInfo('version'))
Example 24
Project: script.module.inputstreamhelper Author: emilsvennesson File: widevine.py License: MIT License | 5 votes |
def ia_cdm_path(): """Return the specified CDM path for inputstream.adaptive, usually ~/.kodi/cdm""" from xbmcaddon import Addon try: addon = Addon('inputstream.adaptive') except RuntimeError: return None cdm_path = translate_path(os.path.join(to_unicode(addon.getSetting('DECRYPTERPATH')), '')) if not exists(cdm_path): mkdirs(cdm_path) return cdm_path
Example 25
Project: plugin.video.emby Author: MediaBrowser File: translate.py License: GNU General Public License v3.0 | 5 votes |
def _(string): ''' Get add-on string. Returns in unicode. ''' if type(string) != int: string = STRINGS[string] result = xbmcaddon.Addon('plugin.video.emby').getLocalizedString(string) if not result: result = xbmc.getLocalizedString(string) return result
Example 26
Project: plugin.video.emby Author: MediaBrowser File: client.py License: GNU General Public License v3.0 | 5 votes |
def get_addon_name(): ''' Used for logging. ''' return xbmcaddon.Addon(addon_id()).getAddonInfo('name').upper()
Example 27
Project: plugin.video.emby Author: MediaBrowser File: client.py License: GNU General Public License v3.0 | 5 votes |
def get_version(): return xbmcaddon.Addon(addon_id()).getAddonInfo('version')
Example 28
Project: plugin.video.emby Author: MediaBrowser File: context.py License: GNU General Public License v3.0 | 5 votes |
def select_menu(self): ''' Display the select dialog. Favorites, Refresh, Delete (opt), Settings. ''' options = [] if self.item['Type'] not in ('Season'): if self.item['UserData'].get('IsFavorite'): options.append(OPTIONS['RemoveFav']) else: options.append(OPTIONS['AddFav']) options.append(OPTIONS['Refresh']) if settings('enableContextDelete.bool'): options.append(OPTIONS['Delete']) options.append(OPTIONS['Addon']) context_menu = context.ContextMenu("script-emby-context.xml", *XML_PATH) context_menu.set_options(options) context_menu.doModal() if context_menu.is_selected(): self._selected_option = context_menu.get_selected() return self._selected_option
Example 29
Project: script.tvguide.fullscreen Author: primaeval File: vpnapi.py License: GNU General Public License v2.0 | 5 votes |
def isVPNSetUp(self): # Indicates if the VPN has been set up. Can be called directly, but is used by # all calls that mess with the connection to ensure the VPN is running. addon = xbmcaddon.Addon("service.vpn.manager") if not addon.getSetting("1_vpn_validated") == "": return True return False
Example 30
Project: script.tvguide.fullscreen Author: primaeval File: vpnapi.py License: GNU General Public License v2.0 | 5 votes |
def refreshLists(self): # This function will refresh the list of filters and VPNs being used. It doesn't need to be called # directly as it will be called before an add-on/window is checked if the data has changed try: changed = int(xbmcgui.Window(10000).getProperty("VPN_Manager_Lists_Last_Refreshed")) except: # If there's no refreshed time stamp, force a refresh with whatever data is available changed = self.last_updated if self.last_updated > changed: return # Get a handle to the VPN Mgr add-on to read the settings data addon = xbmcaddon.Addon("service.vpn.manager") del self.filtered_addons[:] del self.filtered_windows[:] del self.primary_vpns[:] # Adjust 11 below if changing number of conn_max for i in range (0, 11): # Load up the list of primary VPNs if i>0: self.primary_vpns.append(addon.getSetting(str(i)+"_vpn_validated")) # Load up the addon filter list addon_string = "" if i == 0 : addon_string = addon.getSetting("vpn_excluded_addons") else : addon_string = addon.getSetting(str(i)+"_vpn_addons") if not addon_string == "" : self.filtered_addons.append(addon_string.split(",")) else : self.filtered_addons.append(None) # Load up the window filter list window_string = "" if i == 0 : window_string = addon.getSetting("vpn_excluded_windows") else : window_string = addon.getSetting(str(i)+"_vpn_windows") if not window_string == "" : self.filtered_windows.append(window_string.split(",")) else : self.filtered_windows.append(None) # Store the time the filters were last updated self.last_updated = int(time.time())