Ejemplo n.º 1
0
    def install_dependency(self, plugin):
        from resources.libs import db

        dep = os.path.join(CONFIG.ADDONS, plugin, 'addon.xml')
        if os.path.exists(dep):
            match = tools.parse_dom(tools.read_from_file(dep), 'import', ret='addon')
            for depends in match:
                if 'xbmc.python' not in depends:
                    self.progress_dialog.update(0, '\n'+'[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, depends))

                    try:
                        add = tools.get_addon_by_id(id=depends)
                        name2 = tools.get_addon_info(add, 'name')
                    except:
                        db.create_temp(depends)
                        db.addon_database(depends, 1)
Ejemplo n.º 2
0
def enable_addons(all=False):
    from resources.libs.common import tools
    
    from xml.etree import ElementTree

    fold = glob.glob(os.path.join(CONFIG.ADDONS, '*/'))
    addonnames = []
    addonids = []
    for folder in sorted(fold, key=lambda x: x):
        foldername = os.path.split(folder[:-1])[1]
        if foldername in CONFIG.EXCLUDES:
            continue
        elif foldername in CONFIG.DEFAULTPLUGINS:
            continue
        elif foldername == 'packages':
            continue
        xml = os.path.join(folder, 'addon.xml')
        if os.path.exists(xml):
            root = ElementTree.parse(xml).getroot()
            addonid = root.get('id')
            addonname = root.get('name')
            addonids.append(addonid)
            addonnames.append(addonname)
    if not all:
        if len(addonids) == 0:
            directory.add_file("No Addons Found to Enable or Disable.", icon=CONFIG.ICONMAINT)
        else:
            directory.add_file("[I][B][COLOR red]!!Notice: Disabling Some Addons Can Cause Issues!![/COLOR][/B][/I]", icon=CONFIG.ICONMAINT)
            directory.add_dir('Enable All Addons', {'mode': 'enableall'}, icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME3)
            for i in range(0, len(addonids)):
                folder = os.path.join(CONFIG.ADDONS, addonids[i])
                icon = os.path.join(folder, 'icon.png') if os.path.exists(os.path.join(folder, 'icon.png')) else CONFIG.ADDON_ICON
                fanart = os.path.join(folder, 'fanart.jpg') if os.path.exists(os.path.join(folder, 'fanart.jpg')) else CONFIG.ADDON_FANART
                if tools.get_addon_info(addonids[i], 'name'):
                    state = "[COLOR springgreen][Enabled][/COLOR]"
                    goto = "false"
                else:
                    state = "[COLOR red][Disabled][/COLOR]"
                    goto = "true"

                directory.add_file("{0} {1}".format(state, addonnames[i]), {'mode': 'toggleaddon', 'name': addonids[i], 'url': goto}, icon=icon, fanart=fanart)
    else:
        from resources.libs import db
        for addonid in addonids:
            db.toggle_addon(addonid, 'true')
        xbmc.executebuiltin('Container.Refresh()')
Ejemplo n.º 3
0
def enable_addons():
    from resources.libs.common import tools
    
    from xml.etree import ElementTree

    directory.add_file("[I][B][COLOR red]!!Notice: Disabling Some Addons Can Cause Issues!![/COLOR][/B][/I]", icon=CONFIG.ICONMAINT)
    fold = glob.glob(os.path.join(CONFIG.ADDONS, '*/'))
    addonnames = []
    addonids = []
    for folder in sorted(fold, key=lambda x: x):
        foldername = os.path.split(folder[:-1])[1]
        if foldername in CONFIG.EXCLUDES:
            continue
        elif foldername in CONFIG.DEFAULTPLUGINS:
            continue
        elif foldername == 'packages':
            continue
        xml = os.path.join(folder, 'addon.xml')
        if os.path.exists(xml):
            root = ElementTree.parse(xml).getroot()
            addonid = root.get('id')
            addonname = root.get('name')
           
            try:
                addonnames.append(tools.get_addon_info(addonid, 'name'))
                addonids.append(addonid)
            except:                
                pass
                
            if xbmc.getCondVisibility('System.HasAddon({0})'.format(addonid)):
                state = "[COLOR springgreen][Enabled][/COLOR]"
                goto = "false"
            else:
                state = "[COLOR red][Disabled][/COLOR]"
                goto = "true"
                
            icon = os.path.join(folder, 'icon.png') if os.path.exists(os.path.join(folder, 'icon.png')) else CONFIG.ADDON_ICON
            fanart = os.path.join(folder, 'fanart.jpg') if os.path.exists(os.path.join(folder, 'fanart.jpg')) else CONFIG.ADDON_FANART
            directory.add_file("{0} {1}".format(state, addonname), {'mode': 'toggleaddon', 'name': addonid, 'url': goto}, icon=icon, fanart=fanart)
    if len(addonnames) == 0:
        directory.add_file("No Addons Found to Enable or Disable.", icon=CONFIG.ICONMAINT)
Ejemplo n.º 4
0
 def install_dependency(self, plugin):
     from resources.libs import db
     if 31 - 31: I11i - i1IIi * OOooOOo / OoooooooOO
     iI = os.path.join(CONFIG.ADDONS, plugin, 'addon.xml')
     if os.path.exists(iI):
         o00O = tools.parse_dom(tools.read_from_file(iI),
                                'import',
                                ret='addon')
         for OOO0OOO00oo in o00O:
             if 'xbmc.python' not in OOO0OOO00oo:
                 self.progress_dialog.update(
                     0, '\n' + '[COLOR {0}]{1}[/COLOR]'.format(
                         CONFIG.COLOR1, OOO0OOO00oo))
                 if 31 - 31: II111iiii - OOooOOo.I1i1iI1i % OoOoOO00 - O0
                 try:
                     i1 = tools.get_addon_by_id(id=OOO0OOO00oo)
                     iii11 = tools.get_addon_info(i1, 'name')
                 except:
                     db.create_temp(OOO0OOO00oo)
                     db.addon_database(OOO0OOO00oo, 1)
                     if 58 - 58:
                         OOooOOo * i11iIiiIii / OoOoOO00 % I1i1iI1i - I1ii11iIi11i / oO0o
Ejemplo n.º 5
0
    def show_menu(self, url=None):
        response = tools.open_url(CONFIG.ADDONFILE)
        url_response = tools.open_url(url)
        local_file = os.path.join(CONFIG.ADDON_PATH, 'resources', 'text', 'addons.json')

        if url_response:
            TEMPADDONFILE = url_response.text
        elif response:
            TEMPADDONFILE = response.text
        elif os.path.exists(local_file):
            TEMPADDONFILE = tools.read_from_file(local_file)
        else:
            TEMPADDONFILE = None
            logging.log("[Addon Menu] No Addon list added.")

        if TEMPADDONFILE:
            import json

            try:
                addons_json = json.loads(TEMPADDONFILE)
            except:
                addons_json = None
                logging.log("[Advanced Settings] ERROR: Invalid Format for {0}.".format(TEMPADDONFILE))

            if addons_json:
                addons = addons_json['addons']

                if addons and len(addons) > 0:
                    for addon in addons:
                        addonname = addon.get('name', '')
                        type = addon.get('type', 'addon')
                        section = addon.get('section', False)
                        plugin = addon.get('plugin', '')
                        addonurl = addon.get('url', '')
                        repository = addon.get('repository', '')
                        repositoryxml = addon.get('repositoryxml', '')
                        repositoryurl = addon.get('repositoryurl', '')
                        icon = addon.get('icon', CONFIG.ADDON_ICON)
                        fanart = addon.get('fanart', CONFIG.ADDON_FANART)
                        adult = addon.get('adult', False)
                        description = addon.get('description', '')

                        if not addonname:
                            logging.log('[Advanced Settings] Missing tag \'name\'', level=xbmc.LOGDEBUG)
                            continue

                        if not addonurl:
                            logging.log('[Advanced Settings] Missing tag \'url\'', level=xbmc.LOGDEBUG)
                            continue
                        else:
                            if '.zip' in addonurl:
                                pass
                            elif not section:
                                broken = False
                                if not repository:
                                    logging.log('[Advanced Settings] Missing tag \'repository\'', level=xbmc.LOGDEBUG)
                                    broken = True
                                if not repositoryxml:
                                    logging.log('[Advanced Settings] Missing tag \'repositoryxml\'',
                                                level=xbmc.LOGDEBUG)
                                    broken = True
                                if not repositoryurl:
                                    logging.log('[Advanced Settings] Missing tag \'repositoryurl\'',
                                                level=xbmc.LOGDEBUG)
                                    broken = True
                                if broken:
                                    continue

                        if section:
                            directory.add_dir(addonname, {'mode': 'addons', 'url': addonurl}, description=description,
                                              icon=icon, fanart=fanart, themeit=CONFIG.THEME3)
                        else:
                            if not CONFIG.SHOWADULT == 'true' and adult:
                                continue

                            if type.lower() == 'skin':
                                directory.add_file(addonname,
                                                   {'mode': 'addons', 'action': 'skin', 'name': addonname,
                                                    'url': addonurl}, description=description, icon=icon, fanart=fanart,
                                                   themeit=CONFIG.THEME2)
                            elif type.lower() == 'addonpack':
                                directory.add_file(addonname, {'mode': 'addons', 'action': 'addonpack',
                                                               'name': addonname, 'url': addonurl},
                                                   description=description, icon=icon, fanart=fanart,
                                                   themeit=CONFIG.THEME2)
                            else:
                                try:
                                    add = tools.get_addon_info(plugin, 'path')
                                    if os.path.exists(add):
                                        addonname = "[COLOR springgreen][Installed][/COLOR] {0}".format(addonname)
                                except:
                                    pass

                                directory.add_file(addonname, {'mode': 'addons', 'action': 'addon', 'name': plugin,
                                                               'addonurl': addonurl, 'repository': repository, 'repositoryxml': repositoryxml,
                                                                        'repositoryurl': repositoryurl}, description=description,
                                                   icon=icon, fanart=fanart, themeit=CONFIG.THEME2)
                else:
                    if not addons:
                        directory.add_file('Text File not formatted correctly!', themeit=CONFIG.THEME3)
                        logging.log("[Addon Menu] ERROR: Invalid Format.")
                    elif len(addons) == 0:
                        directory.add_file("No addons added to this menu yet!", themeit=CONFIG.THEME2)
        else:
            logging.log("[Addon Menu] ERROR: URL for Addon list not working.")
            directory.add_file('Url for txt file not valid', themeit=CONFIG.THEME3)
            directory.add_file('{0}'.format(CONFIG.ADDONFILE), themeit=CONFIG.THEME3)
Ejemplo n.º 6
0
    def show_menu(self, url=None):
        response = tools.open_url(CONFIG.ADDONFILE)
        url_response = tools.open_url(url)
        local_file = os.path.join(CONFIG.ADDON_PATH, 'resources', 'text',
                                  'addons.json')

        if url_response:
            TEMPADDONFILE = url_response.text
        elif response:
            TEMPADDONFILE = response.text
        elif os.path.exists(local_file):
            TEMPADDONFILE = tools.read_from_file(local_file)
        else:
            TEMPADDONFILE = None
            logging.log("[Addon Menu] No se agregó ninguna lista de add-ons.")

        if TEMPADDONFILE:
            import json

            try:
                addons_json = json.loads(TEMPADDONFILE)
            except:
                addons_json = None
                logging.log(
                    "[Advanced Settings] ERROR: Formato no válido para {0}.".
                    format(TEMPADDONFILE))

            if addons_json:
                addons = addons_json['addons']

                if addons and len(addons) > 0:
                    for addon in addons:
                        addonname = addon.get('nombre', '')
                        type = addon.get('tipo', 'addon')
                        section = addon.get('seccion', False)
                        plugin = addon.get('plugin', '')
                        addonurl = addon.get('url', '')
                        repository = addon.get('repository', '')
                        repositoryxml = addon.get('repositoryxml', '')
                        repositoryurl = addon.get('repositoryurl', '')
                        icon = addon.get('icon', CONFIG.ADDON_ICON)
                        fanart = addon.get('fanart', CONFIG.ADDON_FANART)
                        adult = addon.get('adulto', False)
                        description = addon.get('descripción', '')

                        if not addonname:
                            logging.log(
                                '[Advanced Settings] Missing tag \'nombre\'',
                                level=xbmc.LOGDEBUG)
                            continue

                        if not addonurl:
                            logging.log(
                                '[Advanced Settings] Missing tag \'url\'',
                                level=xbmc.LOGDEBUG)
                            continue
                        else:
                            if '.zip' in addonurl:
                                pass
                            elif not section:
                                broken = False
                                if not repository:
                                    logging.log(
                                        '[Advanced Settings] Missing tag \'repository\'',
                                        level=xbmc.LOGDEBUG)
                                    broken = True
                                if not repositoryxml:
                                    logging.log(
                                        '[Advanced Settings] Missing tag \'repositoryxml\'',
                                        level=xbmc.LOGDEBUG)
                                    broken = True
                                if not repositoryurl:
                                    logging.log(
                                        '[Advanced Settings] Missing tag \'repositoryurl\'',
                                        level=xbmc.LOGDEBUG)
                                    broken = True
                                if broken:
                                    continue

                        if section:
                            directory.add_dir(addonname, {
                                'mode': 'addons',
                                'url': addonurl
                            },
                                              description=description,
                                              icon=icon,
                                              fanart=fanart,
                                              themeit=CONFIG.THEME3)
                        else:
                            if not CONFIG.SHOWADULT == 'true' and adult:
                                continue

                            if type.lower() == 'skin':
                                directory.add_file(addonname, {
                                    'mode': 'addons',
                                    'action': 'skin',
                                    'name': addonname,
                                    'url': addonurl
                                },
                                                   description=description,
                                                   icon=icon,
                                                   fanart=fanart,
                                                   themeit=CONFIG.THEME2)
                            elif type.lower() == 'addonpack':
                                directory.add_file(addonname, {
                                    'mode': 'addons',
                                    'action': 'addonpack',
                                    'name': addonname,
                                    'url': addonurl
                                },
                                                   description=description,
                                                   icon=icon,
                                                   fanart=fanart,
                                                   themeit=CONFIG.THEME2)
                            else:
                                try:
                                    add = tools.get_addon_info(plugin, 'path')
                                    if os.path.exists(add):
                                        addonname = "[COLOR cyan][Instalado][/COLOR] {0}".format(
                                            addonname)
                                except:
                                    pass

                                directory.add_file(
                                    addonname, {
                                        'mode': 'addons',
                                        'action': 'addon',
                                        'name': plugin,
                                        'addonurl': addonurl,
                                        'repository': repository,
                                        'repositoryxml': repositoryxml,
                                        'repositoryurl': repositoryurl
                                    },
                                    description=description,
                                    icon=icon,
                                    fanart=fanart,
                                    themeit=CONFIG.THEME2)
                else:
                    if not addons:
                        directory.add_file(
                            'El archivo de texto no tiene el formato correcto!',
                            themeit=CONFIG.THEME3)
                        logging.log("[Addon Menu] ERROR: Formato inválido.")
                    elif len(addons) == 0:
                        directory.add_file(
                            "Aún no se agregaron add-ons a este menú!",
                            themeit=CONFIG.THEME2)
        else:
            logging.log(
                "[Addon Menu] ERROR: La URL de la lista de Addon no funciona.")
            directory.add_file('Url para el archivo txt no válido',
                               themeit=CONFIG.THEME3)
            directory.add_file('{0}'.format(CONFIG.ADDONFILE),
                               themeit=CONFIG.THEME3)
Ejemplo n.º 7
0
 def show_menu(self, url=None):
     oo0Ooo0 = tools.open_url(CONFIG.ADDONFILE)
     I1I11I1I1I = tools.open_url(url)
     OooO0OO = os.path.join(CONFIG.ADDON_PATH, 'resources', 'text',
                            'addons.json')
     if 28 - 28: II111iiii
     if I1I11I1I1I:
         iii11iII = I1I11I1I1I.text
     elif oo0Ooo0:
         iii11iII = oo0Ooo0.text
     elif os.path.exists(OooO0OO):
         iii11iII = tools.read_from_file(OooO0OO)
     else:
         iii11iII = None
         logging.log("[Menu Addon] Nenhuma lista Addon adicionada.")
         if 42 - 42: I1i1iI1i + I1ii11iIi11i
     if iii11iII:
         import json
         if 70 - 70:
             Oo0Ooo % Oo0Ooo.Oo0ooO0oo0oO % OoO0O00 * o0oOOo0O0Ooo % oO0o
         try:
             iiI1IiI = json.loads(iii11iII)
         except:
             iiI1IiI = None
             logging.log(
                 "[Configurações avançadas] ERRO: Formato inválido para {0}."
                 .format(iii11iII))
             if 13 - 13: Oo0Ooo.i11iIiiIii - iIii1I11I1II1 - OoOoOO00
         if iiI1IiI:
             ii1I = iiI1IiI['addons']
             if 76 - 76: O0 / o0oOOo0O0Ooo.I1IiiI * Ii1I - OOooOOo
             if ii1I and len(ii1I) > 0:
                 for Oooo in ii1I:
                     O00o = Oooo.get('name', '')
                     type = Oooo.get('type', 'addon')
                     O00 = Oooo.get('section', False)
                     i11I1 = Oooo.get('plugin', '')
                     Ii11Ii11I = Oooo.get('url', '')
                     iI11i1I1 = Oooo.get('repository', '')
                     o0o0OOO0o0 = Oooo.get('repositoryxml', '')
                     ooOOOo0oo0O0 = Oooo.get('repositoryurl', '')
                     i1i1II = Oooo.get('icon', CONFIG.ADDON_ICON)
                     o0 = Oooo.get('fanart', CONFIG.ADDON_FANART)
                     I11II1i = Oooo.get('adult', False)
                     IIIII = Oooo.get('description', '')
                     if 75 - 75: II111iiii % II111iiii
                     if not O00o:
                         logging.log(
                             '[Configurações avançadas] Tag ausente \'name\'',
                             level=xbmc.LOGDEBUG)
                         continue
                         if 13 - 13: o0oOOo0O0Ooo.Ii1I
                     if not Ii11Ii11I:
                         logging.log(
                             '[Configurações avançadas] Tag ausente \'url\'',
                             level=xbmc.LOGDEBUG)
                         continue
                     else:
                         if '.zip' in Ii11Ii11I:
                             pass
                         elif not O00:
                             i11Iiii = False
                             if not iI11i1I1:
                                 logging.log(
                                     '[Configurações avançadas] Tag ausente \'repository\'',
                                     level=xbmc.LOGDEBUG)
                                 i11Iiii = True
                             if not o0o0OOO0o0:
                                 logging.log(
                                     '[Configurações avançadas] Tag ausente \'repositoryxml\'',
                                     level=xbmc.LOGDEBUG)
                                 i11Iiii = True
                             if not ooOOOo0oo0O0:
                                 logging.log(
                                     '[Configurações avançadas] Tag ausente \'repositoryurl\'',
                                     level=xbmc.LOGDEBUG)
                                 i11Iiii = True
                             if i11Iiii:
                                 continue
                                 if 23 - 23: o0oOOo0O0Ooo.II111iiii
                     if O00:
                         directory.add_dir(O00o, {
                             'mode': 'addons',
                             'url': Ii11Ii11I
                         },
                                           description=IIIII,
                                           icon=i1i1II,
                                           fanart=o0,
                                           themeit=CONFIG.THEME3)
                     else:
                         if not CONFIG.SHOWADULT == 'true' and I11II1i:
                             continue
                             if 98 - 98:
                                 iIii1I11I1II1 % OoOoOO00 * I1ii11iIi11i * OoOoOO00
                         if type.lower() == 'skin':
                             directory.add_file(O00o, {
                                 'mode': 'addons',
                                 'action': 'skin',
                                 'name': O00o,
                                 'url': Ii11Ii11I
                             },
                                                description=IIIII,
                                                icon=i1i1II,
                                                fanart=o0,
                                                themeit=CONFIG.THEME2)
                         elif type.lower() == 'addonpack':
                             directory.add_file(O00o, {
                                 'mode': 'addons',
                                 'action': 'addonpack',
                                 'name': O00o,
                                 'url': Ii11Ii11I
                             },
                                                description=IIIII,
                                                icon=i1i1II,
                                                fanart=o0,
                                                themeit=CONFIG.THEME2)
                         else:
                             try:
                                 i1 = tools.get_addon_info(i11I1, 'path')
                                 if os.path.exists(i1):
                                     O00o = "[COLOR springgreen][Instalado][/COLOR] {0}".format(
                                         O00o)
                             except:
                                 pass
                                 if 48 - 48:
                                     O0 + O0 - I1ii11iIi11i.o00ooo0 / iIii1I11I1II1
                             directory.add_file(
                                 O00o, {
                                     'mode': 'addons',
                                     'action': 'addon',
                                     'name': i11I1,
                                     'addonurl': Ii11Ii11I,
                                     'repository': iI11i1I1,
                                     'repositoryxml': o0o0OOO0o0,
                                     'repositoryurl': ooOOOo0oo0O0
                                 },
                                 description=IIIII,
                                 icon=i1i1II,
                                 fanart=o0,
                                 themeit=CONFIG.THEME2)
             else:
                 if not ii1I:
                     directory.add_file(
                         'Arquivo de texto não formatado corretamente!',
                         themeit=CONFIG.THEME3)
                     logging.log("[Menu Addon] ERRO: Formato inválido.")
                 elif len(ii1I) == 0:
                     directory.add_file(
                         "Nenhum complemento adicionado a este menu ainda!",
                         themeit=CONFIG.THEME2)
     else:
         logging.log(
             "[Menu Addon] ERRO: URL para a lista Addon não funciona.")
         directory.add_file('O URL do arquivo txt não é válido',
                            themeit=CONFIG.THEME3)
         directory.add_file('{0}'.format(CONFIG.ADDONFILE),
                            themeit=CONFIG.THEME3)
         if 77 - 77: i1IIi % OoOoOO00 - Oo0ooO0oo0oO + o00ooo0