Python xbmcaddon.Addon() Examples

The following are 30 code examples of xbmcaddon.Addon(). 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 also want to check out all available functions/classes of the module xbmcaddon , or try the search function .
Example #1
Source File: vpnplatform.py    From service.vpn.manager with GNU General Public License v2.0 6 votes vote down vote up
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 #2
Source File: servermanual.py    From plugin.video.emby with GNU General Public License v3.0 6 votes vote down vote up
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 #3
Source File: context.py    From plugin.video.emby with GNU General Public License v3.0 6 votes vote down vote up
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 #4
Source File: ResetDatabase.py    From script.tvguide.fullscreen with GNU General Public License v2.0 6 votes vote down vote up
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 #5
Source File: loginconnect.py    From plugin.video.emby with GNU General Public License v3.0 6 votes vote down vote up
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 #6
Source File: loginmanual.py    From plugin.video.emby with GNU General Public License v3.0 6 votes vote down vote up
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 #7
Source File: config_wizard.py    From plugin.video.netflix with MIT License 6 votes vote down vote up
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 #8
Source File: utils.py    From plugin.video.emby with GNU General Public License v3.0 6 votes vote down vote up
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 #9
Source File: __init__.py    From script.module.inputstreamhelper with MIT License 6 votes vote down vote up
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 #10
Source File: ipinfo.py    From service.vpn.manager with GNU General Public License v2.0 6 votes vote down vote up
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 #11
Source File: vpnapi.py    From script.tvguide.fullscreen with GNU General Public License v2.0 6 votes vote down vote up
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 #12
Source File: control.py    From bugatsinho.github.io with GNU General Public License v3.0 6 votes vote down vote up
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 #13
Source File: vpnplatform.py    From service.vpn.manager with GNU General Public License v2.0 6 votes vote down vote up
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 #14
Source File: cache.py    From bugatsinho.github.io with GNU General Public License v3.0 6 votes vote down vote up
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
Source File: control.py    From bugatsinho.github.io with GNU General Public License v3.0 6 votes vote down vote up
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 #16
Source File: cache.py    From bugatsinho.github.io with GNU General Public License v3.0 6 votes vote down vote up
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 #17
Source File: control.py    From bugatsinho.github.io with GNU General Public License v3.0 6 votes vote down vote up
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 #18
Source File: alternativeShellfire.py    From service.vpn.manager with GNU General Public License v2.0 6 votes vote down vote up
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 #19
Source File: control.py    From bugatsinho.github.io with GNU General Public License v3.0 6 votes vote down vote up
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 #20
Source File: control.py    From bugatsinho.github.io with GNU General Public License v3.0 6 votes vote down vote up
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 #21
Source File: control.py    From bugatsinho.github.io with GNU General Public License v3.0 6 votes vote down vote up
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 #22
Source File: sysbox.py    From service.vpn.manager with GNU General Public License v2.0 6 votes vote down vote up
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 #23
Source File: vpnplatform.py    From service.vpn.manager with GNU General Public License v2.0 5 votes vote down vote up
def getPidofPath():
    # return the path to pidof
    p = getPlatform()   
    if p == platforms.LINUX or platforms.RPI:
        return xbmcaddon.Addon(getID()).getSetting("pidof_path") + "pidof"
    return 
Example #24
Source File: alternativeNord.py    From service.vpn.manager with GNU General Public License v2.0 5 votes vote down vote up
def getTokenNordVPN():
    # Return a token that can be used on API calls
    token, renew, expiry, _ = getTokens()
    
    # If the expiry time is passed, renew the token
    if expiry.isdigit() and int(expiry) < now():
        if renewNordVPN(renew):
            token, _, _, _ = getTokens()
            return token
        else:
            # Force an authenticate to happen
            token = ""

    # The authentication call is made during connection validation, which will validate everything and fetch
    # the tokens.  If a reboot happens and the tokens disappear, then we need to force an authenticate again
    if token == "":
        addon = xbmcaddon.Addon(getID())
        if authenticateNordVPN(addon.getSetting("vpn_provider_validated"), addon.getSetting("vpn_username_validated"), addon.getSetting("vpn_password_validated")):
            token, _, _, _ = getTokens()
            return token
        else:
            errorTrace("alternativeNord.py", "Couldn't authenticate or renew the user ID")
            resetTokens()
            raise RuntimeError("Couldn't get a user ID token")
    
    debugTrace("Using existing user ID token")    
    return token 
Example #25
Source File: control.py    From plugin.video.sparkle with GNU General Public License v3.0 5 votes vote down vote up
def openSettings(query=None, id=addonInfo('id')):
    try:
        idle()
        execute('Addon.OpenSettings(%s)' % id)
        if query == None: raise Exception()
        c, f = query.split('.')
        execute('SetFocus(%i)' % (int(c) + 100))
        execute('SetFocus(%i)' % (int(f) + 200))
    except:
        return 
Example #26
Source File: control.py    From plugin.video.sparkle with GNU General Public License v3.0 5 votes vote down vote up
def metaFile():
    if condVisibility('System.HasAddon(script.incursion.metadata)'):
        return os.path.join(xbmcaddon.Addon('script.incursion.metadata').getAddonInfo('path'), 'resources', 'data', 'meta.db') 
Example #27
Source File: mapkey.py    From service.vpn.manager with GNU General Public License v2.0 5 votes vote down vote up
def __new__(cls):
        gui_api = tuple(map(int, xbmcaddon.Addon('xbmc.gui').getAddonInfo('version').split('.')))
        file_name = "DialogNotification.xml" if gui_api >= (5, 11, 0) else "DialogKaiToast.xml"
        return super(KeyListener, cls).__new__(cls, file_name, "") 
Example #28
Source File: vpnplatform.py    From service.vpn.manager with GNU General Public License v2.0 5 votes vote down vote up
def getTestFilePath():
    # Return the full filename for the VPN log file
    # It's platform dependent, but can be forced to the Kodi log location
    use_kodi_dir = xbmcaddon.Addon(getID()).getSetting("openvpn_log_location")
    p = getPlatform()
    if p == platforms.WINDOWS or use_kodi_dir == "true" :
        # Putting this with the other logs on Windows
        return xbmc.translatePath("special://logpath/command_test.txt")
    if p == platforms.LINUX or p == platforms.RPI:
        # This should be a RAM drive so doesn't wear the media
        return "/run/command_text.txt"
        
    # **** ADD MORE PLATFORMS HERE ****
    
    return "" 
Example #29
Source File: vpnplatform.py    From service.vpn.manager with GNU General Public License v2.0 5 votes vote down vote up
def useBigHammer():
    hammer = xbmcaddon.Addon(getID()).getSetting("openvpn_killall")
    if hammer == "true": 
        return True
    else:
        return False 
Example #30
Source File: vpnplatform.py    From service.vpn.manager with GNU General Public License v2.0 5 votes vote down vote up
def useSudo():
    sudo_setting = xbmcaddon.Addon(getID()).getSetting("openvpn_sudo")
    if sudo_setting == "Always": return True
    if sudo_setting == "Never": return False
    if getPlatform() == platforms.LINUX:
        # For non-LE/OE Linux (based on the path name...) we don't need to use sudo
        if not getAddonPath(True, "").startswith("/storage/.kodi/"): return True
    return False