mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge lit2oeb fixes from llasram
This commit is contained in:
commit
ca20f6c4e4
@ -643,11 +643,14 @@ class LitReader(object):
|
|||||||
self.drmlevel = 1
|
self.drmlevel = 1
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
if self.drmlevel < 5:
|
||||||
msdes.deskey(self._calculate_deskey(), msdes.DE1)
|
msdes.deskey(self._calculate_deskey(), msdes.DE1)
|
||||||
bookkey = msdes.des(self.get_file('/DRMStorage/DRMSealed'))
|
bookkey = msdes.des(self.get_file('/DRMStorage/DRMSealed'))
|
||||||
if bookkey[0] != '\000':
|
if bookkey[0] != '\000':
|
||||||
raise LitError('Unable to decrypt title key!')
|
raise LitError('Unable to decrypt title key!')
|
||||||
self.bookkey = bookkey[1:9]
|
self.bookkey = bookkey[1:9]
|
||||||
|
else:
|
||||||
|
raise LitError('Cannot extract content from a DRM protected ebook')
|
||||||
|
|
||||||
def _calculate_deskey(self):
|
def _calculate_deskey(self):
|
||||||
hashfiles = ['/meta', '/DRMStorage/DRMSource']
|
hashfiles = ['/meta', '/DRMStorage/DRMSource']
|
||||||
@ -710,8 +713,6 @@ class LitReader(object):
|
|||||||
return content
|
return content
|
||||||
|
|
||||||
def _decrypt(self, content):
|
def _decrypt(self, content):
|
||||||
if self.drmlevel == 5:
|
|
||||||
raise LitError('Cannot extract content from a DRM protected ebook')
|
|
||||||
msdes.deskey(self.bookkey, msdes.DE1)
|
msdes.deskey(self.bookkey, msdes.DE1)
|
||||||
return msdes.des(content)
|
return msdes.des(content)
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import cStringIO
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
import uuid
|
|
||||||
'''Read/Write metadata from Open Packaging Format (.opf) files.'''
|
'''Read/Write metadata from Open Packaging Format (.opf) files.'''
|
||||||
|
|
||||||
import sys, re, os, glob
|
import sys, re, os, glob
|
||||||
|
import cStringIO
|
||||||
|
import uuid
|
||||||
|
from urllib import unquote, quote
|
||||||
|
|
||||||
from calibre import __appname__
|
from calibre import __appname__
|
||||||
from calibre.ebooks.metadata import MetaInformation
|
from calibre.ebooks.metadata import MetaInformation
|
||||||
@ -25,7 +26,10 @@ class ManifestItem(Resource):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def from_opf_manifest_item(item, basedir):
|
def from_opf_manifest_item(item, basedir):
|
||||||
if item.has_key('href'):
|
if item.has_key('href'):
|
||||||
res = ManifestItem(item['href'], basedir=basedir, is_path=False)
|
href = item['href']
|
||||||
|
if unquote(href) == href:
|
||||||
|
href = quote(href)
|
||||||
|
res = ManifestItem(href, basedir=basedir, is_path=False)
|
||||||
mt = item.get('media-type', '').strip()
|
mt = item.get('media-type', '').strip()
|
||||||
if mt:
|
if mt:
|
||||||
res.mime_type = mt
|
res.mime_type = mt
|
||||||
|
Loading…
x
Reference in New Issue
Block a user