示例#1
0
def call_path(path_id):
    path_def = manage.get_path_by_id(path_id)
    if not path_def:
        return

    utils.call_builtin("Dialog.Close(busydialog)", 500)
    final_path = ""

    if path_def["target"] == "settings":
        final_path = "Addon.OpenSettings({})".format(
            path_def["file"]["file"]
            .replace("plugin://", "")
            .replace("script://", "")
            .split("/")[0]
        )
    elif (
        path_def["target"] == "shortcut"
        and path_def["file"]["filetype"] == "file"
        and path_def["content"] != "addons"
    ):
        if path_def["file"]["file"] == "addons://install/":
            final_path = "InstallFromZip"
        elif not path_def["content"] or path_def["content"] == "files":
            if path_def["file"]["file"].startswith("androidapp://sources/apps/"):
                final_path = "StartAndroidActivity({})".format(
                    path_def["file"]["file"].replace("androidapp://sources/apps/", "")
                )
            elif path_def["file"]["file"].startswith("pvr://"):
                final_path = "PlayMedia({})".format(path_def["file"]["file"])
            else:
                final_path = "RunPlugin({})".format(path_def["file"]["file"])
        elif (
            all(i in path_def["file"]["file"] for i in ["(", ")"])
            and "://" not in path_def["file"]["file"]
        ):
            final_path = path_def["file"]["file"]
        else:
            final_path = "PlayMedia({})".format(path_def["file"]["file"])
    elif (
        path_def["target"] == "widget"
        or path_def["file"]["filetype"] == "directory"
        or path_def["content"] == "addons"
    ):
        final_path = "ActivateWindow({},{},return)".format(
            path_def.get("window", "Videos"), path_def["file"]["file"]
        )

    if final_path:
        utils.log("Calling path from {} using {}".format(path_id, final_path), "debug")
        utils.call_builtin(final_path)
示例#2
0
def call_path(path_id):
    path_def = manage.get_path_by_id(path_id)
    if not path_def:
        return

    utils.call_builtin('Dialog.Close(busydialog)', 500)
    final_path = ''

    if path_def['target'] == 'shortcut' and path_def['file']['filetype'] == 'file' \
            and path_def['content'] != 'addons':
        if path_def['file']['file'] == 'addons://install/':
            final_path = 'InstallFromZip'
        elif not path_def['content'] or path_def['content'] == 'files':
            if path_def['file']['file'].startswith(
                    'androidapp://sources/apps/'):
                final_path = 'StartAndroidActivity({})'.format(
                    path_def['file']['file'].replace(
                        'androidapp://sources/apps/', ''))
            elif path_def['file']['file'].startswith('pvr://'):
                final_path = 'PlayMedia({})'.format(path_def['file']['file'])
            else:
                final_path = 'RunPlugin({})'.format(path_def['file']['file'])
        elif all(
                i in path_def['file']['file']
                for i in ['(', ')']) and '://' not in path_def['file']['file']:
            final_path = path_def['file']['file']
        else:
            final_path = 'PlayMedia({})'.format(path_def['file']['file'])
    elif path_def['target'] == 'widget' or path_def['file']['filetype'] == 'directory' \
            or path_def['content'] == 'addons':
        final_path = 'ActivateWindow({},{},return)'.format(
            path_def.get('window', 'Videos'), path_def['file']['file'])
    elif path_def['target'] == 'settings':
        final_path = 'Addon.OpenSettings({})'.format(
            path_def['file']['file'].replace('plugin://', ''))

    if final_path:
        utils.log('Calling path from {} using {}'.format(path_id, final_path),
                  'debug')
        utils.call_builtin(final_path)

    return False, path_def['label']
示例#3
0
def back_to_top(target):
    if target != "next":
        return
    actions = ["back", "firstpage", "right"]
    for action in actions:
        utils.call_builtin("Action({})".format(action), 100)
示例#4
0
def dispatch(_plugin, _handle, _params):
    params = _log_params(_plugin, int(_handle), _params)
    category = "AutoWidget"
    is_dir = False
    is_type = "files"

    utils.ensure_addon_data()

    mode = params.get("mode", "")
    action = params.get("action", "")
    group = params.get("group", "")
    path = params.get("path", "")
    path_id = params.get("path_id", "")
    target = params.get("target", "")
    widget_id = params.get("id", "")

    if not mode:
        is_dir, category, is_type = menu.root_menu()
    elif mode == "manage":
        if action == "add_group":
            add.add_group(target)
        elif action == "add_path" and group and target:
            add.add_path(group, target)
        elif action == "shift_path" and group and path_id and target:
            edit.shift_path(group, path_id, target)
        elif action == "edit":
            edit.edit_dialog(group, type="group")
        elif action == "edit_path":
            edit.edit_dialog(group, path_id)
        elif action == "edit_widget":
            edit.edit_widget_dialog(widget_id)
        elif action == "copy":
            if group and target:
                add.copy_group(group, target)
    elif mode == "group":
        if not group:
            is_dir, category, is_type = menu.my_groups_menu()
        else:
            is_dir, category, is_type = menu.group_menu(group)
    elif mode == "path":
        try:
            if path_id:
                menu.call_path(path_id)
            elif action in ["static", "cycling"] and group:
                is_dir, category, is_type = menu.path_menu(group, action, widget_id)
            elif action == "merged" and group:
                is_dir, category, is_type = menu.merged_path(group, widget_id)
            elif action == "update" and target:
                refresh.update_path(widget_id, target, path)
        except Exception as e:
            utils.log(traceback.format_exc(), "error")
            is_dir, category, is_type = menu.show_error(
                widget_id if widget_id else path_id
            )
    elif mode == "widget":
        is_dir, category, is_type = menu.active_widgets_menu()
    elif mode == "refresh":
        if not widget_id:
            refresh.refresh_paths()
        else:
            refresh.refresh(widget_id, force=True, single=True)
    elif mode == "tools":
        is_dir, category, is_type = menu.tools_menu()
    elif mode == "force":
        refresh.refresh_paths(notify=True, force=True)
    elif mode == "skindebug":
        utils.call_builtin("Skin.ToggleDebug")
    elif mode == "wipe":
        utils.wipe()
    elif mode == "clean":
        if not widget_id:
            manage.clean(notify=True, all=True)
        else:
            edit.remove_widget(widget_id, over=True)
            utils.update_container(True)
    elif mode == "clear_cache":
        if not target:
            utils.clear_cache()
        else:
            utils.clear_cache(target)
    elif mode == "set_color":
        utils.set_color(setting=True)
    elif mode == "backup" and action:
        if action == "location":
            backup.location()
        elif action == "backup":
            backup.backup()
        elif action == "restore":
            backup.restore()

    if is_dir:
        directory.add_sort_methods(_handle)
        directory.finish_directory(
            _handle, category, is_type if is_type not in [None, "none"] else ""
        )
def back_to_top(target):
    if target != 'next':
        return
    actions = ['back', 'firstpage', 'right']
    for action in actions:
        utils.call_builtin('Action({})'.format(action), 100)
def dispatch(_plugin, _handle, _params):
    params = _log_params(_plugin, int(_handle), _params)
    category = 'AutoWidget'
    is_dir = False
    is_type = 'files'

    utils.ensure_addon_data()

    mode = params.get('mode', '')
    action = params.get('action', '')
    group = params.get('group', '')
    path = params.get('path', '')
    path_id = params.get('path_id', '')
    target = params.get('target', '')
    widget_id = params.get('id', '')

    if not mode:
        is_dir, category = menu.root_menu()
    elif mode == 'manage':
        if action == 'add_group':
            manage.add_group(target)
        elif action == 'add_path' and group and target:
            manage.add_path(group, target)
        elif action == 'shift_path' and group and path_id and target:
            edit.shift_path(group, path_id, target)
        elif action == 'edit':
            edit.edit_dialog(group, type='group')
        elif action == 'edit_path':
            edit.edit_dialog(group, path_id)
        elif action == 'edit_widget':
            edit.edit_widget_dialog(widget_id)
    elif mode == 'group':
        if not group:
            is_dir, category = menu.my_groups_menu()
        else:
            is_dir, category = menu.group_menu(group)
    elif mode == 'path':
        if path_id:
            menu.call_path(path_id)
        elif action in ['static', 'cycling'] and group:
            is_dir, category = menu.path_menu(group, action, widget_id)
        elif action == 'merged' and group:
            is_dir, category = menu.merged_path(group, widget_id)
        elif action == 'update' and target:
            refresh.update_path(widget_id, target, path)
        is_type = 'videos'
    elif mode == 'widget':
        is_dir, is_category = menu.active_widgets_menu()
    elif mode == 'refresh':
        if not widget_id:
            refresh.refresh_paths()
        else:
            refresh.refresh(widget_id, force=True, single=True)
    elif mode == 'tools':
        is_dir, category = menu.tools_menu()
    elif mode == 'force':
        refresh.refresh_paths(notify=True, force=True)
    elif mode == 'skindebug':
        utils.call_builtin('Skin.ToggleDebug')
    elif mode == 'wipe':
        utils.wipe()
    elif mode == 'clean':
        if not widget_id:
            manage.clean(notify=True, all=True)
        else:
            edit.remove_widget(widget_id, over=True)
            utils.update_container(True)
    elif mode == 'clear_cache':
        utils.clear_cache()
    elif mode == 'set_color':
        utils.set_color(setting=True)
    elif mode == 'backup' and action:
        if action == 'location':
            backup.location()
        elif action == 'backup':
            backup.backup()
        elif action == 'restore':
            backup.restore()

    if is_dir:
        directory.add_sort_methods(_handle)
        directory.finish_directory(_handle, category, is_type)