示例#1
0
 def processBook(self, pidlst):
     raw = 0
     fixedimage = True
     try:
         keydata = self.getBookPayloadRecord('dkey', 0)
     except TpzDRMError, e:
         print "no dkey record found, book may not be encrypted"
         print "attempting to extrct files without a book key"
         self.createBookDirectory()
         self.extractFiles()
         print "Successfully Extracted Topaz contents"
         rv = genbook.generateBook(self.outdir, raw, fixedimage)
         if rv == 0:
             print "\nBook Successfully generated"
         return rv
示例#2
0
 def processBook(self, pidlst):
     raw = 0
     fixedimage=True
     try:
         keydata = self.getBookPayloadRecord('dkey', 0)
     except TpzDRMError, e:
         print "no dkey record found, book may not be encrypted"
         print "attempting to extrct files without a book key"
         self.createBookDirectory()
         self.extractFiles()
         print "Successfully Extracted Topaz contents"
         rv = genbook.generateBook(self.outdir, raw, fixedimage)
         if rv == 0:
             print "\nBook Successfully generated"
         return rv            
示例#3
0
    def processBook(self, pidlst):
        raw = 0
        fixedimage=True
        try:
            keydata = self.getBookPayloadRecord('dkey', 0)
        except DrmException, e:
            print u"no dkey record found, book may not be encrypted"
            print u"attempting to extrct files without a book key"
            self.createBookDirectory()
            self.extractFiles()
            print u"Successfully Extracted Topaz contents"
            if inCalibre:
                from calibre_plugins.k4mobidedrm import genbook
            else:
                import genbook

            rv = genbook.generateBook(self.outdir, raw, fixedimage)
            if rv == 0:
                print u"Book Successfully generated."
            return rv
                print "Book Key Found!"
                break

        if not bookKey:
            raise TpzDRMError("Topaz Book. No key found in " + str(len(pidlst)) + " keys tried. Read the FAQs at Alf's blog. Only if none apply, report this failure for help.")

        self.setBookKey(bookKey)
        self.createBookDirectory()
        self.extractFiles()
        print "Successfully Extracted Topaz contents"
        if inCalibre:
            from calibre_plugins.k4mobidedrm import genbook
        else:
            import genbook

        rv = genbook.generateBook(self.outdir, raw, fixedimage)
        if rv == 0:
            print "\nBook Successfully generated"
        return rv

    def createBookDirectory(self):
        outdir = self.outdir
        # create output directory structure
        if not os.path.exists(outdir):
            os.makedirs(outdir)
        destdir =  os.path.join(outdir,'img')
        if not os.path.exists(destdir):
            os.makedirs(destdir)
        destdir =  os.path.join(outdir,'color_img')
        if not os.path.exists(destdir):
            os.makedirs(destdir)
示例#5
0
                bookKeys += decryptDkeyRecords(data, pid)
            except TpzDRMError, e:
                pass
            else:
                bookKey = bookKeys[0]
                print "Book Key Found!"
                break

        if not bookKey:
            raise TpzDRMError('Decryption Unsucessful; No valid pid found')

        self.setBookKey(bookKey)
        self.createBookDirectory()
        self.extractFiles()
        print "Successfully Extracted Topaz contents"
        rv = genbook.generateBook(self.outdir, raw, fixedimage)
        if rv == 0:
            print "\nBook Successfully generated"
        return rv

    def createBookDirectory(self):
        outdir = self.outdir
        # create output directory structure
        if not os.path.exists(outdir):
            os.makedirs(outdir)
        destdir = os.path.join(outdir, 'img')
        if not os.path.exists(destdir):
            os.makedirs(destdir)
        destdir = os.path.join(outdir, 'color_img')
        if not os.path.exists(destdir):
            os.makedirs(destdir)