]> xmof Git - DeDRM.git/commitdiff
Fix python2 issues in Kindle and Nook code (#355)
authorNoDRM <no_drm123@protonmail.com>
Sat, 24 Jun 2023 07:53:55 +0000 (09:53 +0200)
committerNoDRM <no_drm123@protonmail.com>
Sat, 24 Jun 2023 07:53:55 +0000 (09:53 +0200)
CHANGELOG.md
DeDRM_plugin/ignoblekeyNookStudy.py
DeDRM_plugin/kindlekey.py
DeDRM_plugin/topazextract.py

index cdb0d6d97c8208b5840dc3b1f24254907b1bb996..cb0ecbcd9b27f8aa925596839b6c09f15184ad4d 100644 (file)
@@ -91,3 +91,4 @@ List of changes since the fork of Apprentice Harper's repository:
 - Support for Adobe's 'aes128-cbc-uncompressed' encryption method (fixes #242).
 - Two bugfixes for Amazon DeDRM from Satuoni ( https://github.com/noDRM/DeDRM_tools/issues/315#issuecomment-1508305428 ) and andrewc12 ( https://github.com/andrewc12/DeDRM_tools/commit/d9233d61f00d4484235863969919059f4d0b2057 ) that might make the plugin work with newer versions.
 - Fix font decryption not working with some books (fixes #347), thanks for the patch @bydioeds. 
+- Fix a couple unicode errors for Python2 in Kindle and Nook code.
index 6a5f1cfcc492f2d451ed741a594f41815fe70118..4cf524691d9b7644cfc251b44278d65d48de642b 100644 (file)
@@ -54,15 +54,26 @@ def getNookLogFiles():
         paths = set()
         if 'LOCALAPPDATA' in os.environ.keys():
             # Python 2.x does not return unicode env. Use Python 3.x
-            path = winreg.ExpandEnvironmentStrings("%LOCALAPPDATA%")
+            if sys.version_info[0] == 2:
+                path = winreg.ExpandEnvironmentStrings(u"%LOCALAPPDATA%")
+            else:
+                path = winreg.ExpandEnvironmentStrings("%LOCALAPPDATA%")
             if os.path.isdir(path):
                 paths.add(path)
         if 'USERPROFILE' in os.environ.keys():
             # Python 2.x does not return unicode env. Use Python 3.x
-            path = winreg.ExpandEnvironmentStrings("%USERPROFILE%")+"\\AppData\\Local"
+            if sys.version_info[0] == 2:
+                path = winreg.ExpandEnvironmentStrings(u"%USERPROFILE%")+u"\\AppData\\Local"
+            else:
+                path = winreg.ExpandEnvironmentStrings("%USERPROFILE%")+"\\AppData\\Local"
+
             if os.path.isdir(path):
                 paths.add(path)
-            path = winreg.ExpandEnvironmentStrings("%USERPROFILE%")+"\\AppData\\Roaming"
+
+            if sys.version_info[0] == 2:  
+                path = winreg.ExpandEnvironmentStrings(u"%USERPROFILE%")+u"\\AppData\\Roaming"
+            else:
+                path = winreg.ExpandEnvironmentStrings("%USERPROFILE%")+"\\AppData\\Roaming"
             if os.path.isdir(path):
                 paths.add(path)
         # User Shell Folders show take precedent over Shell Folders if present
index 60a6065d5c752752ee5516d52d14c6edb70c553f..14e4ed187d15bf1a820e33596747439a44b7dcd5 100644 (file)
@@ -279,7 +279,10 @@ if iswindows:
         path = ""
         if 'LOCALAPPDATA' in os.environ.keys():
             # Python 2.x does not return unicode env. Use Python 3.x
-            path = winreg.ExpandEnvironmentStrings("%LOCALAPPDATA%")
+            if sys.version_info[0] == 2:
+                path = winreg.ExpandEnvironmentStrings(u"%LOCALAPPDATA%")
+            else:
+                path = winreg.ExpandEnvironmentStrings("%LOCALAPPDATA%")
             # this is just another alternative.
             # path = getEnvironmentVariable('LOCALAPPDATA')
             if not os.path.isdir(path):
index 1eaa2a57c1a604eec9066d8f189eb482aa5b73a3..8848bd9a829b0111266fe5fac1cebe8e079ba0a0 100644 (file)
@@ -1,6 +1,8 @@
 #!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 
+from __future__ import print_function
+
 # topazextract.py
 # Mostly written by some_updates based on code from many others