From 9e8d691d47a0d9d7eac8cfca23648b416b439693 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 17 Mar 2012 19:05:07 +0530 Subject: [PATCH] Fix #957527 (Private bug) --- src/calibre/ebooks/conversion/plugins/epub_output.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/conversion/plugins/epub_output.py b/src/calibre/ebooks/conversion/plugins/epub_output.py index 89cf987bb1..45df8ba9d1 100644 --- a/src/calibre/ebooks/conversion/plugins/epub_output.py +++ b/src/calibre/ebooks/conversion/plugins/epub_output.py @@ -190,12 +190,22 @@ class EPUBOutput(OutputFormatPlugin): if x.get(OPF('scheme'), None).lower() == 'uuid' or unicode(x).startswith('urn:uuid:'): uuid = unicode(x).split(':')[-1] break + encrypted_fonts = getattr(input_plugin, 'encrypted_fonts', []) + if uuid is None: self.log.warn('No UUID identifier found') from uuid import uuid4 uuid = str(uuid4()) oeb.metadata.add('identifier', uuid, scheme='uuid', id=uuid) + if encrypted_fonts and not uuid.startswith('urn:uuid:'): + # Apparently ADE requires this value to start with urn:uuid: + # for some absurd reason, or it will throw a hissy fit and refuse + # to use the obfuscated fonts. + for x in identifiers: + if unicode(x) == uuid: + x.content = 'urn:uuid:'+uuid + with TemporaryDirectory(u'_epub_output') as tdir: from calibre.customize.ui import plugin_for_output_format metadata_xml = None @@ -210,7 +220,6 @@ class EPUBOutput(OutputFormatPlugin): opf = [x for x in os.listdir(tdir) if x.endswith('.opf')][0] self.condense_ncx([os.path.join(tdir, x) for x in os.listdir(tdir)\ if x.endswith('.ncx')][0]) - encrypted_fonts = getattr(input_plugin, 'encrypted_fonts', []) encryption = None if encrypted_fonts: encryption = self.encrypt_fonts(encrypted_fonts, tdir, uuid)