mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -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)
|
reader.opf.smart_update(mi)
|
||||||
|
if getattr(mi, 'uuid', None):
|
||||||
|
reader.opf.application_id = mi.uuid
|
||||||
if apply_null:
|
if apply_null:
|
||||||
if not getattr(mi, 'series', None):
|
if not getattr(mi, 'series', None):
|
||||||
reader.opf.series = None
|
reader.opf.series = None
|
||||||
|
@ -941,12 +941,11 @@ class OPF(object): # {{{
|
|||||||
return self.get_text(match) or None
|
return self.get_text(match) or None
|
||||||
|
|
||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
matches = self.application_id_path(self.metadata)
|
for x in tuple(self.application_id_path(self.metadata)):
|
||||||
if not matches:
|
x.getparent().remove(x)
|
||||||
attrib = {'{%s}scheme'%self.NAMESPACES['opf']: 'calibre'}
|
attrib = {'{%s}scheme'%self.NAMESPACES['opf']: 'calibre'}
|
||||||
matches = [self.create_metadata_element('identifier',
|
self.set_text(self.create_metadata_element(
|
||||||
attrib=attrib)]
|
'identifier', attrib=attrib), unicode(val))
|
||||||
self.set_text(matches[0], unicode(val))
|
|
||||||
|
|
||||||
return property(fget=fget, fset=fset)
|
return property(fget=fget, fset=fset)
|
||||||
|
|
||||||
|
@ -115,8 +115,11 @@ class MergeMetadata(object):
|
|||||||
if mi.uuid is not None:
|
if mi.uuid is not None:
|
||||||
m.filter('identifier', lambda x:x.id=='uuid_id')
|
m.filter('identifier', lambda x:x.id=='uuid_id')
|
||||||
self.oeb.metadata.add('identifier', mi.uuid, 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]
|
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):
|
def set_cover(self, mi, prefer_metadata_cover):
|
||||||
cdata, ext = '', 'jpg'
|
cdata, ext = '', 'jpg'
|
||||||
|
@ -26,6 +26,7 @@ def create_opf_file(db, book_id):
|
|||||||
mi.application_id = uuid.uuid4()
|
mi.application_id = uuid.uuid4()
|
||||||
old_cover = mi.cover
|
old_cover = mi.cover
|
||||||
mi.cover = None
|
mi.cover = None
|
||||||
|
mi.application_id = mi.uuid
|
||||||
raw = metadata_to_opf(mi)
|
raw = metadata_to_opf(mi)
|
||||||
mi.cover = old_cover
|
mi.cover = old_cover
|
||||||
opf_file = PersistentTemporaryFile('.opf')
|
opf_file = PersistentTemporaryFile('.opf')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user