#!/usr/bin/perl -w # # Build the web interface for access to Doctor Who episodes I've # accumulated... # # Working on this - want to output new table and header when the doctor # changes as well as a button and description info for that doctor. # Probably should special case the doctors revisited episodes to put # them first for each doctor (Perhaps add a special sortdate attribute # to override airdate for sort, but not for print). use strict; use Data::Dumper; # Get PATH set to include this script's directory and other useful bits my $newpath=`dirname $0`; chomp($newpath); $newpath=`$newpath/echo-path`; chomp($newpath); $ENV{'PATH'}=$newpath; my $verbose = (scalar(@ARGV) == 1) && ($ARGV[0] eq "-v"); # Update the database file with latest information system("build-db"); my $topdir="/huge/vids"; my $whodir="$topdir/DoctorWho"; my $dbdir="$whodir/.data"; my $dbfile="$dbdir/allinfo.txt"; my $doctorfile="$dbdir/doctors.txt"; my $webindex="$whodir/index.html"; my %db; my %doctors; # Now read in the database of all the episode information my $fh; my $r; if (open($fh, '<', $dbfile)) { while (<$fh>) { chomp; if (/^\[(.+)\]$/) { my $basename = $1; $r = {}; $db{$basename} = $r; } elsif (/^([A-Za-z0-9_]+)=(.+)$/) { if (defined($r)) { my $key = $1; my $val = $2; $r->{$key} = $val; } } } close($fh); undef($fh); undef($r); } # And all the doctor information if (open($fh, '<', $doctorfile)) { while (<$fh>) { chomp; if (/^\[(.+)\]$/) { my $docname = $1; $r = {}; $doctors{$docname} = $r; } elsif (/^([A-Za-z0-9_]+)=(.+)$/) { if (defined($r)) { my $key = $1; my $val = $2; $r->{$key} = $val; } } } close($fh); undef($fh); undef($r); } # Build the index.html file from the information in the database my $tempfile="$webindex.$$"; my $htm; open($htm, '>', $tempfile) || die "Cannot write $tempfile : $!\n"; print $htm <<'HEADER';
"; if (! defined($d)) { print $htm "General Wibbly-Wobbly, Timey-Wimey, Spacey-Wacey stuff..
\n"; print $htm "\
\n"; } else { my $dr = $doctors{$d}; my $di = $dr->{'image'}; my $dw = $dr->{'which'}; print $htm "$d: The $dw Doctor.\n"; print $htm ""; my $companions=$dr->{'companions'}; if (defined($companions)) { my $cp; foreach $cp (split(/,/,$companions)) { print $htm "\ "; } } print $htm "
\n"; } print $htm "Original Airdate |
Minutes | Size | Flags | Description |
---|---|---|---|---|
$airdate | $minutes | $avisize | $notes | ${description}${flags} |
$showcount Episodes recorded"; if ($showsec > 0) { $showsec = int($showsec + 0.5); my $showmin = int($showsec / 60); $showsec -= ($showmin * 60); my $showhour = int($showmin / 60); $showmin -= ($showhour * 60); my $showday = int($showhour / 24); $showhour -= ($showday * 24); if ($showday > 0) { if ($showday == 1) { print $htm ", 1 day"; } else { print $htm ", $showday days"; } } if ($showhour > 0) { if ($showhour == 1) { print $htm ", 1 hour"; } else { print $htm ", $showhour hours"; } } if ($showmin > 0) { if ($showmin == 1) { print $htm ", 1 minute"; } else { print $htm ", $showmin minutes"; } } if ($showsec > 0) { if ($showsec == 1) { print $htm ", 1 second"; } else { print $htm ", $showsec seconds"; } } print $htm " of commercial free Doctor Who."; } print $htm "
\n"; print $htm "Icon legend:
\n"; print $htm <<'LEGEND';Flag | Description |
---|---|
Problems detected with this video. | |
New recording less than a week old. | |
New recording less than 24 hours old. | |
Video has glitch, would like to download a new copy. | |
Commercial removal not yet hand tweaked in this video. | |
Link to special notes on this video. | |
Missing attributes in database entry. | |
Reconstructed episode cobbled together. |