Giter VIP home page Giter VIP logo

comics's Introduction

comics


GoComics API wrapper

pypiv Python 3.7+ continuous-integration Licence

Installation

pip install comics

Quick start

Find and download the Calvin and Hobbes comic strip published on January 2, 1990:

import comics

ch = comics.search("calvinandhobbes").date("January 2, 1990")
ch.download("calvinandhobbes.png")

Find comics

Available comics can be found using the directory class:

import comics

# List available comics - total of 470
comics.directory.listall()
# >>> ("1-and-done", "9-chickweed-lane-classics", "9chickweedlane", "9to5", ... )

# Find endpoints for Calvin and Hobbes
comics.directory.search("Calvin and Hobbes")
# >>> ("calvinandhobbes", "calvinandhobbesenespanol")

First, pass the desired endpoint to comics.search. For example, to search for Calvin and Hobbes comics in english use comics.search("calvinandhobbes"); for spanish, use comics.search("calvinandhobbesenespanol").

Search and download comics

Then, search for a comic strip using the date or random_date method:

import comics

# Get a Calvin and Hobbes comic strip by date
ch = comics.search("calvinandhobbes").date("2013-05-13")  # Also accepts datetime object

# Get a random Calvin and Hobbes comic strip
random_ch = comics.search("calvinandhobbes").random_date()

Finally, show, download, or stream the comic strip:

# Show comic strip - opens in Jupyter notebook or default image viewer application
ch.show()

# Download comic strip - defaults to {endpoint}.png if an export path is not provided
# E.g., a Calvin and Hobbes comic strip will be exported as "calvinandhobbes.png" in the current working directory
ch.download()

# Stream comic strip - useful if custom image content manipulation is desired
ch.stream()

Attributes

An instantiated search class will have the following public attributes:

import comics

garfield = comics.search("garfield")
garfield.endpoint
# >>> "garfield"
garfield.title
# >>> "Garfield"
garfield.start_date
# >>> "1978-06-19"

An instantiated search class with date or random_date will have the following public attributes:

import comics

garfield = comics.search("garfield").date("08/20/2000")
garfield.endpoint
# >>> "garfield"
garfield.title
# >>> "Garfield"
garfield.date
# >>> "2000-08-20"
garfield.url
# >>> "https://www.gocomics.com/garfield/2000/08/20"
garfield.image_url
# >>> "https://assets.amuniversal.com/6694c52099bd01365606005056a9545d"

Exceptions

An exception will be thrown if the queried date is unregistered or before the comic's origin date:

import comics
from comics.exceptions import InvalidDateError

try:
    peanuts = comics.search("peanuts").date("1900-01-01")
    peanuts.download()
except InvalidDateError:
    print("Whoops, an invalid date was queried.")

An exception will be thrown if the queried endpoint is unregistered:

import comics
from comics.exceptions import InvalidEndpointError

try:
    invalid_comic = comics.search("invalid_endpoint").date("2000-01-01")
    invalid_comic.download()
except InvalidEndpointError:
    print("Whoops, an invalid endpoint was queried.")

Contribute

Support

If you are having issues or would like to propose a new feature, please use the issues tracker.

License

This project is licensed under the MIT license.

comics's People

Contributors

irahorecka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

comics's Issues

Import error libopenjp2.so.7

I am trying to use this package but I am running into this error:
ImportError: libopenjp2.so.7: cannot open shared object file: No such file or directory

My setup:
Raspberry 3 Mod. b
Raspian GNU/linux 11 (bullseye)
Python 3.9.2 in virtual environment

Thank you for the support!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.