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.
37 lines
925 B
Plaintext
37 lines
925 B
Plaintext
19 years ago
|
#!/usr/bin/env ruby
|
||
|
|
||
|
require 'http-access2'
|
||
|
require 'mediawikibot'
|
||
|
require 'vpim/icalendar'
|
||
|
include Vpim
|
||
|
|
||
|
if ARGV.size() != 2
|
||
|
$stderr.print($0 + " <wiki-user> <wiki-password>\n")
|
||
|
exit(1)
|
||
|
end
|
||
|
|
||
19 years ago
|
$ical_url = "webcal://upcoming.org/calendar/metro/1551"
|
||
|
$web_url = "http://upcoming.org/metro/de/bawue/ka/"
|
||
19 years ago
|
|
||
|
def get_events()
|
||
|
@client = HTTPAccess2::Client.new()
|
||
19 years ago
|
ical = @client.get_content($ical_url.gsub(/^webcal:/, "http:"))
|
||
19 years ago
|
events = []
|
||
|
Icalendar.decode(ical).each do |publish|
|
||
|
publish.events.each do |event|
|
||
|
events.push(event)
|
||
|
end
|
||
|
end
|
||
|
return events
|
||
|
end
|
||
|
|
||
19 years ago
|
body = "Folgende Termine stammen von #{$web_url} ([#{$ical_url} iCal]):\n\n"
|
||
19 years ago
|
get_events().each do |event|
|
||
|
body += "* #{event.dtstart.mday}.#{event.dtstart.month}. #{event.summary}\n"
|
||
|
end
|
||
|
|
||
|
b = MediaWikiBot::WikiBot.new("http://ka.stadtwiki.net/")
|
||
|
b.login(ARGV[0], ARGV[1])
|
||
|
|
||
|
b.edit("Benutzer:Neingeist/Termine_aus_upcoming.org", body, "Import")
|