def merged_path(group_id, widget_id): _window = utils.get_active_window() group_def = manage.get_group_by_id(group_id) group_name = group_def.get("label", "") paths = group_def.get("paths", []) if len(paths) == 0: directory.add_menu_item(title=30019, art=utils.get_art("alert"), isFolder=False) return True, group_name, None widget_def = manage.get_widget_by_id(widget_id, group_id) if widget_def and _window != "dialog": paths = widget_def["path"] elif not widget_def: idxs = manage.choose_paths(utils.get_string(30089), paths, 5) if idxs is not None: if len(idxs) > 0: widget_def = manage.initialize(group_def, "merged", widget_id, keep=idxs) paths = widget_def["path"] if widget_def: titles = [] for idx, path in enumerate(paths): # simple compatibility with pre-3.3.0 widgets if isinstance(path, dict): path = path.get("id", "") paths[idx] = path widget_def["path"] = paths manage.save_path_details(widget_def) path_def = manage.get_path_by_id(path, group_id) titles, cat, type = show_path( group_id, path_def["label"], widget_id, path_def, idx=idx, titles=titles, num=len(paths), merged=True, ) return titles, cat, type else: directory.add_menu_item(title=30045, art=info, isFolder=True) return True, group_name, None
def copy_group(group_id, type): old_group_def = manage.get_group_by_id(group_id) new_group_id = add_group(type, old_group_def.get("label")) if not new_group_id: return new_group_def = manage.get_group_by_id(new_group_id) new_group_def["art"] = old_group_def.get("art", {}) new_group_def["content"] = old_group_def.get( "content", new_group_def.get("content", "files")) paths = old_group_def.get("paths", []) new_group_def["paths"] = manage.choose_paths(utils.get_string(30121), paths, indices=False) manage.write_path(new_group_def) utils.update_container()
def path_menu(group_id, action, widget_id): group_def = manage.get_group_by_id(group_id) if not group_def: directory.add_menu_item( title=30051, info={"plot": utils.get_string(30053)}, art=utils.get_art("alert"), isFolder=True, ) return True, "AutoWidget", None group_name = group_def.get("label", "") paths = group_def.get("paths", []) if len(paths) == 0: directory.add_menu_item(title=30019, art=utils.get_art("alert"), isFolder=True) return True, group_name, None widget_def = manage.get_widget_by_id(widget_id, group_id) if not widget_def: dialog = xbmcgui.Dialog() if action == "static": idx = manage.choose_paths(utils.get_string(30088), paths, indices=True, single=True) if idx == -1: return True, "AutoWidget", None widget_def = manage.initialize(group_def, action, widget_id, keep=idx) elif action == "cycling": idx = dialog.select( utils.get_string(30059), [utils.get_string(30057), utils.get_string(30058)], ) if idx == -1: del dialog return True, "AutoWidget", None _action = "random" if idx == 0 else "next" cycle_paths = manage.choose_paths(utils.get_string(30123), paths, threshold=-1, indices=True) widget_def = manage.initialize(group_def, _action, widget_id, keep=cycle_paths) del dialog if widget_def: widget_path = widget_def.get("path", "") # simple compatibility with pre-3.3.0 widgets if isinstance(widget_path, dict): widget_path = widget_def.get("path", {}).get("id", "") widget_def["path"] = widget_path manage.save_path_details(widget_def) widget_path = manage.get_path_by_id(widget_path, group_id) _label = "" if isinstance(widget_path, dict): _label = widget_path.get("label", "") utils.log("Showing widget {}".format(widget_id), "debug") titles, cat, type = show_path(group_id, _label, widget_id, widget_path) return titles, cat, type else: directory.add_menu_item(title=30045, art=info, isFolder=True) return True, group_name, None