Gem Version

Icemaker

icemaker is a small cli tool, written in Ruby, that applies search filters to the audio metadata of a set of files and writes any matches out to disk. It was created to write playlists for Ices/Icecast; hence the name.

Access to the metadata is provided via taglib-ruby.

Installation

Add this line to your application's Gemfile:

gem 'icemaker'

And then execute:

$ bundle

Or install it yourself as:

$ gem install icemaker

Usage

run icemaker in a directory containing an Icefile.

# An example Icefile

Icemaker::Playlist.make do |with|

  # .sources, an array containing paths to the locations of the audio files we want to search
  with.sources = ['/path/to/some/music']

  # .is_recursive, if true, do a fully recursive search through the sources
  with.is_recursive = true

  # .verbose, if true, verbalize some status info during run, if false, remain silent
  with.verbose = true

  # .output_to_file, the name of the output file, if a full path is
  # given, it will need to exist before writing out to the file.
  with.output_to_file = 'playlist.txt'

  # .formatter, the format string for the output
  # the following is the default formatter for the playlist output and,
  # as such, it's redundant to specify it in the Icefile its presence here is merely instructional
  # with.formatter = lambda { |track| "#{track[:file]}" }

  # an example of a custom formatter; the keys for the hash are any of the searchable fields
  #with.formatter = lambda { |track| "#{track[:file]} genre: #{track[:genre]} length: #{track[:length]}"}

  # .filters, the array of search filters applied to each track, they take the basic form:

  # { search_field: { search_operator: search_term}}

  # searchable fields are:
  # :title
  # :artist
  # :album
  # :genre
  # :year
  # :length
  # :bitrate
  # :channels
  # :sample_rate

  # available search operators (and their synonyms) are:
  # :is (eq:)
  # :has (contains:)
  # :gt (greater_than:)
  # :gte (greater_than_or_equal_to:)
  # :lt (less_than:)
  # :lte (less_than_or_equal_to:)
  # :regx (satisfies:)

  # all searches are case insensitive, however, case sensitive searches are available using the :regx search operator

  # some examples:

  with.filters << { genre: { is: "ambient" }}
  with.filters << { album: { has: "air structures" }}  
  with.filters << { length: { gt: 200 }}
  with.filters << { length: { lt: 800 }}
  with.filters << { artist: { regx: /[Ff]ripp/}}

  # compound search terms are given as a hash where the
  # key represents a boolean operator (:or, :and) and the value
  # is an array of terms to which the operator is applied.

  # { search_field: { search_operator: { boolean_operator: [search_term_0, search_term_1,...] }}}

  # some examples of compound search terms:

  #with.filters << { artist: { has: { or: ["Aphex", "Cowboy"] }}}
  #with.filters << { genre: { has: { and: ["Ambient", "Darkwave"] }}}

  # synonyms for boolean_operators are:
  # :intersection_of for :and
  # :union_of for :or

  #with.filters << { artist: { has: { union_of: ["Aphex", "Cowboy"] }}}
  #with.filters << { genre: { has: { intersection_of: ["Ambient", "Darkwave"] }}}

end

A much smaller example Icefile is available in the /examples directory.

Contributing

Bug reports are welcome on GitHub at https://github.com/twocats/icemaker.