diff --git a/src/calibre/devices/apple/driver.py b/src/calibre/devices/apple/driver.py index 5a0496e863..8d8f7c378f 100644 --- a/src/calibre/devices/apple/driver.py +++ b/src/calibre/devices/apple/driver.py @@ -2517,6 +2517,26 @@ class ITUNES(DriverBase): opf = [x for x in fnames if '.opf' in x][0] if 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 block in OPF file") + self.log.info(" add timestamp: %s" % metadata.timestamp) + ''' ns_map = opf_tree.nsmap.keys() for item in ns_map: ns = opf_tree.nsmap[item] @@ -2538,7 +2558,7 @@ class ITUNES(DriverBase): if DEBUG: self.log.warning(" missing block in OPF file") self.log.info(" add timestamp: %s" % metadata.timestamp) - + ''' # Force the language declaration for iBooks 1.1 #metadata.language = get_lang().replace('_', '-')