Generated on: $sysDate
-Version: $ver
+Version: $ver
+Config Version: $comicConfigVer
+CVS: http://demandred.dyndns.org/cgi-bin/cvsweb/comics/
@@ -204,9 +278,12 @@ sub checkDir ($$) {
#######################################################################
sub writeTitle ($$) {
my ( $date ) = @_;
- my $indexFile = $indexDir . "/index-" . $date->{'year2'} . $date->{'mon2'} .
- $date->{'day2'} . ".html";
- my $today = $date->{'mon'} . "/" . $date->{'day'} . "/" . $date->{'year'};
+ my $sd = substr( join( '', $days[$date->{'dow'}] ), 0, 3 );
+ my $indexFile = $indexDir . "/index-" . $date->{'year2'} .
+ $date->{'mon2'} . $date->{'day2'} . "-" .
+ $sd . ".html";
+ my $today = $days[$date->{'dow'}] . " " . $date->{'mon'} . "/" . $date->{'day'} . "/" . $date->{'year'};
+ my $today_long = Date_to_Text_Long(Today());
open INDEX, ">$indexFile";
print INDEX <
+
+
Daily Comics for $today
-Daily Comics for $today
+
+
+ |
+$today_long |
+ |
+
+
EOF
close (INDEX);
}
@@ -236,7 +321,8 @@ sub directDownload ($$) {
my $cDir = $date->{'mon2'} . $date->{'year2'};
my $cDate = $date->{'day2'};
- my $cmd = "wget -q $file --referer=\"" . $comics->{$comic}{'url'} ."\" --user-agent=\"$USER_AGENT\" -O - | /usr/bin/convert - jpeg:images/$cDir/$comic-$cDate.jpg";
+ my $cmd = "wget -q $file --referer=\"" . $comics->{$comic}{'url'} ."\" --user-agent=\"$USER_AGENT\" -O - | /usr/bin/convert - jpeg:images/$cDir/$comic-$cDate.jpg";
+
return system($cmd);
}
@@ -247,7 +333,10 @@ sub indexDownload ($$) {
my ( @lines, $comicLine, $mainURL );
my $comicIndex = "indexes/index.$comic";
- `wget -q $comics->{$comic}{'url'} -O $comicIndex`;
+ my $wget_cmd = "wget -q --referer=\"$comics->{$comic}{'url'}\" " .
+ "--user-agent=\"$USER_AGENT\" " .
+ "$comics->{$comic}{'url'} -O $comicIndex";
+ system($wget_cmd);
if ( ! open FILEN, "<$comicIndex" ) {
return "ERROR: Can't open index file for " . $comics->{$comic}{'fullName'} .
@@ -267,10 +356,10 @@ sub indexDownload ($$) {
## Find the comic strip URL based on the specified regex in the search
##
foreach my $line (@lines) {
- if ( $line =~ m/$comics->{$comic}{'search'}/ ) {
+ if ( $line =~ m/$comics->{$comic}{'search'}/i ) {
$comicLine = $1; chomp $comicLine;
}
- }
+ }
##
## Save the file to the appropriate directory
@@ -281,7 +370,7 @@ sub indexDownload ($$) {
if ( $comicLine ) {
if ( $comicLine =~ m/(gif|jpg|png)/i ) { $comics->{$comic}{'ext'} = $1; }
my $comicURL = ( $comicLine =~ m/http/ ) ? $comicLine : $mainURL . $comicLine;
- my $cmd = "wget --user-agent=\"$USER_AGENT\" --referer=\"" . $comics->{$comic}{'url'} . "\" -q $comicURL -O - | /usr/bin/convert - jpeg:images/$cDir/$comic-$cDate.jpg";
+ my $cmd = "wget --user-agent=\"$USER_AGENT\" --referer=\"" . $comics->{$comic}{'url'} . "\" -q $comicURL -O images/$cDir/$comic-$cDate.$comics->{$comic}{'ext'}";
system( $cmd );
return 0;
}
@@ -314,16 +403,71 @@ sub parseComic ($$) {
sub fetchDates () {
my %dates = ();
- ($dates{'day'}, $dates{'mon'}, $dates{'year'}, $dates{'dow'}) = (localtime)[3,4,5,6];
-
- ## If you missed a day or two, reflect it here:
- $dates{'day'} -= $days_ago; ## <-- 5 days ago
+ ($dates{'day'}, $dates{'mon'}, $dates{'year'}, $dates{'dow'}) = (localtime(time - (86400 * $days_ago )))[3,4,5,6];
$dates{'year'} += 1900;
$dates{'year2'} = substr $dates{'year'}, 2, 2;
$dates{'day2'} = ( $dates{'day'} < 10 ) ? "0" . $dates{'day'} : $dates{'day'};
$dates{'mon'}++;
$dates{'mon2'} = ( $dates{'mon'} < 10 ) ? "0".$dates{'mon'} : $dates{'mon'};
+ my @days = qw/ Sunday Monday Tuesday Wednesday Thursday Friday Saturday /;
+ $dates{'wday'} = $days[$dates{'dow'}];
return %dates;
}
+
+###############################################################################
+##
+## &fetchOptions( );
+##
+## Grab our command line arguments and toss them in to a hash
+##
+###############################################################################
+sub fetchOptions {
+ my %opts;
+
+ &GetOptions(
+ "days:i" => \$opts{'days'},
+ "help|?" => \$opts{'help'},
+ "man" => \$opts{'man'},
+ ) || &pod2usage( );
+ &pod2usage( ) if defined $opts{'help'};
+ &pod2usage( { -verbose => 2, -input => \*DATA } ) if defined $opts{'man'};
+
+ return %opts;
+}
+
+__END__
+
+=head1 NAME
+
+fetch.pl - Fetches comics and places them all locally in a single html file.
+
+=head1 SYNOPSIS
+
+fetch.pl [options]
+
+Options:
+ --days,d Fetch comics from X days ago
+ --help,? Display the basic help menu
+ --man,m Display the detailed man page
+
+=head1 DESCRIPTION
+
+=head1 HISTORY
+
+=head1 AUTHOR
+
+Nicholas DeClario
+
+=head1 BUGS
+
+This is a work in progress. Please report all bugs to the author.
+
+=head1 SEE ALSO
+
+=head1 COPYRIGHT
+
+=cut
+
+
|