Last active
December 26, 2015 08:49
-
-
Save oparrish/7124851 to your computer and use it in GitHub Desktop.
Ruby script to format a CUE sheet as HTML output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubycue' | |
require 'optparse' | |
options = {} | |
opts = OptionParser.new do |opts| | |
opts.on("-c", "--cue PATH", "Path to chesheet file") do |cue_file| | |
options[:cue] = cue_file | |
end | |
end | |
opts.parse! | |
cuesheet = RubyCue::Cuesheet.new(File.read(options[:cue])) | |
cuesheet.parse! | |
html="<ol>" | |
cuesheet.songs.each do |song| | |
hour = song[:index].minutes / 60 | |
hour = hour.floor | |
minutes = (song[:index].minutes - hour * 60).floor | |
minutes = '%02d' % minutes | |
seconds = '%02d' % song[:index].seconds | |
if hour == 0 | |
html << "<li>#{minutes}:#{seconds} #{song[:performer]} - #{song[:title]}</li>" | |
else | |
html << "<li>#{hour}:#{minutes}:#{seconds} #{song[:performer]} - #{song[:title]}</li>" | |
end | |
end | |
html << "</ol>" | |
puts html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment