mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB metadata: When setting authors, always move the new dc:creator element to the top so broken implementations don't get confused and make their anonymous creators look like fools
This commit is contained in:
parent
7266cdd3c4
commit
7e56edf946
@ -669,10 +669,19 @@ class OPF(object):
|
|||||||
remove = list(self.authors_path(self.metadata))
|
remove = list(self.authors_path(self.metadata))
|
||||||
for elem in remove:
|
for elem in remove:
|
||||||
elem.getparent().remove(elem)
|
elem.getparent().remove(elem)
|
||||||
|
elems = []
|
||||||
for author in val:
|
for author in val:
|
||||||
attrib = {'{%s}role'%self.NAMESPACES['opf']: 'aut'}
|
attrib = {'{%s}role'%self.NAMESPACES['opf']: 'aut'}
|
||||||
elem = self.create_metadata_element('creator', attrib=attrib)
|
elem = self.create_metadata_element('creator', attrib=attrib)
|
||||||
self.set_text(elem, author.strip())
|
self.set_text(elem, author.strip())
|
||||||
|
# Ensure new author element is at the top of the list
|
||||||
|
# for broken implementations that always use the first
|
||||||
|
# <dc:creator> element with no attention to the role
|
||||||
|
elems.append(elem)
|
||||||
|
for elem in reversed(elems):
|
||||||
|
parent = elem.getparent()
|
||||||
|
parent.remove(elem)
|
||||||
|
parent.insert(0, elem)
|
||||||
|
|
||||||
return property(fget=fget, fset=fset)
|
return property(fget=fget, fset=fset)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user