Commit ccef0eb2 authored by citronalco's avatar citronalco
Browse files

update readme

add kap942ics.pl
parent 3351b4f9
......@@ -14,14 +14,14 @@ Source: http://www.eventhalle-westpark.de/das-programm
Script: `eventhalleWestpark2ics.pl`
Demo: http://www.geierb.de/~geierb/kalender/eventhallewestpark.ics
Demo: https://www.geierb.de/~geierb/kalender/eventhallewestpark.ics
### Kulturzentrum Halle Neun, Ingolstadt
Source: http://halle9-ingolstadt.de
Script: `halle92ics.pl`
Demo: http://www.geierb.de/~geierb/kalender/halle9.ics
Demo: https://www.geierb.de/~geierb/kalender/halle9.ics
### Intro.de
Source: http://www.intro.de
......@@ -35,7 +35,16 @@ Source: http://www.br.de/radio/bayern2/sendungen/zuendfunk/veranstaltungen-praes
Script: `zuendfunk2ics.pl`
Demo: http://geierb.spdns.de/~geierb/kalender/zuendfunk-tipps.ics
Demo: https://geierb.de/~geierb/kalender/zuendfunk-tipps.ics
### KAP94, Ingolstadt
Source: http://www.kap94.de/events/month/
Script: `kap942ics.pl`
Demo: https://geierb.de/~geierb/kalender/kap94.ics
Usage
-----
......
#!/usr/bin/perl
# geierb@geierb.de
# GPLv3
use strict;
use WWW::Mechanize;
use HTML::Entities;
use HTML::TreeBuilder;
use Data::ICal;
use Data::ICal::Entry::Event;
use utf8;
use warnings;
# KAP94 already provides basic information in ics format via a hidden link
# This script filters out simple "belegt" events, sets location to the full address and adds the description
my $url="http://www.kap94.de/events/?ical=1";
# avoid "wide character" warnings
binmode STDOUT, ":utf8";
my $mech=WWW::Mechanize->new();
$mech->get($url) or die($!);
my $kap94calendar=Data::ICal->new(data=>$mech->content());
my $calendar=Data::ICal->new();
$calendar->add_properties(method=>"PUBLISH",
"X-PUBLISHED-TTL"=>"P1D",
"X-WR-CALNAME"=>"KAP94",
"X-WR-CALDESC"=>"KAP94 Veranstaltungen");
foreach my $entry (@{$kap94calendar->entries}) {
# skip simple "belegt" events
next if ($entry->property('summary')->[0]->value=~/^belegt$/);
my $url=$entry->property('url')->[0]->value;
my $description=$entry->property('description')->[0]->value;
# if no description but event's url given, get description from url
if ((!$description) and ($url)) {
$mech->get($url);
my $tree=HTML::TreeBuilder->new_from_content($mech->content());
$entry->add_properties('description'=>join("\n",map { $_->as_trimmed_text(extra_chars=>'\xA0'); } $tree->look_down('_tag'=>'div','id'=>'event-single-content')->find('p')));
}
# fix location
$entry->add_properties('location' =>"KAP94, Westliche Ringstr. 91, 85049 Ingolstadt");
$calendar->add_entry($entry);
}
print $calendar->as_string;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment