diff --git a/src/calibre/ebooks/mobi/output.py b/src/calibre/ebooks/mobi/output.py index 2035df261a..c8fe87a161 100644 --- a/src/calibre/ebooks/mobi/output.py +++ b/src/calibre/ebooks/mobi/output.py @@ -40,7 +40,7 @@ class MOBIOutput(OutputFormatPlugin): def check_for_periodical(self): if self.oeb.metadata.publication_type and \ - self.oeb.metadata.publication_type[0].startswith('periodical:'): + unicode(self.oeb.metadata.publication_type[0]).startswith('periodical:'): self.periodicalize_toc() self.check_for_masthead() self.opts.mobi_periodical = True @@ -54,7 +54,7 @@ class MOBIOutput(OutputFormatPlugin): found = True break if not found: - self.oeb.debug('No masthead found, generating default one...') + self.oeb.log.debug('No masthead found, generating default one...') from calibre.resources import server_resources try: from PIL import Image as PILImage @@ -84,12 +84,16 @@ class MOBIOutput(OutputFormatPlugin): sections[0].append(x) else: sections = list(toc) + for x in sections: + x.klass = 'section' for sec in sections: articles[id(sec)] = [] for a in list(sec): + a.klass = 'article' articles[id(sec)].append(a) sec.nodes.remove(a) - root = TOC(klass='periodical', title=self.oeb.metadata.title[0]) + root = TOC(klass='periodical', + title=unicode(self.oeb.metadata.title[0])) for s in sections: if articles[id(s)]: for a in articles[id(s)]: diff --git a/src/calibre/ebooks/mobi/writer.py b/src/calibre/ebooks/mobi/writer.py index 7e5bb77460..b8b5c8f796 100644 --- a/src/calibre/ebooks/mobi/writer.py +++ b/src/calibre/ebooks/mobi/writer.py @@ -1820,7 +1820,6 @@ class MobiWriter(object): # Process 'periodical', 'section' and 'article' if node.klass is None : return - t = node.title if title is None else title t = self._clean_text_value(t) self._last_toc_entry = t @@ -1982,7 +1981,7 @@ class MobiWriter(object): elif self._periodicalCount and self._sectionCount > 1 : pt = None if self._oeb.metadata.publication_type: - x = self._oeb.metadata.publication_type[0].split(':') + x = unicode(self._oeb.metadata.publication_type[0]).split(':') if len(x) > 1: pt = x[1] mobiType = {'newspaper':0x101}.get(pt, 0x103) diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index 86c0ae1ed6..acf95df502 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -47,7 +47,7 @@ XPNSMAP = {'h' : XHTML_NS, 'o1' : OPF1_NS, 'o2' : OPF2_NS, 'd09': DC09_NS, 'd10': DC10_NS, 'd11': DC11_NS, 'xsi': XSI_NS, 'dt' : DCTERMS_NS, 'ncx': NCX_NS, 'svg': SVG_NS, 'xl' : XLINK_NS, 're': RE_NS, - 'mbp': MBP_NS } + 'mbp': MBP_NS, 'calibre': CALIBRE_NS } OPF1_NSMAP = {'dc': DC11_NS, 'oebpackage': OPF1_NS} OPF2_NSMAP = {'opf': OPF2_NS, 'dc': DC11_NS, 'dcterms': DCTERMS_NS,