mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
EPUB Metadata: Add workaround for bug in PocketBook firmware which causes it to fail to read series metadata if the series number is declared before the series. Fixes #1488113 [Pocketbook Series Number metadata](https://bugs.launchpad.net/calibre/+bug/1488113)
This commit is contained in:
parent
2a9d8e3e81
commit
379b82cd00
@ -1248,6 +1248,19 @@ class OPF(object): # {{{
|
||||
if c is not None:
|
||||
del a['content']
|
||||
a['content'] = c
|
||||
# The PocketBook requires calibre:series_index to come after
|
||||
# calibre:series or it fails to read series info
|
||||
# We swap attributes instead of elements, as that avoids namespace
|
||||
# re-declarations
|
||||
smap = {}
|
||||
for child in self.metadata.xpath('./*[@name="calibre:series" or @name="calibre:series_index"]'):
|
||||
smap[child.get('name')] = (child, self.metadata.index(child))
|
||||
if len(smap) == 2 and smap['calibre:series'][1] > smap['calibre:series_index'][1]:
|
||||
s, si = smap['calibre:series'][0], smap['calibre:series_index'][0]
|
||||
def swap(attr):
|
||||
t = s.get(attr, '')
|
||||
s.set(attr, si.get(attr, '')), si.set(attr, t)
|
||||
swap('name'), swap('content')
|
||||
|
||||
self.write_user_metadata()
|
||||
if pretty_print_opf:
|
||||
|
Loading…
x
Reference in New Issue
Block a user