'Decrypt Kobo book
:param book: obok file object'

def decryptBook(self, book):

    result = {}
    result[u'success'] = False
    result[u'fileobj'] = None
    zin = zipfile.ZipFile(book.filename, u'r')
    for userkey in self.userkeys:
        print(_(u'Trying    key:    '), userkey.encode(u'hex_codec'))
        check = True
        try:
            fileout = PersistentTemporaryFile(u'.epub', dir=self.tdir)
            zout = zipfile.ZipFile(fileout.name, u'w', zipfile.ZIP_DEFLATED)
            members = zin.namelist()
            try:
                members.remove(u'mimetype')
            except Exception:
                pass
            zout.writestr(u'mimetype', u'application/epub+zip', zipfile.ZIP_STORED)
            for filename in members:
                contents = zin.read(filename)
                if (filename in book.encryptedfiles):
                    file = book.encryptedfiles[filename]
                    contents = file.decrypt(userkey, contents)
                    if check:
                        check = (not file.check(contents))
                zout.writestr(filename, contents)
            zout.close()
            zin.close()
            result[u'success'] = True
            result[u'fileobj'] = fileout
            print(u'Success!')
            return result
        except ValueError:
            print(_(u'Decryption    failed,    trying    next    key.'))
            zout.close()
            continue
        except Exception:
            print(_(u'Unknown    Error    decrypting,    trying    next    key..'))
            zout.close()
            continue
    result[u'fileobj'] = book.filename
    zin.close()
    return result
