Exemplo n.º 1
0
params = dict(urlparse.parse_qsl(sys.argv[2].replace('?', '')))

try: name           = params["name"]
except: name        = ''

try: description    = params["description"]
except: description = name

try: fanart         = params["fanart"]
except: fanart      = ''

try: iconimage      = params["iconimage"]
except: iconimage   = ''

try: mode           = params["mode"]
except: mode        = None

try: url            = params["url"]
except: url         = ''

if mode in master_modes:
    try:
        eval(master_modes[mode])
    except:
        koding.Text_Box('ERROR IN CODE',koding.Last_Error())
elif mode == None:
    Main_Menu()
else:
    dialog.ok('MODE DOES NOT EXIST','The following mode does not exist in your master_modes dictionary:','[COLOR=dodgerblue]%s[/COLOR]'%mode)

xbmcplugin.endOfDirectory(int(sys.argv[1]))
Exemplo n.º 2
0
def Configure_Menus(menutype='HOME_'):
    shortcut_file = {
        String(30061): 'x606.DATA.xml',
        String(30077): 'x303.DATA.xml',
        String(30062): 'x404.DATA.xml',
        String(30063): 'x505.DATA.xml',
        String(30064): 'x8.DATA.xml',
        String(30065): 'x12.DATA.xml',
        String(30066): 'x10.DATA.xml',
        String(30067): 'x3.DATA.xml',
        String(30068): 'x1.DATA.xml',
        String(30069): 'x2.DATA.xml',
        String(30070): 'x202.DATA.xml',
        String(30071): 'x.7.DATA.xml',
        String(30072): 'x11.DATA.xml',
        String(30073): 'x4.DATA.xml',
        String(30074): 'x6.DATA.xml',
        String(30075): 'x13.DATA.xml'
    }

    master_list = [
        String(30061),
        String(30077),
        String(30062),
        String(30063),
        String(30064),
        String(30065),
        String(30066),
        String(30067),
        String(30068),
        String(30069),
        String(30070),
        String(30071),
        String(30072),
        String(30073),
        String(30074),
        String(30075),
        String(30504)
    ]

    choice = dialog.select(String(30294), sorted(master_list))
    if choice >= 0:
        menu = sorted(master_list)[choice]

        # If it's reset all to factory defaults
        if menu == String(30504):
            Reset_Factory(menutype)
        else:
            new_list = [
                String(30295) % menu,
                String(30296) % menu,
                String(30297),
                String(30298),
                String(30299)
            ]
            choice = dialog.select(String(30303), new_list)
            if choice >= 0:

                my_setting = menutype + menu.upper().replace(' ', '_')
                dialog_plus_user = os.path.join(
                    redirects, '%s_DIALOG_PLUS_USER' % my_setting)
                dialog_user = os.path.join(redirects,
                                           '%s_DIALOG_USER' % my_setting)
                exec_user = os.path.join(redirects,
                                         '%s_EXEC_USER' % my_setting)
                sf_user = os.path.join(redirects, '%s_SF_USER' % my_setting)

                delete_array = [
                    dialog_plus_user, dialog_user, exec_user, sf_user
                ]

                if choice == 0:
                    my_shortcut = my_setting + '_SF'
                    if menutype == 'HOME_':
                        Addon_Setting(setting=my_setting,
                                      value='super_faves_user')
                        for item in delete_array:
                            if not my_shortcut in item and os.path.exists(
                                    item):
                                os.remove(item)
                    if not os.path.exists(sf_user):
                        Text_File(sf_user, 'w', '')
                    else:
                        dialog.ok(String(30308), String(30309))
                        return

                if choice == 1:
                    my_shortcut = my_setting + '_DIALOG_PLUS_USER'
                    if menutype == 'HOME_':
                        dolog('Setting %s to: dialog_plus_user' % (my_setting))
                        Addon_Setting(setting=my_setting,
                                      value='dialog_plus_user')
                        for item in delete_array:
                            if not my_shortcut in item and os.path.exists(
                                    item):
                                os.remove(item)
                    if not os.path.exists(dialog_plus_user):
                        Text_File(dialog_plus_user, 'w', '')
                    else:
                        dialog.ok(String(30308), String(30309))
                        return

                if choice == 2:
                    my_shortcut = my_setting + '_DIALOG_USER'
                    if menutype == 'HOME_':
                        dolog('Setting %s to: dialog_user' % (my_setting))
                        Addon_Setting(setting=my_setting, value='dialog_user')
                        for item in delete_array:
                            if not my_shortcut in item and os.path.exists(
                                    item):
                                os.remove(item)
                    if not os.path.exists(dialog_user):
                        Text_File(dialog_user, 'w', '')
                    else:
                        dialog.ok(String(30308), String(30309))
                        return

                if choice == 3:
                    my_shortcut = my_setting + '_EXEC_USER'
                    if menutype == 'HOME_':
                        dolog('Setting %s to: executable_user' % (my_setting))
                        Addon_Setting(setting=my_setting,
                                      value='executable_user')
                        for item in delete_array:
                            if not my_shortcut in item and os.path.exists(
                                    item):
                                os.remove(item)
                    if not os.path.exists(exec_user):
                        my_code = koding.Keyboard(
                            'Enter the command you want to run')
                        if not my_code:
                            return
                        Text_File(exec_user, 'w', my_code)
                    else:
                        dialog.ok(String(30308), String(30309))
                        return

                if choice == 4:
                    if menutype == 'HOME_':
                        dolog('Setting %s to defaults' % (my_setting))
                        Default_Setting(setting=my_setting, reset=True)

                        # Find the relevant home menu and clear the contents
                        for item in os.listdir(redirects):
                            if item.startswith(my_setting) and item.endswith(
                                    '_USER'):
                                delete_path = os.path.join(redirects, item)
                                try:
                                    os.remove(delete_path)
                                except:
                                    dolog('FAILED TO REMOVE: %s' % delete_path)
                        if os.path.exists(
                                xbmc.translatePath(
                                    'special://home/addons/script.openwindow/default.py'
                                )):
                            xbmc.executebuiltin(
                                'RunScript(special://home/addons/script.openwindow/default.py,update_shares)'
                            )
                        elif os.path.exists(
                                xbmc.translatePath(
                                    'xbmc://home/addons/script.openwindow/default.py'
                                )):
                            xbmc.executebuiltin(
                                'RunScript(xbmc://home/addons/script.openwindow/default.py,update_shares)'
                            )

                    else:
                        try:
                            os.remove(
                                os.path.join(skin_shortcuts,
                                             shortcut_file[menu]))
                            os.remove(
                                os.path.join(skin_shortcuts,
                                             current_skin + '.hash'))
                        except:
                            xbmc.log('FAILED TO DEFAULT SKIN SETTINGS: %s' %
                                     koding.Last_Error())

                        for item in delete_array:
                            if os.path.exists(item):
                                os.remove(item)
                        koding.Refresh('skin')

            # If it's a submenu we try and add to the skinshortcuts and give it a name
                if menutype == 'SUBMENU_' and choice != 4:
                    sub_name = koding.Keyboard(
                        'Enter a name for this sub-menu item')
                    if not sub_name:
                        return
                    Edit_Sub_Menu(shortcut=my_shortcut,
                                  sub_name=sub_name,
                                  shortcut_file=shortcut_file[menu])
            else:
                Main_Menu_Check()