+ "TITLE": document.meta.title,
+ "PUBLISHER": document.meta.publisher[0],
+ "YEAR": document.meta.created_at[:4],
+ "MONTH": document.meta.created_at[5:7],
+ "AUTHOR": document.meta.author.readable(),
+
+ "NARRATOR": narrator,
+ }
+
+ with open(get_resource('res/daisy/content.smil')) as f:
+ tree = etree.parse(f)
+ populate(tree.getroot(), context)
+
+ seq = tree.find('//seq')
+ for si, item in enumerate(sync):
+ par = etree.SubElement(seq, 'par', id="par%06d" % (si + 1), endsync="last")
+ etree.SubElement(
+ par,
+ "text",
+ src="book%d.html#%s" % (i, item[2]))
+
+ audio = etree.SubElement(
+ par,
+ "audio",
+ src="book%d.mp3" % i,
+ **{
+ "clip-begin": "npt=%.3fs" % item[0],
+ "clip-end": "npt=%.3fs" % item[1],
+ },
+ )
+
+ zipf.writestr(
+ directory + 'content%d.smil' % i,
+ etree.tostring(
+ tree,
+ xml_declaration=True,
+ pretty_print=True,
+ ),
+ )
+
+ for fname in ('smil10.dtd', 'xhtml1-transitional.dtd', 'xhtml-lat1.ent', 'xhtml-special.ent', 'xhtml-symbol.ent'):
+ zipf.write(
+ get_resource('res/daisy/' + fname),
+ directory + fname)
+
+ duration = sum(durations)
+ hms = format_hms(duration)