+
+ |
+$today_long |
+ |
+
+
EOF
close (INDEX);
}
@@ -237,7 +289,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);
}
@@ -268,10 +321,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
@@ -282,7 +335,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;
}
@@ -315,10 +368,7 @@ 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;
@@ -328,3 +378,59 @@ sub fetchDates () {
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
+
+
|