Merge pull request #38 from robweber/profiles

added support for userdata/profiles folder
This commit is contained in:
robweber 2013-10-21 07:00:09 -07:00
commit 4962a9c63b
5 changed files with 30 additions and 15 deletions

View File

@ -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="XBMC Backup" version="0.4.1" provider-name="robweber"> name="XBMC Backup" version="0.4.2" provider-name="robweber">
<requires> <requires>
<import addon="xbmc.python" version="2.1.0"/> <import addon="xbmc.python" version="2.1.0"/>
</requires> </requires>

View File

@ -1,3 +1,7 @@
Version 0.4.2
Added support for userdata/profiles folder - thanks TUSSFC
Version 0.4.1 Version 0.4.1
added encode() around notifications added encode() around notifications

View File

@ -71,4 +71,5 @@
<string id="30077">Restart XBMC</string> <string id="30077">Restart XBMC</string>
<string id="30078">You should restart XBMC to continue</string> <string id="30078">You should restart XBMC to continue</string>
<string id="30079">Just Today</string> <string id="30079">Just Today</string>
<string id="30080">Profiles</string>
</strings> </strings>

View File

@ -119,7 +119,11 @@ class XbmcBackup:
if(utils.getSetting("backup_playlists") == 'true'): if(utils.getSetting("backup_playlists") == 'true'):
self.remote_vfs.mkdir(self.remote_vfs.root_path + "userdata/playlists") self.remote_vfs.mkdir(self.remote_vfs.root_path + "userdata/playlists")
fileManager.walkTree(xbmc.translatePath('special://home/userdata/playlists')) fileManager.walkTree(xbmc.translatePath('special://home/userdata/playlists'))
if(utils.getSetting('backup_profiles') == 'true'):
self.remote_vfs.mkdir(self.remote_vfs.root_path + "userdata/profiles")
fileManager.walkTree(xbmc.translatePath('special://home/userdata/profiles'))
if(utils.getSetting("backup_thumbnails") == "true"): if(utils.getSetting("backup_thumbnails") == "true"):
self.remote_vfs.mkdir(self.remote_vfs.root_path + "userdata/Thumbnails") self.remote_vfs.mkdir(self.remote_vfs.root_path + "userdata/Thumbnails")
fileManager.walkTree(xbmc.translatePath('special://home/userdata/Thumbnails')) fileManager.walkTree(xbmc.translatePath('special://home/userdata/Thumbnails'))
@ -237,6 +241,10 @@ class XbmcBackup:
if(utils.getSetting("backup_playlists") == 'true'): if(utils.getSetting("backup_playlists") == 'true'):
self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata/playlists')) self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata/playlists'))
fileManager.walkTree(self.remote_vfs.root_path + "userdata/playlists") fileManager.walkTree(self.remote_vfs.root_path + "userdata/playlists")
if(utils.getSetting('backup_profiles') == 'true'):
self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata/profiles'))
fileManager.walkTree(self.remote_vfs.root_path + "userdata/profiles")
if(utils.getSetting("backup_thumbnails") == "true"): if(utils.getSetting("backup_thumbnails") == "true"):
self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata/Thumbnails')) self.xbmc_vfs.mkdir(xbmc.translatePath('special://home/userdata/Thumbnails'))
@ -371,21 +379,22 @@ class FileManager:
self.vfs = vfs self.vfs = vfs
def walkTree(self,directory): def walkTree(self,directory):
dirs,files = self.vfs.listdir(directory) if(self.vfs.exists(directory)):
dirs,files = self.vfs.listdir(directory)
#create all the subdirs first #create all the subdirs first
for aDir in dirs: for aDir in dirs:
dirPath = xbmc.translatePath(directory + "/" + aDir) dirPath = xbmc.translatePath(directory + "/" + aDir)
file_ext = aDir.split('.')[-1] file_ext = aDir.split('.')[-1]
self.addFile("-" + dirPath) self.addFile("-" + dirPath)
#catch for "non directory" type files #catch for "non directory" type files
if (not any(file_ext in s for s in self.not_dir)): if (not any(file_ext in s for s in self.not_dir)):
self.walkTree(dirPath) self.walkTree(dirPath)
#copy all the files #copy all the files
for aFile in files: for aFile in files:
filePath = xbmc.translatePath(directory + "/" + aFile) filePath = xbmc.translatePath(directory + "/" + aFile)
self.addFile(filePath) self.addFile(filePath)
def addFile(self,filename): def addFile(self,filename):
try: try:

View File

@ -14,6 +14,7 @@
<setting id="backup_addon_data" type="bool" label="30031" default="false" /> <setting id="backup_addon_data" type="bool" label="30031" default="false" />
<setting id="backup_database" type="bool" label="30032" default="true" /> <setting id="backup_database" type="bool" label="30032" default="true" />
<setting id="backup_playlists" type="bool" label="30033" default="true" /> <setting id="backup_playlists" type="bool" label="30033" default="true" />
<setting id="backup_profiles" type="bool" label="30080" default="false" />
<setting id="backup_thumbnails" type="bool" label="30034" default="true" /> <setting id="backup_thumbnails" type="bool" label="30034" default="true" />
<setting id="backup_config" type="bool" label="30035" default="true" /> <setting id="backup_config" type="bool" label="30035" default="true" />
<setting id="custom_dir_1_enable" type="bool" label="30036" default="false" /> <setting id="custom_dir_1_enable" type="bool" label="30036" default="false" />