Adding New Comics

Adding new comics is relatively easy. By creating a simple text file with a couple of lines in the configs directory of your Comic Gopher installation you can add a new comic to Comic Gopher.

To fetch a comic Comic Gopher generally only needs to know two things: what page the current comic is on and how to find the comic image.

Once you have added a new comic, please consider contributing it to the community by adding a page for the comic on this wiki with your configuration and linking to that page from the Community section of the Supported Comics page.

A Simple Configuration

Below is a barebones example configuration for the make believe Foobar Comic:

[Foobar Comic]
start_page = http://foobar.com/
image = http://foobar.com/comics/%y%m%d.png

Every configuration should start with the name of the comic in brackets. The start_page line defines the main page or home page of the comic site. The image line defines the location of the current image. Saving this configuration to a text file named "Foobar Comic.txt" in your Comic Gopher configs folder would allow you to subscribe to Foobar Comics. The name displayed in Comic Gopher is actually grabbed from the name of the text file (except in one case, see below) - so name the file appropriately.

The image line is where some of the magic happens. For many comics, the images are saved with file names related to their publish date. The image line captures this using the % notation. The most common %'s you will use are the following:

  • %Y is the year in 4-digit format, eg. 2008
  • %y is the year in 2-digit format, eg. 08
  • %m is the month in 2-digit format, eg. 02
  • %d is the day in 2-digit format, eg. 10

So from our image line above, the value http://foobar.com/comics/%y%m%d.png captures images like http://foobar.com/comics/080207.png, which would be the comic image for Feb 7, 2008.

So in our simple example you need to determine how the image is named. Getting this information is pretty easy. Just go to the website of the comic you want to add and right-click on the comic image and select View Image (in Firefox). Once the image is displayed your URL location bar will display the path to the image. You just need to reverse-engineer the image name format into the above format.

Full Configuration Options

The above configuration works well for images with predictable naming schemes. In cases where the image names are not predictable you will need to use some other configuration lines.

The below example shows pretty much all the configuration lines, many of which are optional. You will never need all these lines because the correct two or three lines can always tell Comic Gopher how to fetch the comic. Typically you only need start_page, current_page, one of image or image_regex and one of page or page_regex. Although sometimes, as in the above simple configuration, just the start_page and image lines will do.

[Foobar Comic]
name = Foobar Comic
start_page = http://foobar.com/
current_page = http://foobar.com/
page = http://foobar.com/comics/comic%y%m%d.php
image = http://foobar.com/comics/%y%m%d.png
page_regex = comic.*\.php
image_regex = comics/fb.*\.png

The name line sets the comic display name used in Comic Gopher. This is necessary when the name of the comic cannot be written as the configuration file name because the operating system does not allow certain characters to be used in file names.

The current_page line defines the page where the current comic is always displayed.

The page line defines the location of the page displaying the current comic in case that page is not always the same. You can use the same % notation on this line as you do on the image line.

If you don't know what a regular expression is and you aren't feeling like learning a little about them then you might want to skip the next part and go to the Gotchas at the end of the page.

The page_regex line defines a regular expression that captures how the page href values look. This is useful for finding pages that don't follow a predictable naming scheme.

The image_regex line defines a regular expression that captures how the image src values look. This is useful for finding images that don't follow a predictable naming scheme.

Getting the page_regex and image_regex will usually require a bit more work than finding the page and image information. You will need to View the Source of the comic website pages and look for the href value in page link tags for page_regex and the src value in the comic image tags for image_regex. Once you have these values you need to come up with regular expressions that will match the pages and images, see the Python regular expression page for reference. Generally you can just copy the href or src value and replace any periods with "\." and any random looking letter or number sequences with ".*". So the image_regex above, "comics/fb.*\.png" could have been devised from images src values like "comics/fb12398.png".

You might also find it useful to check out the existing configurations in your configs folder for examples of working configurations.

Gotchas

  • If the comic name has a / in it, omit the slash from the [Comic Name] line, eg. [OK/Cancel] becomes [OK Cancel]. The /'s cause problems with an extra 'feature' of the underlying configuration loader.
  • Configuration file names in the config folder must be unique. So you can't have Foobar.txt in two different folders in the config folder, you will need to rename one of them.
  • Is your new configuration not showing up in Comic Gopher? Try refreshing the page by hitting F5.
  • Does the comic image come in different file types on different days (eg. Sundays are color jpg images and other days are black and white gif images)? Use \.(gif|jpe?g|png) as the last part of your image_regex to catch all the different image types.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License