neue lib
This commit is contained in:
parent
d1cdd63f8f
commit
e64bebbd8b
1 changed files with 32 additions and 10 deletions
|
@ -1,18 +1,38 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
require 'mediawikibot'
|
$:.unshift('vendor/ruby-mediawiki/lib')
|
||||||
|
$:.unshift('vendor/htree')
|
||||||
|
require 'mediawiki/dotfile'
|
||||||
|
@wiki = MediaWiki.dotfile(nil,'entropia')
|
||||||
|
|
||||||
if ARGV.size() != 2
|
def parse_template(title, template)
|
||||||
$stderr.print($0 + " <wiki-user> <wiki-password>\n")
|
template_re = Regexp.new("\\\{\\\{" + template + "(.*?)\\\}\\\}")
|
||||||
exit(1)
|
|
||||||
|
fields = {}
|
||||||
|
|
||||||
|
fields_string = @wiki.article(title).text.scan(template_re)[0][0]
|
||||||
|
|
||||||
|
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
|
end
|
||||||
|
|
||||||
b = MediaWikiBot::WikiBot.new("http://entropia.de/wiki/")
|
|
||||||
b.login(ARGV[0], ARGV[1])
|
|
||||||
|
|
||||||
body = ""
|
body = ""
|
||||||
template = "Vorlage:Radio Chaotica-Sendung"
|
template = "Vorlage:Radio Chaotica-Sendung"
|
||||||
b.get_what_uses_template(template).each do |page|
|
@wiki.article(template).what_links_here.each do |page|
|
||||||
if erste_sendung = b.parse_template(page, template)["erste_sendung"]
|
if erste_sendung = parse_template(page, template)["erste_sendung"]
|
||||||
datum = erste_sendung.gsub(/\s*um\s*\d+:\d+$/,"")
|
datum = erste_sendung.gsub(/\s*um\s*\d+:\d+$/,"")
|
||||||
body += "* " + datum + " [[" + page + "]]\n"
|
body += "* " + datum + " [[" + page + "]]\n"
|
||||||
else
|
else
|
||||||
|
@ -20,4 +40,6 @@ b.get_what_uses_template(template).each do |page|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
b.edit("Benutzer:Neingeist/Radio Chaotica-Liste", body, "Test")
|
a = @wiki.article("Benutzer:Neingeist/Radio Chaotica-Liste")
|
||||||
|
a.text = body
|
||||||
|
a.submit("Radio Chaotica-Liste")
|
||||||
|
|
Reference in a new issue