hbfk-dresden: init
This commit is contained in:
parent
20011c4f20
commit
943176a98d
|
@ -40,4 +40,5 @@ in {
|
|||
azconni = wrapScript "azconni" ./azconni/scrape.rb;
|
||||
kunsthaus = wrapScript "kunsthaus" ./kunsthaus/scrape.rb;
|
||||
hfmdd = wrapScript "hfmdd" ./hfmdd/scrape.rb;
|
||||
hfbk-dresden = wrapScript "hfbk-dresden" ./hfbk-dresden/scrape.rb;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
#!/usr/bin/env ruby
|
||||
# coding: utf-8
|
||||
|
||||
require 'open-uri'
|
||||
require 'time'
|
||||
require 'nokogiri'
|
||||
require 'erb'
|
||||
|
||||
def fmt_time t
|
||||
t.strftime "%Y%m%dT%H%M%S"
|
||||
end
|
||||
|
||||
class Event
|
||||
attr_accessor :title, :url
|
||||
attr_reader :date, :location, :dtstart
|
||||
|
||||
def initialize
|
||||
@location = "Hochschule für Bildende Künste Dresden"
|
||||
end
|
||||
|
||||
def dtend
|
||||
@dtstart + 7200
|
||||
end
|
||||
|
||||
def date=(s)
|
||||
@dtstart = Time::parse(s)
|
||||
end
|
||||
end
|
||||
|
||||
events = []
|
||||
|
||||
url = "https://www.hfbk-dresden.de/veranstaltungen"
|
||||
doc = Nokogiri::HTML URI.open(url)
|
||||
doc.css(".topnews").each do |content|
|
||||
time = content.css("time").attr("datetime").text
|
||||
title_link = content.css("h3 a")
|
||||
|
||||
ev = Event::new
|
||||
ev.title = title_link.attr("title").text
|
||||
ev.url = URI.join url, title_link.attr("href")
|
||||
ev.date = time
|
||||
events << ev
|
||||
end
|
||||
|
||||
ical = ERB::new <<~EOF
|
||||
BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
METHOD:PUBLISH
|
||||
X-WR-TIMEZONE;VALUE=TEXT:Europe/Berlin
|
||||
<% events.each do |ev| %>
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:<%= ev.title %>
|
||||
DTSTART:<%= fmt_time ev.dtstart %>
|
||||
DTEND:<%= fmt_time ev.dtend %>
|
||||
UID:<%= ev.url %>
|
||||
URL:<%= ev.url %>
|
||||
LOCATION:<%= ev.location %>
|
||||
END:VEVENT
|
||||
<% end %>
|
||||
END:VCALENDAR
|
||||
EOF
|
||||
|
||||
puts ical.result
|
Loading…
Reference in New Issue