From dc3a040d2a4919f8e27a57143f67005f6f820b78 Mon Sep 17 00:00:00 2001 From: neingeist Date: Fri, 30 Sep 2005 13:30:54 +0000 Subject: [PATCH] erstmal committen --- neinomat-termine | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 neinomat-termine diff --git a/neinomat-termine b/neinomat-termine new file mode 100755 index 0000000..7664d77 --- /dev/null +++ b/neinomat-termine @@ -0,0 +1,58 @@ +#!/usr/bin/env ruby +require 'mediawikibot' + +if ARGV.size() != 2 + $stderr.print($0 + " \n") + exit(1) +end + +b = MediaWikiBot::WikiBot.new("http://www.entropia.de/wiki/") +b.login(ARGV[0], ARGV[1]) + +termine = [] + +#---------------------------------------------------------------------------- + +template = "Vorlage:Radio Chaotica-Sendung" +b.get_what_uses_template(template).each do |page| + if erste_sendung = b.parse_template(page, template)["erste_sendung"] + termin = {} + termin["datum"] = erste_sendung.gsub(/\s*um\s*\d+:\d+$/,"") + termin["uhrzeit"] = "16:00" + termin["beschreibung"] = "[[" + page + "]]" + termin["ort"] = "[http://www.querfunk.de Querfunk]" + termine.push(termin) + else + $stderr.print(page, ": erste_sendung nicht gesetzt") + end +end + +#---------------------------------------------------------------------------- + +template = "Vorlage:Termin" +b.get_what_uses_template(template).each do |page| + termin = b.parse_template(page, template) + termine.push(termin) +end + +#---------------------------------------------------------------------------- + + +termine = termine.sort do |x,y| + def datum2isodate(datum) + isodate = datum[6..9] + "-" + datum[3..4] + "-" + datum[0..1] + end + datum2isodate(x["datum"]) <=> datum2isodate(y["datum"]) +end + +body = '{| border=1 cellspacing="0" cellpadding="5" style="border-collapse:collapse;"' +body += "\n" +termine.each do |termin| + body += "| " + termin["datum"] + "\n" + body += "| " + termin["beschreibung"] + "\n" + body += "|-\n" +end +body += "|}" + +#puts body +b.edit("Benutzer:Neingeist/Termine", body, "Test")