def _get_value(edit_def, key): if isinstance(edit_def[_clean_key(key)], dict): is_art = key == 'art' label = utils.get_string(32117) if is_art else utils.get_string(32118) options = _get_options(edit_def[key], useThumbs=is_art) idx = dialog.select(label, options, useDetails=is_art) if idx < 0: return elif idx == len(options) - 1: keys = utils.info_types if key == 'file' else utils.art_types add_options = [ i for i in keys if (i not in edit_def[key] or edit_def[key][i] in [None, "", -1]) ] add_idx = dialog.select( utils.get_string(32120) if key == 'file' else utils.get_string(32119), add_options) if add_idx < 0: return if key == 'file': value = dialog.input( utils.get_string(32121).format(add_options[add_idx])) if value is not None: edit_def[key][add_options[add_idx]] = value return edit_def[key][add_options[add_idx]] elif key == 'art': value = dialog.browse(2, utils.get_string(32049).format( add_options[add_idx].capitalize()), shares='files', mask='.jpg|.png', useThumbs=True) if value is not None: edit_def[key][ add_options[add_idx]] = utils.clean_artwork_url(value) return edit_def[key] else: subkey = _clean_key(options[idx]) value = _get_value(edit_def[key], _clean_key(options[idx])) if value is not None: edit_def[key][subkey] = value return edit_def[key] else: default = edit_def[key] if key in utils.art_types: value = dialog.browse(2, utils.get_string(32049).format( key.capitalize()), shares='files', mask='.jpg|.png', useThumbs=True, defaultt=default) elif key == 'filetype': options = ['file', 'directory'] type = dialog.select(utils.get_string(32122), options, preselect=options.index(default)) value = options[type] elif key == 'color': value = utils.set_color() else: value = dialog.input(utils.get_string(32121).format(key), defaultt=default) if value == default: clear = dialog.yesno( 'AutoWidget', utils.get_string(32123).format( 'art' if key in utils.art_types else 'value', key, default), yeslabel=utils.get_string(32124), nolabel=utils.get_string(32125)) if clear: value = '' if value is not None: edit_def[key] = utils.clean_artwork_url(value) return value
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 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)
def _get_value(edit_def, key): if isinstance(edit_def[_clean_key(key)], dict): is_art = key == "art" label = utils.get_string(30091) if is_art else utils.get_string(30092) options = _get_options(edit_def[key], useThumbs=is_art) idx = dialog.select(label, options, useDetails=is_art) if idx < 0: return elif idx == len(options) - 1: keys = utils.info_types if key == "file" else utils.art_types add_options = [ i for i in keys if (i not in edit_def[key] or edit_def[key][i] in [None, "", -1]) ] add_idx = dialog.select( utils.get_string(30094) if key == "file" else utils.get_string(30093), add_options, ) if add_idx < 0: return if key == "file": value = dialog.input( utils.get_string(30095).format(add_options[add_idx])) if value is not None: edit_def[key][add_options[add_idx]] = value return edit_def[key][add_options[add_idx]] elif key == "art": value = dialog.browse( 2, utils.get_string(30032).format( add_options[add_idx].capitalize()), shares="files", mask=".jpg|.png", useThumbs=True, ) if value is not None: edit_def[key][ add_options[add_idx]] = utils.clean_artwork_url(value) return edit_def[key] else: subkey = _clean_key(options[idx]) value = _get_value(edit_def[key], _clean_key(options[idx])) if value is not None: edit_def[key][subkey] = value return edit_def[key] else: default = edit_def[key] if key in utils.art_types: value = dialog.browse( 2, utils.get_string(30032).format(key.capitalize()), shares="files", mask=".jpg|.png", useThumbs=True, defaultt=default, ) elif key == "filetype": options = ["file", "directory"] type = dialog.select(utils.get_string(30096), options, preselect=options.index(default)) value = options[type] elif key == "color": value = utils.set_color() else: value = dialog.input(utils.get_string(30095).format(key), defaultt=default) if value == default: clear = dialog.yesno( "AutoWidget", utils.get_string(30097).format( "art" if key in utils.art_types else "value", key, default), yeslabel=utils.get_string(30098), nolabel=utils.get_string(30099), ) if clear: value = "" if value is not None: if key in utils.art_types: edit_def[key] = utils.clean_artwork_url(value) else: edit_def[key] = value return value
def _get_value(edit_def, key): dialog = xbmcgui.Dialog() if isinstance(edit_def[_clean_key(key)], dict): is_art = key == "art" label = utils.get_string(30091) if is_art else utils.get_string(30092) options = _get_options(edit_def[key], useThumbs=is_art) idx = dialog.select(label, options, useDetails=is_art) if idx < 0: del dialog return elif idx == len(options) - 1: keys = utils.info_types if key == "file" else utils.art_types add_options = [ i for i in keys if (i not in edit_def[key] or edit_def[key][i] in [None, "", -1]) ] add_idx = dialog.select( utils.get_string(30094) if key == "file" else utils.get_string(30093), add_options, ) if add_idx < 0: del dialog return if key == "file": value = dialog.input( utils.get_string(30095).format(add_options[add_idx])) if value is not None: edit_def[key][add_options[add_idx]] = value del dialog return edit_def[key][add_options[add_idx]] elif key == "art": value = dialog.browse( 2, utils.get_string(30032).format( add_options[add_idx].capitalize()), shares="files", mask=".jpg|.png", useThumbs=True, ) if value is not None: edit_def[key][ add_options[add_idx]] = utils.clean_artwork_url(value) del dialog return edit_def[key] else: subkey = _clean_key(options[idx]) value = _get_value(edit_def[key], _clean_key(options[idx])) if value is not None: edit_def[key][subkey] = value del dialog return edit_def[key] else: default = edit_def[key] if key in utils.art_types: value = dialog.browse( 2, utils.get_string(30032).format(key.capitalize()), shares="files", mask=".jpg|.png", useThumbs=True, defaultt=default, ) elif key == "filetype": options = ["file", "directory"] type = dialog.select(utils.get_string(30096), options, preselect=options.index(default)) value = options[type] elif key == "color": value = utils.set_color() elif key == "content": options = [ "none", "files", "movies", "tvshows", "episodes", "videos", "artists", "albums", "songs", "musicvideos", "images", "games", "genres", "years", "actors", "playlists", "plugins", "studios", "directors", "sets", "tags", "countries", "roles", "images", "addons", "livetv", ] type = dialog.select( utils.get_string(30119), options, preselect=options.index(default if default in options else "none"), ) value = options[type] else: value = dialog.input(utils.get_string(30095).format(key), defaultt=default) if value == default: clear = dialog.yesno( "AutoWidget", utils.get_string(30097).format( "art" if key in utils.art_types else "value", key, default), yeslabel=utils.get_string(30098), nolabel=utils.get_string(30099), ) if clear: value = "" del dialog if value is not None: if key in utils.art_types: edit_def[key] = utils.clean_artwork_url(value) else: edit_def[key] = value return value