mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
RB input: Support uncompressed text.
This commit is contained in:
parent
503b697653
commit
9f54a396d6
@ -70,12 +70,13 @@ class Reader(object):
|
|||||||
return toc
|
return toc
|
||||||
|
|
||||||
def get_text(self, toc_item, output_dir):
|
def get_text(self, toc_item, output_dir):
|
||||||
if toc_item.flags != 8:
|
if toc_item.flags in (1, 2):
|
||||||
return
|
return
|
||||||
|
|
||||||
output = u''
|
output = u''
|
||||||
|
|
||||||
self.stream.seek(toc_item.offset)
|
self.stream.seek(toc_item.offset)
|
||||||
|
|
||||||
|
if toc_item.flags == 8:
|
||||||
count = self.read_i32()
|
count = self.read_i32()
|
||||||
self.read_i32() # Uncompressed size.
|
self.read_i32() # Uncompressed size.
|
||||||
chunck_sizes = []
|
chunck_sizes = []
|
||||||
@ -85,6 +86,8 @@ class Reader(object):
|
|||||||
for size in chunck_sizes:
|
for size in chunck_sizes:
|
||||||
cm_chunck = self.stream.read(size)
|
cm_chunck = self.stream.read(size)
|
||||||
output += zlib.decompress(cm_chunck).decode('cp1252' if self.encoding is None else self.encoding)
|
output += zlib.decompress(cm_chunck).decode('cp1252' if self.encoding is None else self.encoding)
|
||||||
|
else:
|
||||||
|
output += self.stream.read(toc_item.size).decode('cp1252' if self.encoding is None else self.encoding)
|
||||||
|
|
||||||
with open(os.path.join(output_dir, toc_item.name), 'wb') as html:
|
with open(os.path.join(output_dir, toc_item.name), 'wb') as html:
|
||||||
html.write(output.encode('utf-8'))
|
html.write(output.encode('utf-8'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user