Compare commits
21 Commits
matrix-1.7
...
krypton-1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56a1d95930 | ||
|
|
49b3144baa | ||
|
|
adc6ee0c52 | ||
|
|
5030cbce15 | ||
|
|
236ae90bd1 | ||
|
|
fd4bba7c81 | ||
|
|
ca05f9e9f8 | ||
|
|
9088127b13 | ||
|
|
02ce0baf5e | ||
|
|
03c20a2def | ||
|
|
ef7bef7908 | ||
|
|
13d5dc1b79 | ||
|
|
373ec95a8a | ||
|
|
fa6bdf43a4 | ||
|
|
1eca075d75 | ||
|
|
c2afb9b3ec | ||
|
|
d9e1fe5170 | ||
|
|
3bceb19e01 | ||
|
|
5745a20d33 | ||
|
|
abb27a7251 | ||
|
|
9ae5545f6c |
@@ -1,5 +1,5 @@
|
|||||||
# Backup Addon
|
# Backup Addon
|
||||||
 [](https://travis-ci.org/robweber/xbmcbackup) [](https://github.com/robweber/xbmcbackup/blob/master/LICENSE.txt)
|
 [](https://travis-ci.com/robweber/xbmcbackup) [](https://github.com/robweber/xbmcbackup/blob/master/LICENSE.txt)
|
||||||
|
|
||||||
## About
|
## About
|
||||||
|
|
||||||
|
|||||||
19
addon.xml
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<addon id="script.xbmcbackup"
|
<addon id="script.xbmcbackup"
|
||||||
name="Backup" version="1.5.2" provider-name="robweber">
|
name="Backup" version="1.5.4" provider-name="robweber">
|
||||||
<requires>
|
<requires>
|
||||||
<!-- jarvis -->
|
<!-- jarvis -->
|
||||||
<import addon="xbmc.python" version="2.25.0"/>
|
<import addon="xbmc.python" version="2.25.0"/>
|
||||||
@@ -90,15 +90,16 @@
|
|||||||
<email></email>
|
<email></email>
|
||||||
<assets>
|
<assets>
|
||||||
<icon>resources/images/icon.png</icon>
|
<icon>resources/images/icon.png</icon>
|
||||||
<screenshot>resources/images/screenshot1.png</screenshot>
|
<screenshot>resources/images/screenshot1.jpg</screenshot>
|
||||||
<screenshot>resources/images/screenshot2.png</screenshot>
|
<screenshot>resources/images/screenshot2.jpg</screenshot>
|
||||||
<screenshot>resources/images/screenshot3.png</screenshot>
|
<screenshot>resources/images/screenshot3.jpg</screenshot>
|
||||||
<screenshot>resources/images/screenshot4.png</screenshot>
|
<screenshot>resources/images/screenshot4.jpg</screenshot>
|
||||||
</assets>
|
</assets>
|
||||||
<news>Version 1.5.2
|
<news>Version 1.5.4
|
||||||
- Added script.module.dropbox import as a dependency for Dropbox filesystem
|
- converted PNG to JPG
|
||||||
- Fixed issue getting xbmcbackup.val file from non-zipped remote directories. Was being copied as though it was a local file so it was failing.
|
- updated Travis-CI links
|
||||||
- Use linux path separator (/) all the time, Kodi will interpret this correctly on windows. Was causing issues with remote file systems since os.path.sep
|
- added utf decode to JSON calls
|
||||||
|
- added better system settings/restore functionality (enabled by default)
|
||||||
</news>
|
</news>
|
||||||
</extension>
|
</extension>
|
||||||
</addon>
|
</addon>
|
||||||
|
|||||||
21
changelog.md
@@ -4,11 +4,28 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||||
|
|
||||||
## [Unreleased](https://github.com/robweber/xbmcbackup/compare/krypton-1.5.2...HEAD)
|
## [Version 1.5.4](https://github.com/robweber/xbmcbackup/compare/krypton-1.5.3...robweber:krypton-1.5.4) - 2020-12-03
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- added new badges for Kodi Version, TravisCI and license information from shields.io
|
- added method to backup/restore Kodi settings via the GetSettings/SetSettingValue JSON methods in the validation file
|
||||||
|
- added setting to always restore settings or prompt at the time of backup
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- changed PNG screenshots to JPG (per #165)
|
||||||
|
- updated Travis CI links. travis-ci.org is deprectated to travis-ci.com
|
||||||
|
- decode string after GetSettings JSON call (per #162)
|
||||||
|
|
||||||
|
## [Version 1.5.3](https://github.com/robweber/xbmcbackup/compare/krypton-1.5.2...robweber:krypton-1.5.3) - 2019-12-30
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- added new badges for Kodi Version, TravisCI and license information from shields.io
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- backported a fix from Matrix that fixes backup rotation paths when slashes are missing from the base path (thanks @AnonTester)
|
||||||
|
|
||||||
## [Version 1.5.2](https://github.com/robweber/xbmcbackup/compare/krypton-1.5.1...robweber:krypton-1.5.2) - 2019-09-30
|
## [Version 1.5.2](https://github.com/robweber/xbmcbackup/compare/krypton-1.5.1...robweber:krypton-1.5.2) - 2019-09-30
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 125 KiB |
BIN
resources/images/screenshot1.jpg
Normal file
|
After Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 125 KiB |
|
Before Width: | Height: | Size: 129 KiB |
BIN
resources/images/screenshot2.jpg
Normal file
|
After Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 129 KiB |
|
Before Width: | Height: | Size: 270 KiB |
BIN
resources/images/screenshot3.jpg
Normal file
|
After Width: | Height: | Size: 135 KiB |
|
Before Width: | Height: | Size: 270 KiB |
|
Before Width: | Height: | Size: 150 KiB |
BIN
resources/images/screenshot4.jpg
Normal file
|
After Width: | Height: | Size: 95 KiB |
|
Before Width: | Height: | Size: 150 KiB |
BIN
resources/images/screenshot5.jpg
Normal file
|
After Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 102 KiB |
BIN
resources/images/screenshot6.jpg
Normal file
|
After Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 76 KiB |
@@ -556,3 +556,15 @@ msgstr ""
|
|||||||
msgctxt "#30141"
|
msgctxt "#30141"
|
||||||
msgid "This will erase any current Advanced Editor settings"
|
msgid "This will erase any current Advanced Editor settings"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30148"
|
||||||
|
msgid "Ask before restoring Kodi UI settings"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30149"
|
||||||
|
msgid "Restore Kodi UI Settings"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30150"
|
||||||
|
msgid "Restore saved Kodi system settings from backup?"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -280,6 +280,12 @@ class XbmcBackup:
|
|||||||
xbmcgui.Dialog().ok(utils.getString(30077),utils.getString(30078))
|
xbmcgui.Dialog().ok(utils.getString(30077),utils.getString(30078))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# check if settings should be restored from this backup
|
||||||
|
restoreSettings = utils.getSetting('always_prompt_restore_settings') == 'false'
|
||||||
|
if(not restoreSettings and 'system_settings' in valFile):
|
||||||
|
# prompt the user to restore settings yes/no
|
||||||
|
restoreSettings = xbmcgui.Dialog().yesno(utils.getString(30149), utils.getString(30150))
|
||||||
|
|
||||||
#use a multiselect dialog to select sets to restore
|
#use a multiselect dialog to select sets to restore
|
||||||
restoreSets = [n['name'] for n in valFile['directories']]
|
restoreSets = [n['name'] for n in valFile['directories']]
|
||||||
|
|
||||||
@@ -313,6 +319,12 @@ class XbmcBackup:
|
|||||||
self.xbmc_vfs.set_root(fileGroup['dest'])
|
self.xbmc_vfs.set_root(fileGroup['dest'])
|
||||||
self._copyFiles(fileGroup['files'],self.remote_vfs,self.xbmc_vfs)
|
self._copyFiles(fileGroup['files'],self.remote_vfs,self.xbmc_vfs)
|
||||||
|
|
||||||
|
# update the Kodi settings - if we can
|
||||||
|
if('system_settings' in valFile and restoreSettings):
|
||||||
|
self.progressBar.updateProgress(98, "Restoring Kodi settings")
|
||||||
|
gui_settings = GuiSettingsManager()
|
||||||
|
gui_settings.restore(valFile['system_settings'])
|
||||||
|
|
||||||
self.progressBar.updateProgress(99,"Clean up operations .....")
|
self.progressBar.updateProgress(99,"Clean up operations .....")
|
||||||
|
|
||||||
if(self.restore_point.split('.')[-1] == 'zip'):
|
if(self.restore_point.split('.')[-1] == 'zip'):
|
||||||
@@ -320,11 +332,6 @@ class XbmcBackup:
|
|||||||
self.xbmc_vfs.rmfile(xbmc.translatePath("special://temp/" + self.restore_point))
|
self.xbmc_vfs.rmfile(xbmc.translatePath("special://temp/" + self.restore_point))
|
||||||
self.xbmc_vfs.rmdir(self.remote_vfs.root_path)
|
self.xbmc_vfs.rmdir(self.remote_vfs.root_path)
|
||||||
|
|
||||||
|
|
||||||
#update the guisettings information (or what we can from it)
|
|
||||||
gui_settings = GuiSettingsManager()
|
|
||||||
gui_settings.run()
|
|
||||||
|
|
||||||
#call update addons to refresh everything
|
#call update addons to refresh everything
|
||||||
xbmc.executebuiltin('UpdateLocalAddons')
|
xbmc.executebuiltin('UpdateLocalAddons')
|
||||||
|
|
||||||
@@ -461,20 +468,24 @@ class XbmcBackup:
|
|||||||
|
|
||||||
if(dirs[remove_num][0].split('.')[-1] == 'zip'):
|
if(dirs[remove_num][0].split('.')[-1] == 'zip'):
|
||||||
#this is a file, remove it that way
|
#this is a file, remove it that way
|
||||||
self.remote_vfs.rmfile(self.remote_base_path + dirs[remove_num][0])
|
self.remote_vfs.rmfile(self.remote_vfs.clean_path(self.remote_base_path) + dirs[remove_num][0])
|
||||||
else:
|
else:
|
||||||
self.remote_vfs.rmdir(self.remote_base_path + dirs[remove_num][0] + "/")
|
self.remote_vfs.rmdir(self.remote_vfs.clean_path(self.remote_base_path) + dirs[remove_num][0] + "/")
|
||||||
|
|
||||||
remove_num = remove_num + 1
|
remove_num = remove_num + 1
|
||||||
|
|
||||||
def _createValidationFile(self,dirList):
|
def _createValidationFile(self,dirList):
|
||||||
valInfo = {"name":"XBMC Backup Validation File","xbmc_version":xbmc.getInfoLabel('System.BuildVersion'),"type":0}
|
valInfo = {"name":"XBMC Backup Validation File","xbmc_version":xbmc.getInfoLabel('System.BuildVersion'),"type":0, "system_settings": []}
|
||||||
valDirs = []
|
valDirs = []
|
||||||
|
|
||||||
for aDir in dirList:
|
for aDir in dirList:
|
||||||
valDirs.append({"name":aDir['name'],"path":aDir['source']})
|
valDirs.append({"name":aDir['name'],"path":aDir['source']})
|
||||||
valInfo['directories'] = valDirs
|
valInfo['directories'] = valDirs
|
||||||
|
|
||||||
|
# dump all current Kodi settings
|
||||||
|
gui_settings = GuiSettingsManager()
|
||||||
|
valInfo['system_settings'] = gui_settings.backup()
|
||||||
|
|
||||||
vFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "xbmcbackup.val"),'w')
|
vFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "xbmcbackup.val"),'w')
|
||||||
vFile.write(json.dumps(valInfo))
|
vFile.write(json.dumps(valInfo))
|
||||||
vFile.write("")
|
vFile.write("")
|
||||||
|
|||||||
@@ -1,73 +1,45 @@
|
|||||||
import json
|
import json
|
||||||
import xbmc,xbmcvfs
|
import xbmc,xbmcvfs
|
||||||
from . import utils as utils
|
from . import utils as utils
|
||||||
from xml.dom import minidom
|
|
||||||
from xml.parsers.expat import ExpatError
|
|
||||||
|
|
||||||
|
|
||||||
class GuiSettingsManager:
|
class GuiSettingsManager:
|
||||||
doc = None
|
systemSettings = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
#first make a copy of the file
|
# get all of the current Kodi settings
|
||||||
xbmcvfs.copy(xbmc.translatePath('special://home/userdata/guisettings.xml'), xbmc.translatePath("special://home/userdata/guisettings.xml.restored"))
|
json_response = json.loads(xbmc.executeJSONRPC('{"jsonrpc":"2.0", "id":1, "method":"Settings.GetSettings","params":{"level":"expert"}}').decode('utf-8', errors="ignore"))
|
||||||
|
|
||||||
#read in the copy
|
self.systemSettings = json_response['result']['settings']
|
||||||
self._readFile(xbmc.translatePath('special://home/userdata/guisettings.xml.restored'))
|
|
||||||
|
|
||||||
def run(self):
|
def backup(self):
|
||||||
#get a list of all the settings we can manipulate via json
|
utils.log('Backing up Kodi settings')
|
||||||
json_response = json.loads(xbmc.executeJSONRPC('{"jsonrpc":"2.0", "id":1, "method":"Settings.GetSettings","params":{"level":"advanced"}}'))
|
|
||||||
|
|
||||||
settings = json_response['result']['settings']
|
# return all current settings
|
||||||
currentSettings = {}
|
return self.systemSettings
|
||||||
|
|
||||||
for aSetting in settings:
|
def restore(self, restoreSettings):
|
||||||
if('value' in aSetting):
|
utils.log('Restoring Kodi settings')
|
||||||
currentSettings[aSetting['id']] = aSetting['value']
|
|
||||||
|
|
||||||
#parse the existing xml file and get all the settings we need to restore
|
updateJson = {"jsonrpc": "2.0", "id": 1, "method": "Settings.SetSettingValue", "params": {"setting": "", "value": ""}}
|
||||||
restoreSettings = self.__parseNodes(self.doc.getElementsByTagName('setting'))
|
|
||||||
|
|
||||||
#get a list where the restore setting value != the current value
|
# create a setting=value dict of the current settings
|
||||||
updateSettings = {k: v for k, v in list(restoreSettings.items()) if (k in currentSettings and currentSettings[k] != v)}
|
settingsDict = {}
|
||||||
|
for aSetting in self.systemSettings:
|
||||||
|
# ignore action types, no value
|
||||||
|
if(aSetting['type'] != 'action'):
|
||||||
|
settingsDict[aSetting['id']] = aSetting['value']
|
||||||
|
|
||||||
#go through all the found settings and update them
|
restoreCount = 0
|
||||||
jsonObj = {"jsonrpc":"2.0","id":1,"method":"Settings.SetSettingValue","params":{"setting":"","value":""}}
|
for aSetting in restoreSettings:
|
||||||
for anId, aValue in list(updateSettings.items()):
|
# only update a setting if its different than the current (action types have no value)
|
||||||
utils.log("updating: " + anId + ", value: " + str(aValue))
|
if(aSetting['type'] != 'action' and settingsDict[aSetting['id']] != aSetting['value']):
|
||||||
|
utils.log('%s different than current: %s' % (aSetting['id'], str(aSetting['value'])), xbmc.LOGDEBUG)
|
||||||
|
|
||||||
jsonObj['params']['setting'] = anId
|
updateJson['params']['setting'] = aSetting['id']
|
||||||
jsonObj['params']['value'] = aValue
|
updateJson['params']['value'] = aSetting['value']
|
||||||
|
|
||||||
xbmc.executeJSONRPC(json.dumps(jsonObj))
|
|
||||||
|
|
||||||
def __parseNodes(self,nodeList):
|
|
||||||
result = {}
|
|
||||||
|
|
||||||
for node in nodeList:
|
|
||||||
nodeValue = ''
|
|
||||||
if(node.firstChild != None):
|
|
||||||
nodeValue = node.firstChild.nodeValue
|
|
||||||
|
|
||||||
#check for numbers and booleans
|
|
||||||
if(nodeValue.isdigit()):
|
|
||||||
nodeValue = int(nodeValue)
|
|
||||||
elif(nodeValue == 'true'):
|
|
||||||
nodeValue = True
|
|
||||||
elif(nodeValue == 'false'):
|
|
||||||
nodeValue = False
|
|
||||||
|
|
||||||
result[node.getAttribute('id')] = nodeValue
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def _readFile(self,fileLoc):
|
|
||||||
|
|
||||||
if(xbmcvfs.exists(fileLoc)):
|
|
||||||
try:
|
|
||||||
self.doc = minidom.parse(fileLoc)
|
|
||||||
except ExpatError:
|
|
||||||
utils.log("Can't read " + fileLoc)
|
|
||||||
|
|
||||||
|
xbmc.executeJSONRPC(json.dumps(updateJson))
|
||||||
|
restoreCount = restoreCount + 1
|
||||||
|
|
||||||
|
utils.log('Update %d settings' % restoreCount)
|
||||||
|
|||||||
@@ -15,16 +15,19 @@ class Vfs:
|
|||||||
def __init__(self,rootString):
|
def __init__(self,rootString):
|
||||||
self.set_root(rootString)
|
self.set_root(rootString)
|
||||||
|
|
||||||
|
def clean_path(self, path):
|
||||||
|
# fix slashes
|
||||||
|
path = path.replace("\\", "/")
|
||||||
|
|
||||||
|
# check if trailing slash is included
|
||||||
|
if(path[-1:] != '/'):
|
||||||
|
path = path + '/'
|
||||||
|
|
||||||
|
return path
|
||||||
|
|
||||||
def set_root(self,rootString):
|
def set_root(self,rootString):
|
||||||
old_root = self.root_path
|
old_root = self.root_path
|
||||||
self.root_path = rootString
|
self.root_path = self.clean_path(rootString)
|
||||||
|
|
||||||
#fix slashes
|
|
||||||
self.root_path = self.root_path.replace("\\","/")
|
|
||||||
|
|
||||||
#check if trailing slash is included
|
|
||||||
if(self.root_path[-1:] != "/"):
|
|
||||||
self.root_path = self.root_path + "/"
|
|
||||||
|
|
||||||
#return the old root
|
#return the old root
|
||||||
return old_root
|
return old_root
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<category id="general" label="30011">
|
<category id="general" label="30011">
|
||||||
<setting id="compress_backups" type="bool" label="30087" default="false" />
|
<setting id="compress_backups" type="bool" label="30087" default="false" />
|
||||||
<setting id="backup_rotation" type="number" label="30026" default="0" />
|
<setting id="backup_rotation" type="number" label="30026" default="0" />
|
||||||
|
<setting id="always_prompt_restore_settings" type="bool" label="30148" default="false" />
|
||||||
<setting id="progress_mode" type="enum" label="30022" lvalues="30082|30083|30084" default="0" />
|
<setting id="progress_mode" type="enum" label="30022" lvalues="30082|30083|30084" default="0" />
|
||||||
<setting id="upgrade_notes" type="number" label="upgrade_notes" visible="false" default="1" />
|
<setting id="upgrade_notes" type="number" label="upgrade_notes" visible="false" default="1" />
|
||||||
</category>
|
</category>
|
||||||
|
|||||||