Esempio n. 1
0
    def processBook(self, totalpids):
        with zipfile.ZipFile(self.infile, 'r') as zf:
            for filename in zf.namelist():
                with zf.open(filename) as fh:
                    data = fh.read(8)
                    if data != '\xeaDRMION\xee':
                        continue
                    data += fh.read()
                    if self.voucher is None:
                        self.decrypt_voucher(totalpids)
                    print(u'Decrypting KFX DRMION: {0}'.format(filename))
                    outfile = io.BytesIO()
                    ion.DrmIon(io.BytesIO(data[8:-8]), lambda name: self.voucher).parse(outfile)
                    self.decrypted[filename] = outfile.getvalue()

        if not self.decrypted:
            print(u'The .kfx-zip archive does not contain an encrypted DRMION file')
Esempio n. 2
0
    def processBook(self, totalpids):
        with zipfile.ZipFile(self.infile, 'r') as zf:
            for filename in zf.namelist():
                data = zf.read(filename)
                if data.startswith('\xeaDRMION\xee'):
                    if self.voucher is None:
                        self.decrypt_voucher(totalpids)
                    print u'Decrypting KFX DRMION: {0}'.format(filename)
                    outfile = StringIO()
                    ion.DrmIon(StringIO(data[8:-8]),
                               lambda name: self.voucher).parse(outfile)
                    self.decrypted[filename] = outfile.getvalue()

        if not self.decrypted:
            print(
                u'The .kfx-zip archive does not contain an encrypted DRMION file'
            )