From 48cb1d313802dd13dd754dea60227716bbc90b34 Mon Sep 17 00:00:00 2001 From: Timothy Legge Date: Wed, 22 Sep 2010 21:45:44 -0300 Subject: [PATCH 1/4] Fix 6902 - If Title is None set to Unknown --- src/calibre/devices/kobo/books.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/calibre/devices/kobo/books.py b/src/calibre/devices/kobo/books.py index 496162d668..5724efc4ec 100644 --- a/src/calibre/devices/kobo/books.py +++ b/src/calibre/devices/kobo/books.py @@ -41,6 +41,10 @@ class Book(MetaInformation): self.authors = [''] else: self.authors = [authors] + + if not title: + self.title = 'Unknown' + self.mime = mime self.size = size # will be set later if None From cee9c6e6dbe17eff8a7420cc2ba696cabfee552d Mon Sep 17 00:00:00 2001 From: GRiker Date: Thu, 23 Sep 2010 06:35:13 -0700 Subject: [PATCH 2/4] GwR fix regression with NCX encoding #6797 --- src/calibre/ebooks/mobi/writer.py | 48 +++++++++---------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/src/calibre/ebooks/mobi/writer.py b/src/calibre/ebooks/mobi/writer.py index 23f92d1fd2..80c1bf74eb 100644 --- a/src/calibre/ebooks/mobi/writer.py +++ b/src/calibre/ebooks/mobi/writer.py @@ -1574,15 +1574,14 @@ class MobiWriter(object): id = unicode(oeb.metadata.cover[0]) item = oeb.manifest.ids[id] href = item.href - if href in self._images: - index = self._images[href] - 1 - exth.write(pack('>III', 0xc9, 0x0c, index)) - exth.write(pack('>III', 0xcb, 0x0c, 0)) - nrecs += 2 - index = self._add_thumbnail(item) - if index is not None: - exth.write(pack('>III', 0xca, 0x0c, index - 1)) - nrecs += 1 + index = self._images[href] - 1 + exth.write(pack('>III', 0xc9, 0x0c, index)) + exth.write(pack('>III', 0xcb, 0x0c, 0)) + nrecs += 2 + index = self._add_thumbnail(item) + if index is not None: + exth.write(pack('>III', 0xca, 0x0c, index - 1)) + nrecs += 1 exth = exth.getvalue() trail = len(exth) % 4 @@ -1696,11 +1695,12 @@ class MobiWriter(object): header.write(pack('>I', 1)) # 0x1c - 0x1f : Text encoding ? - # GR: Language encoding for NCX entries (latin_1) - header.write(pack('>I', 0x4e4)) + # header.write(pack('>I', 650001)) + # GR: This needs to be either 0xFDE9 or 0x4E4 + header.write(pack('>I', 0xFDE9)) - # 0x20 - 0x23 : Mimicking kindleGen - header.write(pack('>I', 0xFFFFFFFF)) + # 0x20 - 0x23 : Language code? + header.write(iana2mobi(str(self._oeb.metadata.language[0]))) # 0x24 - 0x27 : Number of TOC entries in INDX1 header.write(pack('>I', indxt_count + 1)) @@ -1800,7 +1800,7 @@ class MobiWriter(object): text = text.strip() if not isinstance(text, unicode): text = text.decode('utf-8', 'replace') - text = text.encode('cp1252','replace') + text = text.encode('ascii','replace') return text def _add_to_ctoc(self, ctoc_str, record_offset): @@ -2150,26 +2150,6 @@ class MobiWriter(object): indxt.write(decint(self._ctoc_map[index]['titleOffset'], DECINT_FORWARD)) # vwi title offset in CNCX indxt.write(decint(0, DECINT_FORWARD)) # unknown byte - def _write_subchapter_node(self, indxt, indices, index, offset, length, count): - # This style works without a parent chapter, mimicking what KindleGen does, - # using a value of 0x0B for parentIndex - # Writes an INDX1 NCXEntry of entryType 0x1F - subchapter - if self.opts.verbose > 2: - # *** GR: Turn this off while I'm developing my code - #self._oeb.log.debug('Writing TOC node to IDXT:', node.title, 'href:', node.href) - pass - - pos = 0xc0 + indxt.tell() - indices.write(pack('>H', pos)) # Save the offset for IDXTIndices - name = "%04X"%count - indxt.write(chr(len(name)) + name) # Write the name - indxt.write(INDXT['subchapter']) # entryType [0x0F | 0xDF | 0xFF | 0x3F] - indxt.write(decint(offset, DECINT_FORWARD)) # offset - indxt.write(decint(length, DECINT_FORWARD)) # length - indxt.write(decint(self._ctoc_map[index]['titleOffset'], DECINT_FORWARD)) # vwi title offset in CNCX - indxt.write(decint(0, DECINT_FORWARD)) # unknown byte - indxt.write(decint(0xb, DECINT_FORWARD)) # parentIndex - null - def _compute_offset_length(self, i, node, entries) : h = node.href if h not in self._id_offsets: From e41a54c1d70b418f25fe6592a56bcfd68ea4ea9e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 23 Sep 2010 08:31:27 -0600 Subject: [PATCH 3/4] Neal's Nuze by Tony Stegall. Fixes #6917 (Recipe for Neal's Nuze) --- resources/images/news/boortz.png | Bin 0 -> 652 bytes resources/recipes/boortz.recipe | 43 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 resources/images/news/boortz.png create mode 100644 resources/recipes/boortz.recipe diff --git a/resources/images/news/boortz.png b/resources/images/news/boortz.png new file mode 100644 index 0000000000000000000000000000000000000000..ac806e805679606e8d5afc008d13f94e74a640d2 GIT binary patch literal 652 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b zK-vS0-A-oPfdtD69Mgd`SU*F|v9*U87#O#Dx;TbdoL)M4qjz+m$gz4hQTFD}e8Y|z z5AHZFX_{=P5Wy{*)V623VWZO7Yl?r_xwvHK?@-x&*mQzZw}Q$|mZi=wa_0Az^|(D! zD7BD%w0rM*H}>DU;^%gL-~GJixwW&B(jWG=|GY8t=NImLd`UZ8E{0G1lgc(b)+FaN z*8Q`1t!8f7XS3^@R73t;???IEQ{0X*+_1JwN>aO5uk!uHHrvcdK_J?haV1qC%j@K= zD^qSnx*s<=*ng?o_rfNnOS#qllden=5}Y_8zHWVtV$6xnTX*ptIRCR!#=1TEIYYr4 zne|DA4BOu4RTdVpIGlJdoA4<%@H_v9haa@V&sz1(eY`3%{c>sPJ#kBx55FIHJKTJ) zKfOftcKLP&m&uyb#KkK%Z(MkEubsVeirtk{_YQ~ueVo&iqvl&y*m?f<@1FCj3_C2p z{$f#E+?iqInwioQxARbw>B(iUH%03d6~AIMu$%ruct(%frZ#n}nI_e%yi8_Z()B-c z Date: Thu, 23 Sep 2010 08:45:37 -0600 Subject: [PATCH 4/4] Database: Fix regression that caused has_cover to create empty directories unneccessarily --- src/calibre/library/database2.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 627ab6358b..9c0397e21e 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -358,10 +358,10 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): return row[self.FIELD_MAP['path']].replace('/', os.sep) - def abspath(self, index, index_is_id=False): + def abspath(self, index, index_is_id=False, create_dirs=True): 'Return the absolute path to the directory containing this books files as a unicode string.' path = os.path.join(self.library_path, self.path(index, index_is_id=index_is_id)) - if not os.path.exists(path): + if create_dirs and not os.path.exists(path): os.makedirs(path) return path @@ -597,7 +597,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): def has_cover(self, index, index_is_id=False): id = index if index_is_id else self.id(index) try: - path = os.path.join(self.abspath(id, index_is_id=True), 'cover.jpg') + path = os.path.join(self.abspath(id, index_is_id=True, + create_dirs=False), 'cover.jpg') except: # Can happen if path has not yet been set return False