Created
May 12, 2016 12:29
-
-
Save kch/f0ca9bb348886c557a178a89ddf10712 to your computer and use it in GitHub Desktop.
sort wgt bands by time, append location
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
#!/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