mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
using local-name()=
This commit is contained in:
parent
0bf3e3db12
commit
0083f92f9e
@ -2517,6 +2517,26 @@ class ITUNES(DriverBase):
|
|||||||
opf = [x for x in fnames if '.opf' in x][0]
|
opf = [x for x in fnames if '.opf' in x][0]
|
||||||
if opf:
|
if opf:
|
||||||
opf_tree = etree.fromstring(zf_opf.read(opf))
|
opf_tree = etree.fromstring(zf_opf.read(opf))
|
||||||
|
md_el = opf_tree.xpath('.//*[local-name()="metadata"]')[0]
|
||||||
|
if md_el is not None:
|
||||||
|
ts = md_el.find('.//*[@name="calibre:timestamp"]')
|
||||||
|
if ts is not None:
|
||||||
|
timestamp = ts.get('content')
|
||||||
|
old_ts = parse_date(timestamp)
|
||||||
|
metadata.timestamp = datetime.datetime(old_ts.year, old_ts.month, old_ts.day, old_ts.hour,
|
||||||
|
old_ts.minute, old_ts.second, old_ts.microsecond+1, old_ts.tzinfo)
|
||||||
|
if DEBUG:
|
||||||
|
self.log.info(" existing timestamp: %s" % metadata.timestamp)
|
||||||
|
else:
|
||||||
|
metadata.timestamp = now()
|
||||||
|
if DEBUG:
|
||||||
|
self.log.info(" add timestamp: %s" % metadata.timestamp)
|
||||||
|
else:
|
||||||
|
metadata.timestamp = now()
|
||||||
|
if DEBUG:
|
||||||
|
self.log.warning(" missing <metadata> block in OPF file")
|
||||||
|
self.log.info(" add timestamp: %s" % metadata.timestamp)
|
||||||
|
'''
|
||||||
ns_map = opf_tree.nsmap.keys()
|
ns_map = opf_tree.nsmap.keys()
|
||||||
for item in ns_map:
|
for item in ns_map:
|
||||||
ns = opf_tree.nsmap[item]
|
ns = opf_tree.nsmap[item]
|
||||||
@ -2538,7 +2558,7 @@ class ITUNES(DriverBase):
|
|||||||
if DEBUG:
|
if DEBUG:
|
||||||
self.log.warning(" missing <metadata> block in OPF file")
|
self.log.warning(" missing <metadata> block in OPF file")
|
||||||
self.log.info(" add timestamp: %s" % metadata.timestamp)
|
self.log.info(" add timestamp: %s" % metadata.timestamp)
|
||||||
|
'''
|
||||||
# Force the language declaration for iBooks 1.1
|
# Force the language declaration for iBooks 1.1
|
||||||
#metadata.language = get_lang().replace('_', '-')
|
#metadata.language = get_lang().replace('_', '-')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user