Skip to content

sepro/Flask-Comic-Collection

Repository files navigation

Flask Comic Collection

Flask Comic Collection runs on a lightweight server (e.g. a raspberry pi) and check if new episodes of your favorite webcomics have been released and combines them into a single website.

screenshot

Installation

First get the code from github

git clone https://github.com/sepro/Flask-Comic-Collection 

Go into the directory and set up a virtual environment

cd Flask-Comic-Collection
virtualenv --python=python3 venv

Next activate the virtual env and install the required python packages

source venv/bin/activate
pip install -r requirements.txt

Edit the config file

vim config.py

Create a database

python3 db_action.py create

Run the webserver

python3 run.py

Now no webcomics are added so you will be presented a mostly empty screen.

Adding webcomics

The file sites.json contains the details on which webcomics should be checked. Apart from a name (that will show up in Flask-Comic-Collection) you need to provide the base url, which is where new comics will appear regularly. Furthermore a regex needs to be provided that will pick up the URL of the comic (the image).

[
  {
    "base_url": "http:\/\/dilbert.com\/",
    "name": "Dilbert",
    "pattern": "\"(http:\/\/assets.amuniversal.com\/.*?)\""
  }
]

Defining the pattern is the most difficult thing to do (for more information on how to format a regex, check the documentation for the python re module). The whole pattern needs to match uniquely to the part of the site's html code that contains the url to the image. The section in between round brackets (http://assets.amuniversal.com/.*?) needs to match any url that might appear there.

You can run the update from the website (if ALLOW_UPDATE is True in config.py). Click the gears in the top right corner, and hit Update comics in the menu that appears.

Using CRON to update

After activating the virtual environment and configuring sites.json you can update the current comics using

python3 db_action.py update

However, it is recommended to set up a cron job once or twice a day to do this. Add (!) the following line (after updating the paths to match your installation) to /etc/crontab

0 5,17  * * *   sepro   cd /home/sepro/git/CoAgg && /home/sepro/git/CoAgg/venv/bin/python /home/sepro/git/CoAgg/db_action.py update

This will check twice a day for new comics (at 5 am and 5 pm)

Setting up the a Flask app with a webserver

This will depend on your system, the popular choice is to run nginx as a reverse proxy and use uWSGI or GUnicorn to run the app. There are a number of examples out there

Acknowledgements