]> xmof Git - DeDRM.git/commitdiff
encode serialnum before returning it, close #1479
authorxxyzz <gitpull@protonmail.com>
Wed, 27 Jan 2021 06:31:05 +0000 (14:31 +0800)
committerxxyzz <gitpull@protonmail.com>
Wed, 27 Jan 2021 06:31:05 +0000 (14:31 +0800)
DeDRM_plugin/kgenpids.py

index 98002547bdff58580e973da1631a0241ba890dca..103b77b222bd2a1e8328eab24f95f235586ca076 100644 (file)
@@ -174,14 +174,14 @@ def pidFromSerial(s, l):
 
 # Parse the EXTH header records and use the Kindle serial number to calculate the book pid.
 def getKindlePids(rec209, token, serialnum):
+    if isinstance(serialnum,str):
+        serialnum = serialnum.encode('utf-8')
+
     if rec209 is None:
         return [serialnum]
 
     pids=[]
 
-    if isinstance(serialnum,str):
-        serialnum = serialnum.encode('utf-8')
-
     # Compute book PID
     pidHash = SHA1(serialnum+rec209+token)
     bookPID = encodePID(pidHash)