--- /dev/null
+package HTML5TV::hCalendar;
+
+use warnings;
+use strict;
+
+use File::Slurp;
+use HTML::TreeBuilder;
+use Data::Dump qw/dump/;
+
+sub new {
+ my $class = shift;
+ my $path = shift || die "need path to hCalendar";
+
+ my $tree = HTML::TreeBuilder->new;
+ $tree->parse_file($path);
+
+ my $self = {
+ path => $path,
+ tree => $tree,
+ };
+ bless $self, $class;
+ return $self;
+}
+
+# we don't want DESTROY to fallback into AUTOLOAD
+sub DESTROY {}
+
+our $AUTOLOAD;
+sub AUTOLOAD {
+ my $self = shift;
+
+ my $class = $AUTOLOAD;
+ $class =~ s/.*://;
+
+warn "XX $class\n";
+
+ if ( my $vevent = $self->{tree}->look_down( class => 'vevent' ) ) {
+ if ( my $el = $vevent->look_down( class => $class ) ) {
+ return $el->as_trimmed_text;
+ } else {
+ die "can't find vevent.$class in ", $self->{path};
+ }
+ } else {
+ die "can't find vevent in ", $self->{path};
+ }
+
+}
+
+1;
--- /dev/null
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use Test::More tests => 7;
+
+use lib 'lib';
+
+BEGIN {
+ use_ok( 'HTML5TV::hCalendar' );
+}
+
+my $path = shift @ARGV || 'media/hCalendar.html';
+
+ok( my $hcal = HTML5TV::hCalendar->new( $path ), "new $path" );
+
+foreach my $class ( qw/organiser summary url dtstart description/ ) {
+ ok( defined( my $text = $hcal->$class ), $class );
+ diag "$class: $text";
+}
+