getcomics.pl - My Daily Dose of Comics

Download this program

SYNOPSIS

        getcomics.pl            # Normal case, sends Email
        getcomics.pl -d 1       # Use this for debugging
        getcomics.pl -d 2       # Debugging. Saves comic in *.page files
        getcomics.pl -d 1 -grab # Debugging. Read comic from *.page files

DESCRIPTION

Uss this program manually or in a cron job to figure out the URLs for your favorite comic and send you an Email. The program fetches the comic and tries to find the image of the comic so you don't need to look at all that extra advertising.

The program reads a configuration file which defines the users to receive the Email as well as the rules for finding the comics.

Output from the program is an Email sent to a list you designate. The body of the Email looks like this:

  TO: tom@somecompany.com tony@somecompany.com
  Subject: From the Comic Archives

  Don't bother telling me if any of these URLs fail:

  Dilbert:
    http://www.dilbert.com/ (Unable to find comic in URL)

  Calvin and Hobbes:
    http://images.ucomics.com/comics/ch/1993/ch930822.gif

  Doonesbury:
    http://images.ucomics.com/comics/db/2004/db040822.gif

  Garfield:
    http://garfield.ucomics.com/garfield/gaview.cfm (Unable to fetch initial page)

  Hagar the Horrible:
    http://www.kingfeatures.com/features/comics/hagar/aboutMain.htm

  User Friendly:
    http://www.userfriendly.org/cartoons/archives/04aug/xuf007042.gif

  Non-Sequitur:
    http://images.ucomics.com/comics/nq/2004/nq040822.gif

OPTIONS

-cfgfile file
Specifies the path to the configuration file. The default is 'getcomics.txt' found in the same directory where this program is found.

-debug N
Enables debugging to show you what was found. If N is larger than 1, the comic page is saved in a file with an extension of '.page'.

-email address
Allows you to override the destination Email address found in the configuration file. This is useful when debugging.

-grab
Specifies the program should fetch the comic from a file with the extension of .page. See also -save This is useful when debugging.

-help
Shows you this help file.

-save
Specifies the program should save the comic as a file with the extension of .page. See also -grab. This is useful when debugging.

PARAMETERS

The program takes no parameters.

CONFIG FILE

The configuration file consists of two sections. The first follows a comment line ``#User_Definitions'' and consists of a set of Email addresses to send the message to. All users get the same Email

The second section follows a comment line ``#Comic_Definitions'' and defines the comics to be fetched. Each line consists of four parts, each separated by the character '|'.

comicname
is the name of the comic (e.g. Dilbert)

URL
is URL of the page to fetch. Be sure to specify '/' after the hostname.

imagemask
is the string to find in page we fetched. This is Perl regular expression and may result in a full, partial or relative URL Note that this MUST contain up to three Perl grouping parenthesies.

prefixurl
Specifies a prefix for string match returned by imagemask This should contain %1%, %2% and %3% to substitute for matches in imagemask. Special support added for Javascript routines. Do these substitutions:
  • %YYYY% - year as four digits
  • %YY% - year as two digits
  • %MM% - month as two digits
  • %DD% - day as two digits

Here's a sample file. Notice the comic defintions are generally very long and have been broken after the '|' characters:

  #
  #     Send getcomics.pl Email to these addresses
  #
  #User_Definitions
  tom@somecompany.com
  tony@somecompany.com
  #Comic_Definitions
  #
  Dilbert            |
    http://www.dilbert.com/|
    (/comics/dilbert/archive/images/dilbert\d{13,14}.gif)|
    http://www.dilbert.com/%1%
  Calvin and Hobbes  |
    http://www.ucomics.com/calvinandhobbes/viewch.cfm|
    (http://images.ucomics.com/comics/ch/..../ch.......gif)|
    %1%
  Doonesbury         |
    http://www.doonesbury.com/strip/dailydose/|
    (http://images.ucomics.com/comics/db/..../db.......gif)|
    %1%
  Garfield           |
    http://www.garfield.com/comics/comics_todays.html|
    var stripName\s*=\s*.(.+/\d\d\d\d)|
    %1%/ga%YY%%MM%%DD%.gif
  Hagar the Horrible |
    http://www.kingfeatures.com/features/comics/hagar/aboutMain.htm|
    (.)|
    http://www.kingfeatures.com/features/comics/hagar/aboutMain.htm
  User Friendly      |
    http://www.userfriendly.org/static/|
    (cartoons/archives/\d\d.../.{9}\.gif)|
    %1%
  Non-Sequitur       |
    http://www.non-sequitur.com/|
    http://images.ucomics.com/comics/(nq/\d{4}/nq\d{6}.gif)|
    http://images.ucomics.com/comics/
    %1%

EXIT

If no fatal errors are detected, the program exits with a return code of 0.

AUTHOR

Written by Terry Gliedt <tpg@hps.com> in 1994-2005. This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; See http://www.gnu.org/copyleft/gpl.html