Created
April 16, 2014 09:16
-
-
Save spnkr/10838998 to your computer and use it in GitHub Desktop.
plain text to .cue formatter (cue file generator)
This file contains 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
# turns /Users/foo/cue into a real cue file called new.cue. | |
# /Users/foo/cue must be of format: | |
# start# time | |
# artist | |
# track name | |
# | |
# | |
# | |
# e.g. | |
# 01:15 | |
# Nicky Romero w/ The Aston Shuffle vs. Tommy Trash w/ Deorro | |
# Toulouse/Toulouse (Headhunterz Remix Acappella)/Sunrise (Won't Get Lost) (Acappella)/Yee | |
# | |
# New lines are ignored (can leave as many as you want) | |
# set basic track info | |
cue = [] | |
cue.push 'PERFORMER "Nicky Romero"' | |
cue.push 'TITLE "Nicky Romero @ Main Stage, Ultra Music Festival Miami 2014-03-29"' | |
cue.push 'FILE "Nicky Romero – Live @ Ultra Music Festival 2014 (Miami, FL) – 29.03.2014" MP3' | |
#read /Users/foo/cue and turn into proper .cue syntax | |
lines = File.readlines("/Users/foo/cue") | |
lines = lines.map{|l| | |
l = l.to_s.strip.gsub("\n","") | |
if l.length<2 | |
nil | |
else | |
l | |
end | |
}.compact | |
track = 1 | |
lines.each_slice(3) do |s| | |
if track >=10 | |
cue.push " TRACK #{track} AUDIO" | |
else | |
cue.push " TRACK 0#{track} AUDIO" | |
end | |
cue.push " PERFORMER \"#{s[1].strip}\"" | |
cue.push " TITLE \"#{s[2].strip}\"" | |
cue.push " INDEX 01 #{s[0].strip}:00" | |
track +=1 | |
end | |
File.open("/Users/will/new.cue", 'w') do |file| | |
file.puts cue | |
end | |
puts "done!" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment