Fix for Kindle problem in Mac app and non-ascii username problem in Windows (plugin and app).

This commit is contained in:
Apprentice Harper
2015-03-25 07:26:33 +00:00
committed by Apprentice Alf
parent 9d9c879413
commit e729ae8904
20 changed files with 97 additions and 683 deletions

View File

@@ -2,6 +2,13 @@
# -*- coding: utf-8 -*-
from __future__ import with_statement
# kgenpids.py
# Copyright © 2010-2015 by some_updates, Apprentice Alf and Apprentice Harper
# Revision history:
# 2.0 - Fix for non-ascii Windows user names
import sys
import os, csv
import binascii
@@ -164,7 +171,7 @@ def getKindlePids(rec209, token, serialnum):
pids=[]
if isinstance(serialnum,unicode):
serialnum = serialnum.encode('ascii')
serialnum = serialnum.encode('utf-8')
# Compute book PID
pidHash = SHA1(serialnum+rec209+token)
@@ -190,16 +197,16 @@ def getK4Pids(rec209, token, kindleDatabase):
try:
# Get the Mazama Random number
MazamaRandomNumber = (kindleDatabase[1])['MazamaRandomNumber'].decode('hex').encode('ascii')
MazamaRandomNumber = (kindleDatabase[1])['MazamaRandomNumber'].decode('hex')
# Get the kindle account token
kindleAccountToken = (kindleDatabase[1])['kindle.account.tokens'].decode('hex').encode('ascii')
kindleAccountToken = (kindleDatabase[1])['kindle.account.tokens'].decode('hex')
# Get the IDString used to decode the Kindle Info file
IDString = (kindleDatabase[1])['IDString'].decode('hex').encode('ascii')
IDString = (kindleDatabase[1])['IDString'].decode('hex')
# Get the UserName stored when the Kindle Info file was decoded
UserName = (kindleDatabase[1])['UserName'].decode('hex').encode('ascii')
UserName = (kindleDatabase[1])['UserName'].decode('hex')
except KeyError:
print u"Keys not found in the database {0}.".format(kindleDatabase[0])