Sha256: 16f0f9a97f4aabe6e8a0900e6ebd34cde64ce6e787d5832c8cf49511cb02aa1d

Contents?: true

Size: 998 Bytes

Versions: 1

Compression:

Stored size: 998 Bytes

Contents

#!/usr/bin/env ruby

require 'traktor/nml'

require 'optparse'

opt = OptionParser.new
out_format = ""

opt.version = Traktor::NML::VERSION
opt.on('-f FORMAT', '--format FORMAT', 'Specify output format') do |f|
  out_format = f
end

opt.parse! ARGV

abort 'please specify NML file to process' if ARGV.empty?

ARGV.each do |file|
  Traktor::NML.load(file).each_with_index do |track, i|
    puts(out_format.split(/(%[a-zA-Z])/).map do |f|
      case f
      when '%t'
        track.title
      when '%a'
        track.artist
      when '%d'
        track.album[:name]
      when '%i'
        track.album[:track]
      when '%I'
        i+1
      when '%p'
        track.primarykey
      when '%g'
        track.genre
      when '%l'
        track.label
      when '%D'
        track.release_date
      when '%T'
        track.playtime
      when '%b'
        track.bpm
      when '%k'
        track.key
      when '%K'
        track.musical_key
      else
        f
      end
    end.join)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
traktor-nml-0.3.1 bin/printnml