Create a gist now

Instantly share code, notes, and snippets.

@kch /wgt.rb
Created May 12, 2016

What would you like to do?
sort wgt bands by time, append location
#!/usr/bin/env ruby
s = ARGF.read =~ /Freitag, 13. Mai 2016.*?(?=\n\n)/m && $&
s.gsub! /^(\d\d)\.(\d\d)\u00A0Uhr\n/, "\\1:\\2h -- "
days = []
s.lines.each do |l|
case l
when /^\d\d:\d\dh -- Einlaß/ then :pass
when /Mai 2016$/ then days << [l, []]
when /^\d\d:\d\dh -- / then days.last[1] << l.sub(/\Z/, " -- @ #{$x}")
else $x = l.chomp
end
end
days.each{|d,ls| ls.sort_by!{|l| [(l =~ /^0/ ? 1 : 0), l] }}
puts days.flat_map{|d,ls| [nil,'== ' + d,ls] }
__END__
Usage:
curl -s http://www.wave-gotik-treffen.de/prog/programm.php | textutil -stdin -stdout -format html -convert txt | $0
cat programm.html | textutil -stdin -stdout -format html -convert txt | $0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment