Class: Bookbinder::Package::MediaRipper

Inherits:
Bookbinder::Package show all
Defined in:
lib/bookbinder/package/media_ripper.rb

Constant Summary collapse

DEFAULT_TRANSFORMS =
[
  Bookbinder::Transform::MediaRipper_Rendition,
  Bookbinder::Transform::MediaRipper_Title,
  Bookbinder::Transform::MediaRipper_Publisher,
  Bookbinder::Transform::MediaRipper_EISBN,
  Bookbinder::Transform::MediaRipper_Spine,
  Bookbinder::Transform::MediaRipper_NavToc,
  Bookbinder::Transform::MediaRipper_CoverImage,
  Bookbinder::Transform::Organizer,
  Bookbinder::Transform::Generator
]

Instance Attribute Summary

Attributes inherited from Bookbinder::Package

#content_root, #file_aliases, #file_system, #map, #options, #warnings

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Bookbinder::Package

#all_book_content, #apply_transform, build, #build, #copy_to, #export, #file, #file_path, #from_map, #if_file, #import, #initialize, #read, read, require_transforms, #reset_transforms, #save_open_files, #to_map, #transforms, #warn, #write

Constructor Details

This class inherits a constructor from Bookbinder::Package

Class Method Details

.recognize(path) ⇒ Object



18
19
20
21
# File 'lib/bookbinder/package/media_ripper.rb', line 18

def self.recognize(path)
  return path.match(/.odmr.zip$/);
  # TODO: detect unzipped media-ripper audiobook?
end

.transformsObject



24
25
26
# File 'lib/bookbinder/package/media_ripper.rb', line 24

def self.transforms
  @transforms ||= DEFAULT_TRANSFORMS
end

Instance Method Details

#audio_pathsObject



29
30
31
32
33
34
35
# File 'lib/bookbinder/package/media_ripper.rb', line 29

def audio_paths
  xml_paths.collect { |xml_path|
    next  unless doc = file(xml_path).document('r')
    next  unless markers_tag = doc.find('AudioBook > Markers')
    markers_tag['file']
  }.compact
end

#xml_pathsObject



38
39
40
41
42
43
44
45
# File 'lib/bookbinder/package/media_ripper.rb', line 38

def xml_paths
  xml_paths = []
  file_system.each { |path|
    next  unless match = path.match(/Part(\d+)\.xml$/)
    xml_paths[match[1].to_i] = path
  }
  xml_paths.compact!
end