module Meta
The part that deals with metadata collection and generation. Currently, all metadata is collected and written by the command-line-tool atomicparsley.
Public Class Methods
apply_metadata(file, metadata, cover)
click to toggle source
Writes the metadata to the file.
# File lib/scrunch/meta.rb, line 33 def self.apply_metadata(file, metadata, cover) %(AtomicParsley \"#{file}\" \ --title \"#{metadata["nam"]}\" \ --album \"#{metadata["alb"]}\" \ --artist \"#{metadata["ART"]}\" \ --genre \"Audiobooks\" \ --stik \"Audiobook\" \ --artwork \"#{cover}\" \ --overWrite \ 2>&1 1>/dev/null) end
get_cover(input_file)
click to toggle source
Uses atomicparsley to write the embedded cover image to disk in the same directory as the audiobook.
# File lib/scrunch/meta.rb, line 22 def self.get_cover(input_file) unprocessed = `AtomicParsley \"#{input_file}\" -E` /(?<=\: ).*/.match(unprocessed).to_s end
get_metadata(file)
click to toggle source
Uses atomicparsley to collect metadata from the audiobook and return it as a fancy hash. Returns the following values:
-
nam (Title)
-
alb (Series)
-
ART (Author)
# File lib/scrunch/meta.rb, line 10 def self.get_metadata(file) atoms = `AtomicParsley \"#{file}\" -t` atoms.each_line.each_with_object({}) do |line, hash| prefix, contents = line.split(": ") atom_name = /([\w]{3,4})(?=\" contains)/.match(prefix).to_s hash[atom_name] = contents.strip unless atom_name.empty? hash end end
make_filename(input_file)
click to toggle source
Returns the final filename that is written finally.
# File lib/scrunch/meta.rb, line 28 def self.make_filename(input_file) input_file[0...-4] + "-new.m4b" end