This commit is contained in:
Kovid Goyal 2011-02-16 09:28:10 -07:00
commit dc71b6b002

View File

@ -2517,28 +2517,25 @@ 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))
ns_map = opf_tree.nsmap.keys() md_els = opf_tree.xpath('.//*[local-name()="metadata"]')
for item in ns_map: if md_els:
ns = opf_tree.nsmap[item] ts = md_els[0].find('.//*[@name="calibre:timestamp"]')
md_el = opf_tree.find(".//{%s}metadata" % ns) if ts is not None:
if md_el is not None: timestamp = ts.get('content')
ts = md_el.find('.//{%s}meta[@name="calibre:timestamp"]') old_ts = parse_date(timestamp)
if ts: metadata.timestamp = datetime.datetime(old_ts.year, old_ts.month, old_ts.day, old_ts.hour,
timestamp = ts.get('content') old_ts.minute, old_ts.second, old_ts.microsecond+1, old_ts.tzinfo)
old_ts = parse_date(timestamp) if DEBUG:
metadata.timestamp = datetime.datetime(old_ts.year, old_ts.month, old_ts.day, old_ts.hour, self.log.info(" existing timestamp: %s" % metadata.timestamp)
old_ts.minute, old_ts.second, old_ts.microsecond+1, old_ts.tzinfo) else:
else: metadata.timestamp = now()
metadata.timestamp = now() if DEBUG:
if DEBUG: self.log.info(" add timestamp: %s" % metadata.timestamp)
self.log.info(" add timestamp: %s" % metadata.timestamp)
break
else: else:
metadata.timestamp = now() metadata.timestamp = now()
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('_', '-')