mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More robust reading of user metadata from OPF
This commit is contained in:
parent
420db7851b
commit
4bc7aa1b71
@ -531,6 +531,7 @@ class OPF(object): # {{{
|
|||||||
|
|
||||||
def read_user_metadata(self):
|
def read_user_metadata(self):
|
||||||
self._user_metadata_ = {}
|
self._user_metadata_ = {}
|
||||||
|
temp = Metadata('x', ['x'])
|
||||||
from calibre.utils.config import from_json
|
from calibre.utils.config import from_json
|
||||||
elems = self.root.xpath('//*[name() = "meta" and starts-with(@name,'
|
elems = self.root.xpath('//*[name() = "meta" and starts-with(@name,'
|
||||||
'"calibre:user_metadata:") and @content]')
|
'"calibre:user_metadata:") and @content]')
|
||||||
@ -542,12 +543,13 @@ class OPF(object): # {{{
|
|||||||
fm = elem.get('content')
|
fm = elem.get('content')
|
||||||
try:
|
try:
|
||||||
fm = json.loads(fm, object_hook=from_json)
|
fm = json.loads(fm, object_hook=from_json)
|
||||||
|
temp.set_user_metadata(name, fm)
|
||||||
except:
|
except:
|
||||||
prints('Failed to read user metadata:', name)
|
prints('Failed to read user metadata:', name)
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
continue
|
continue
|
||||||
self._user_metadata_[name] = fm
|
self._user_metadata_ = temp.get_all_user_metadata(True)
|
||||||
|
|
||||||
def to_book_metadata(self):
|
def to_book_metadata(self):
|
||||||
ans = MetaInformation(self)
|
ans = MetaInformation(self)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user