Wiki2rem
Revision as of 20:29, 23 September 2010 by Migratebot (talk | contribs) (Created page with "<source lang="text"> #!/usr/bin/perl
# wiki2rem
# Convert the PZI Networked Media course schedule from
# the HTML of Trac's wiki to a remind calendar file
=head1 NAME
...")
#!/usr/bin/perl
# wiki2rem
# Convert the PZI Networked Media course schedule from
# the HTML of Trac's wiki to a remind calendar file
=head1 NAME
wiki2rem - Convert the the PZI Networked Media course schedule from HTML to remind
=head1 SYNOPSIS
wiki2rem [URL]
wiki2rem < [FILE.html]
=head1 DEPENDENCIES
wget
=head1 AUTHOR
FC, 4/2010
=cut
# determine current year
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime time;
$year += 1900;
# fetch web page if URL is given as an argument
if ($ARGV[0]) {
# sanitize input
$ARGV[0] =~ s/[;|\s]//g;
@wiki_lines = split ("\n", `wget -O - $ARGV[0]`);
}
# or act as a filter on the HTML file supplied via STDIN
else {
while (<STDIN>) {
push @wiki_lines, $_;
}
}
# transform wiki schedule HTML page into a remind file, print to STDOUT
foreach $_(@wiki_lines) {
chomp;
if (/<h3 id/) {
/.*id=\"([A-Z][a-z]+)([A-Z][a-z]+)([0-9]+)\".*/;
$day = "$3 $2 $year";
}
if (/<li>/) {
/.*<li>([0-9]+)-([0-9]+) (.*)/;
$hour = $1.':00';
$duration = $2-$1.':00';
$message = $3;
$message =~ s/<[^>]*>//g;
if ($message) {
print "$day AT $hour DURATION $duration MSG $message\n";
}
}
}
# EOF