mirror of
https://github.com/anxdpanic/plugin.video.youtube.git
synced 2025-12-06 02:30:50 -08:00
Add script action to refresh settings
- Will remove unused settings from settings.xml in Kodi 20+
This commit is contained in:
parent
076f038e3a
commit
fe9f4804a6
4 changed files with 62 additions and 2 deletions
|
|
@ -21,7 +21,7 @@ from .constants import (
|
|||
)
|
||||
from .context import XbmcContext
|
||||
from .network import get_client_ip_address, httpd_status
|
||||
from .utils import rm_dir, validate_ip_address
|
||||
from .utils import current_system_version, rm_dir, validate_ip_address
|
||||
|
||||
|
||||
def _config_actions(context, action, *_args):
|
||||
|
|
@ -150,6 +150,48 @@ def _maintenance_actions(context, action, params):
|
|||
targets[target]().clear()
|
||||
ui.show_notification(localize('succeeded'))
|
||||
|
||||
elif action == 'refresh':
|
||||
targets = {
|
||||
'settings_xml': 'settings.xml',
|
||||
}
|
||||
path = targets.get(target)
|
||||
if not path:
|
||||
return
|
||||
|
||||
if target == 'settings_xml' and ui.on_yes_no_input(
|
||||
context.get_name(), localize('refresh.settings.confirm')
|
||||
):
|
||||
if not current_system_version.compatible(20, 0):
|
||||
ui.show_notification(localize('failed'))
|
||||
return
|
||||
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
path = xbmcvfs.translatePath(os.path.join(DATA_PATH, path))
|
||||
xml = ET.parse(path)
|
||||
settings = xml.getroot()
|
||||
|
||||
marker = settings.find('setting[@id="|end_settings_marker|"]')
|
||||
if marker is None:
|
||||
ui.show_notification(localize('failed'))
|
||||
return
|
||||
|
||||
removed = 0
|
||||
for setting in reversed(settings.findall('setting')):
|
||||
if setting == marker:
|
||||
break
|
||||
settings.remove(setting)
|
||||
removed += 1
|
||||
else:
|
||||
ui.show_notification(localize('failed'))
|
||||
return
|
||||
|
||||
if removed:
|
||||
xml.write(path)
|
||||
ui.show_notification(localize('succeeded'))
|
||||
else:
|
||||
return
|
||||
|
||||
elif action == 'delete':
|
||||
path = params.get('path')
|
||||
targets = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue