From 018a1a1e82043991ce2922946784cbfd1e614fba Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Tue, 11 Dec 2012 13:39:13 -0600 Subject: [PATCH] added multiple encoding try/except block --- addon.xml | 2 +- changelog.txt | 4 ++++ resources/lib/backup.py | 10 +++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/addon.xml b/addon.xml index a771abc..2123d24 100644 --- a/addon.xml +++ b/addon.xml @@ -1,6 +1,6 @@  + name="XBMC Backup" version="0.3.1" provider-name="robweber"> diff --git a/changelog.txt b/changelog.txt index d18fbd2..ad8af4f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +Version 0.3.1 + +added try/except for multiple character encodings + Version 0.3.0 major vfs rewrite diff --git a/resources/lib/backup.py b/resources/lib/backup.py index d59e982..a798ad3 100644 --- a/resources/lib/backup.py +++ b/resources/lib/backup.py @@ -62,8 +62,7 @@ class FileManager: for aDir in dirs: dirPath = xbmc.translatePath(directory + "/" + aDir) file_ext = aDir.split('.')[-1] - - self.addFile("-" + dirPath[len(self.vfs.root_path):].decode("UTF-8")) + self.addFile("-" + dirPath[len(self.vfs.root_path):]) #catch for "non directory" type files if (not any(file_ext in s for s in self.not_dir)): self.walkTree(dirPath) @@ -71,9 +70,14 @@ class FileManager: #copy all the files for aFile in files: filePath = xbmc.translatePath(directory + "/" + aFile) - self.addFile(filePath[len(self.vfs.root_path):].decode("UTF-8")) + self.addFile(filePath[len(self.vfs.root_path):]) def addFile(self,filename): + try: + filename = filename.decode('UTF-8') + except UnicodeDecodeError: + filename = filename.decode('ISO-8859-2') + #write the full remote path name of this file utils.log("Add File: " + filename,xbmc.LOGDEBUG) self.fileArray.append(filename)