dhmd-veranstaltungen: add URL, LOCATION

This commit is contained in:
Astro 2021-09-08 22:54:37 +02:00
parent 6eac79f06f
commit 7965e1ba0f
1 changed files with 15 additions and 2 deletions

View File

@ -5,15 +5,26 @@ require 'open-uri'
require 'nokogiri'
require 'erb'
class Event
attr_accessor :data, :url
def initialize data, url
@data = data
@url = url
end
end
events = []
url = "https://www.dhmd.de/veranstaltungen/kalender/1/"
doc = Nokogiri::HTML URI.open(url)
doc.css("a.more").each do |details_link|
details = Nokogiri::HTML URI.open(URI.join url, details_link.attr('href'))
event_url = URI.join url, details_link.attr('href')
details = Nokogiri::HTML URI.open(event_url)
details.css("a.icon-termin").each do |icon|
ical = URI.open(icon.attr('href')).read()
ical.scan(/BEGIN:VEVENT\r\n(.+?)\nEND:VEVENT/m).each do |ev,|
ev = Event::new ev, event_url
events << ev
end
end
@ -26,7 +37,9 @@ ical = ERB::new <<~EOF
X-WR-TIMEZONE;VALUE=TEXT:Europe/Berlin
<% events.each do |ev| %>
BEGIN:VEVENT
<%= ev %>
<%= ev.data %>
URL:<%= ev.url %>
LOCATION:Hygienemuseum
END:VEVENT
<% end %>
END:VCALENDAR