Class: Bookbinder::Transform::MediaRipper_NavToc
- Inherits:
-
Bookbinder::Transform
- Object
- Bookbinder::Transform
- Bookbinder::Transform::MediaRipper_NavToc
- Defined in:
- lib/bookbinder/transform/media_ripper/nav_toc.rb
Overview
MediaMarker XML format is like this:
<AudioBook>
<Markers file="HP-136127-Part08.mp3">
<Marker>
<Name>Chapter 15</Name>
<Time>74:48.000</Time>
</Marker>
... etc ...
</Markers>
</AudioBook>
Instance Method Summary collapse
Methods inherited from Bookbinder::Transform
Instance Method Details
#to_map(package) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bookbinder/transform/media_ripper/nav_toc.rb', line 15 def to_map(package) toc = [] package.xml_paths.each { |xml_path| doc = package.file(xml_path).document('r') markers_tag = doc.find('AudioBook > Markers') aud_path = markers_tag['file'] doc.each_within(markers_tag, 'Marker') { |marker_tag| seconds = translate_time(doc.find_within(marker_tag, 'Time').content) toc << { 'title' => doc.find_within(marker_tag, 'Name').content.strip, 'path' => "#{aud_path}#{seconds ? "##{seconds}" : ''}" } } } package.map['nav'] = { 'toc' => toc } end |