Commit 484ad10b authored by Bernhard Geier's avatar Bernhard Geier
Browse files

kap94: skip broken links in calendar

parent db12138c
...@@ -12,6 +12,8 @@ use DateTime; ...@@ -12,6 +12,8 @@ use DateTime;
use Data::ICal; use Data::ICal;
use Data::ICal::Entry::Event; use Data::ICal::Entry::Event;
use Try::Tiny;
use utf8; use utf8;
use warnings; use warnings;
...@@ -56,11 +58,13 @@ for (my $month=0;$month<$MAXMONTHS;$month++) { ...@@ -56,11 +58,13 @@ for (my $month=0;$month<$MAXMONTHS;$month++) {
my $description=$entry->property('description')->[0]->value; my $description=$entry->property('description')->[0]->value;
# if no description but event's url given, get description from url # if no description but event's url given, get description from url
if ((!$description) and ($url)) { if ((!$description) and ($url)) {
$mech->get($url); try {
my $tree=HTML::TreeBuilder->new_from_content($mech->content()); $mech->get($url);
$entry->add_properties( my $tree=HTML::TreeBuilder->new_from_content($mech->content());
'description'=>join("\n", map { $_->as_trimmed_text(extra_chars=>'\xA0'); } $tree->look_down('_tag'=>'div','id'=>'event-single-content')->find('p')) $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 # fix location
$entry->add_properties('location'=>"KAP94, Jahnstr. 1a, 85049 Ingolstadt"); $entry->add_properties('location'=>"KAP94, Jahnstr. 1a, 85049 Ingolstadt");
......
Markdown is supported
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