diff --git a/src/calibre/ebooks/txt/output.py b/src/calibre/ebooks/txt/output.py index 7d44172b3f..5e58d47ef1 100644 --- a/src/calibre/ebooks/txt/output.py +++ b/src/calibre/ebooks/txt/output.py @@ -39,10 +39,10 @@ class TXTOutput(OutputFormatPlugin): def convert(self, oeb_book, output_path, input_plugin, opts, log): metadata = TxtMetadata() if opts.prepend_author.lower() == 'true': - metadata.author = opts.authors if opts.authors else authors_to_string(oeb_book.metadata.authors) + metadata.author = opts.authors if opts.authors else authors_to_string(oeb_book.metadata.authors.value) if oeb_book.metadata.authors != [] else _('Unknown') if opts.prepend_title.lower() == 'true': - metadata.title = opts.title if opts.title else oeb_book.metadata.title - + metadata.title = opts.title if opts.title else oeb_book.metadata.title[0].value if oeb_book.metadata.title != [] else _('Unknown') + writer = TxtWriter(TxtNewlines(opts.newline).newline, log) txt = writer.dump(oeb_book.spine, metadata) diff --git a/src/calibre/ebooks/txt/writer.py b/src/calibre/ebooks/txt/writer.py index eabc2d64ed..2fb5f9550a 100644 --- a/src/calibre/ebooks/txt/writer.py +++ b/src/calibre/ebooks/txt/writer.py @@ -22,16 +22,15 @@ class TxtWriter(object): def dump(self, spine, metadata): out = u'' for item in spine: - with open(item, 'r') as itemf: - content = itemf.read().decode(item.encoding) - # Convert newlines to unix style \n for processing. These - # will be changed to the specified type later in the process. - content = self.unix_newlines(content) - content = self.strip_html(content) - content = self.replace_html_symbols(content) - content = self.cleanup_text(content) - content = self.specified_newlines(content) - out += content + content = unicode(item) + # Convert newlines to unix style \n for processing. These + # will be changed to the specified type later in the process. + content = self.unix_newlines(content) + content = self.strip_html(content) + content = self.replace_html_symbols(content) + content = self.cleanup_text(content) + content = self.specified_newlines(content) + out += content # Prepend metadata if metadata.author != None and metadata.author != '':