use File::Spec::Functions qw(catfile catdir);
use POSIX qw(strftime);
+use Data::ICal;
+use Text::LevenshteinXS 'distance';
+
sub log_info (&) { print $_[0]->(), "\n"; }
sub run {
$info->{name} = prompt('What is the name of this talk?', $info->{name});
(my $slug = lc $info->{name}) =~ s/ /-/g;
$info->{slug} = prompt('What is the slug for this talk?', $slug);
+ my $act_data = {};
+ $act_data = get_act_talk_data($info->{name}, $bucket->{act_url})
+ if $bucket->{act_url};
+ if(exists $act_data->{talk_id}) {
+ $info->{act_talk_id} = $act_data->{talk_id};
+ $info->{details} = $act_data->{description};
+ }
+
+ $info->{details} = prompt('Enter a talk description', $info->{details});
$info->{bucket} = $bucket;
$info->{announcement} = $ann;
$videos{$video_file} = bless($info, 'App::IdiotBox::Video');
$bucket->videos->add($_) for values %videos;
}
+## Bug, this doesn't cope with files named foo.bar.5.23.mkv etc (multiple periods)
sub video_files_from_dir {
my ($class, $dir) = @_;
my %videos;
\%videos;
}
+## Parse the act timetable.ics to find talk data and description
+## (best guess based on talk name)
+sub get_act_talk_data {
+ my ($talk_name, $base_url) = @_;
+
+ my $act_url = URI->new($base_url . '/timetable.ics');
+ my $timetable < io($act_url);
+
+ my $act_schedule = Data::ICal->new(data => $timetable)
+ or die "Can't parse timetable.ics: $!";
+
+ my $target = "Things I learned from users";
+
+ my $mangled_target = uc $target;
+ $mangled_target =~ s/\W//g;
+
+ my @possibles;
+
+ for my $entry (@{$act_schedule->entries}) {
+ my $title = $entry->property('SUMMARY')->[0]->decoded_value;
+
+ my $description = $entry->property('DESCRIPTION')->[0]->decoded_value;
+
+ my $eid = $entry->property('URL')->[0]->decoded_value;
+ $eid =~ s!/$!!;
+ $eid =~ m!.*/(.*?)$! or die "Couldn't find last component in $eid";
+ $eid = $1;
+
+ my $mangled_title = uc $title;
+ $mangled_title =~ s/\W//g;
+
+ my $score = (length($mangled_title) - distance($mangled_title, $mangled_target))/length($mangled_title);
+ # print "Score for $mangled_title vs $mangled_target = $score\n";
+
+ push @possibles, {
+ score => $score,
+ title => $title,
+ description => $description,
+ event_id => $eid
+ };
+ }
+
+ @possibles = sort {$b->{score} <=> $a->{score}} @possibles;
+
+
+ print STDERR "ye2010/$target/ http://conferences.yapceurope.org/ye2010/talk/$possibles[0]{event_id}\n";
+
+ return $possibles[0];
+
+}
+
+
1;
--- /dev/null
+CREATE TABLE buckets (
+ slug TEXT NOT NULL PRIMARY KEY,
+ name TEXT NOT NULL,
+ act_url TEXT
+);
+
+CREATE TABLE announcements (
+ id INTEGER NOT NULL PRIMARY KEY,
+ made_at DATETIME NOT NULL,
+ bucket_slug TEXT REFERENCES buckets(slug)
+);
+
+CREATE TABLE videos (
+ slug TEXT NOT NULL,
+ bucket_slug TEXT NOT NULL REFERENCES buckets(slug),
+ name TEXT NOT NULL,
+ author TEXT NOT NULL,
+ act_talk_id INTEGER,
+ details TEXT NOT NULL DEFAULT '',
+ announcement_id INTEGER NOT NULL,
+ PRIMARY KEY (slug, bucket_slug),
+ FOREIGN KEY (announcement_id, bucket_slug)
+ REFERENCES announcements(id, bucket_slug)
+);