mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
EPUB: Ensure that the calibre book uuid is present in the opf of EPUB files converted/exported from the GUI
This commit is contained in:
parent
daf84fd6a7
commit
e25cb884fa
@ -291,6 +291,8 @@ def set_metadata(stream, mi, apply_null=False, update_timestamp=False):
|
||||
|
||||
|
||||
reader.opf.smart_update(mi)
|
||||
if getattr(mi, 'uuid', None):
|
||||
reader.opf.application_id = mi.uuid
|
||||
if apply_null:
|
||||
if not getattr(mi, 'series', None):
|
||||
reader.opf.series = None
|
||||
|
@ -941,12 +941,11 @@ class OPF(object): # {{{
|
||||
return self.get_text(match) or None
|
||||
|
||||
def fset(self, val):
|
||||
matches = self.application_id_path(self.metadata)
|
||||
if not matches:
|
||||
attrib = {'{%s}scheme'%self.NAMESPACES['opf']: 'calibre'}
|
||||
matches = [self.create_metadata_element('identifier',
|
||||
attrib=attrib)]
|
||||
self.set_text(matches[0], unicode(val))
|
||||
for x in tuple(self.application_id_path(self.metadata)):
|
||||
x.getparent().remove(x)
|
||||
attrib = {'{%s}scheme'%self.NAMESPACES['opf']: 'calibre'}
|
||||
self.set_text(self.create_metadata_element(
|
||||
'identifier', attrib=attrib), unicode(val))
|
||||
|
||||
return property(fget=fget, fset=fset)
|
||||
|
||||
|
@ -115,8 +115,11 @@ class MergeMetadata(object):
|
||||
if mi.uuid is not None:
|
||||
m.filter('identifier', lambda x:x.id=='uuid_id')
|
||||
self.oeb.metadata.add('identifier', mi.uuid, id='uuid_id',
|
||||
scheme='uuid')
|
||||
scheme='uuid')
|
||||
self.oeb.uid = self.oeb.metadata.identifier[-1]
|
||||
if mi.application_id is not None:
|
||||
m.filter('identifier', lambda x:x.scheme=='calibre')
|
||||
self.oeb.metadata.add('identifier', mi.application_id, scheme='calibre')
|
||||
|
||||
def set_cover(self, mi, prefer_metadata_cover):
|
||||
cdata, ext = '', 'jpg'
|
||||
|
@ -26,6 +26,7 @@ def create_opf_file(db, book_id):
|
||||
mi.application_id = uuid.uuid4()
|
||||
old_cover = mi.cover
|
||||
mi.cover = None
|
||||
mi.application_id = mi.uuid
|
||||
raw = metadata_to_opf(mi)
|
||||
mi.cover = old_cover
|
||||
opf_file = PersistentTemporaryFile('.opf')
|
||||
|
Loading…
x
Reference in New Issue
Block a user