Skip to content

Instantly share code, notes, and snippets.

@tily
Created September 23, 2016 23:00
Show Gist options
  • Save tily/eb339a9452846e339ff2cba7ee78410f to your computer and use it in GitHub Desktop.
Save tily/eb339a9452846e339ff2cba7ee78410f to your computer and use it in GitHub Desktop.
Detect data track from XLD logs
def main
Dir["/Users/tily/Music/CDs/*/*.log"].each do |path|
f = File.open(path)
table_num, track_num = parse(f)
if table_num != track_num
puts "#{path}: table -> #{table_num}, track -> #{track_num}"
end
end
end
def parse(io)
lines = io.read.split("\n")
iter = lines.each
table_num = nil
track_num = nil
while true
begin
l = iter.next
if l.match(/^TOC of the extracted CD$/)
while true
l = iter.next
if num = l[/^\s+(\d+)/, 1]
table_num = num.to_i
end
if l == ""
break
end
end
end
if num = l[/^Track (\d+)/, 1]
track_num = num.to_i
end
rescue StopIteration => e
break
end
end
return [table_num, track_num]
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment