neingeist
/
neinomaten
Archived
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
neinomaten/neinomat-radio-chaotica

46 lines
1.1 KiB
Plaintext

19 years ago
#!/usr/bin/env ruby
19 years ago
$:.unshift('vendor/ruby-mediawiki/lib')
$:.unshift('vendor/htree')
require 'mediawiki/dotfile'
@wiki = MediaWiki.dotfile(nil,'entropia')
19 years ago
19 years ago
def parse_template(title, template)
template_re = Regexp.new("\\\{\\\{" + template + "(.*?)\\\}\\\}")
fields = {}
fields_string = @wiki.article(title).text.scan(template_re)[0][0]
19 years ago
19 years ago
inlink = 0
field = ""
fields_string += "|" unless fields_string.match(/\|$/)
fields_string.split(//).each do |c|
if c == "|" && inlink == 0
(key, value) = field.split(/=/)
fields[key] = value
field = ""
else
inlink += 1 if c == "["
inlink -= 1 if c == "]"
field += c
end
end
fields
end
19 years ago
body = ""
template = "Vorlage:Radio Chaotica-Sendung"
19 years ago
@wiki.article(template).what_links_here.each do |page|
if erste_sendung = parse_template(page, template)["erste_sendung"]
19 years ago
datum = erste_sendung.gsub(/\s*um\s*\d+:\d+$/,"")
body += "* " + datum + " [[" + page + "]]\n"
else
$stderr.print(page, ": erste_sendung nicht gesetzt")
end
end
19 years ago
a = @wiki.article("Benutzer:Neingeist/Radio Chaotica-Liste")
a.text = body
a.submit("Radio Chaotica-Liste")