Skip to main content

Anilist Python module that allows you to search up and retrieve anime/manga/characters/etc info. (No login required)

Project description

AnilistPython

Anilist Python library that allows you to easily search up and retrieve anime, manga, animation studio, and character information. This library is both beginner-friendly and offers the freedom for more experienced developers to interact with the retrieved information.

Overview

This library is currently developed by a team of one and many operations in the library are yet to be optimized. However, the current version (0.0.8) has been partially tested and it is completely functional at its current state. The code base drew a lot of inspiration from the PyMoe library which mainly offers data block retrieval with no auto json parsing.

Currently, only anime and character data retrival has been optimized for beginner-friendly data parsing.

How to use?

Step One: Library Installation

pip install AnilistPython==0.0.8

Step Two: Instance Creation

from AnilistPython import Anilist
anilist = Anilist()

Step Three: Usage

Starting off, there are a set of commands optimized for auto json parsing. Currently, they are only available for anime and characters. All of the following functions uses Anilist's new GraphQL API.

# ANIME
anilist.getAnimeInfo("Code Geass")             # returns a dictionary with anime info (parsed)
anilist.getAnimeID("ReZero")                   # returns Re:Zero's ID on Anilist
anilist.printAnimeInfo("Madoka Magica")        # prints all information regarding the anime Madoka Magica

#CHARACTER
anilist.getCharacterInfo("Emilia")             # returns a dictionary containing the info about Emilia-tan (parsed)
anilist.getCharacterID("Milim")                # returns character Milim's ID on Anilist
anilist.printCharacterInfo("Misaka Mikoto")    # prints all information regarding the character Misaka Mikoto (desc not parsed)

Once the commands above are executed, the program will automatically search and retrieve the request information. When multiple targets are found, three results will be shown in the terminal. Pick your desired character to retrieve their information.

1. Madonna (Movie)
2. Mahou Shoujo Madoka鈽哅agica
3. Hanoka
Please select the anime that you are searching for in number: <enter 1, 2, or 3>

For retrieved dictionaries from the the step above by using .getAnimeInfo() or .getCharacterInfo(), the data has be parsed and reformatted into more readable and easily accessible json objects. The keys to the correspounding dictionaries are as follows:

#ANIME                 #CHARACTER
- name_romaji          - first_name
- name_english         - last_name
- starting_time        - native_name 
- ending_time          - desc 
- cover_image          - image
- banner_image
- airing_format
- airing_status
- airing_episodes
- season
- desc
- average_score
- genres
- next_airing_ep

One simple example would be:

>>> extracted_data = anilist.getAnimeInfo("Tensei Slime")     # retrieves dictionary containing anime data
>>> print(extracted_data["name_romaji"])                      # applies the key "name_romaji"
Tensura Nikki: Tensei Shitara Slime Datta Ken                 # Ta-Da!

Here are some more advanced usages:

(Works for all anime, manga, characters, studio, and staff)

Retrieved data takes the form of json objects or lists of json objects. In order to retrieve the desired data, title/item ID is required. Data extraction does not accept string inputs and can only take int parameters as ID's. The process of chaining ID request and data request together has been included in the optimized functions above, but this is not built-in if you would like to directly request for data blocks in the form or orginial/raw json objects.

Note that it is possible to directly call functions from the subclasses of the driver code in ExtractID and ExtractInfo with the Anilist instance.

# RETRIEVING JSON OBJ CONTAINING DATA
anilist.extractInfo.anime(105333)           # Return data on Dr.Stone
anilist.extractInfo.manga(85737)            # Return data on Re:Zero kara Hajimeru Isekai Seikatsu
anilist.extractInfo.staff(103509)           # Return data on Hiroyuki Sawano
anilist.extractInfo.studio(43)              # Return data on ufotable
anilist.extractInfo.review(2113)            # Return review #2113 and format the review body in HTML

# RETRIEVING JSON OBJ CONTAINING ID NUM
anilist.extractID.anime("Owari No Seraph")  # Anime search results for King.
anilist.extractID.manga("Sakurasou")        # Manga search results for Sakurasou.
anilist.extractID.character("Subaru")       # Character search results for Subaru.
anilist.extractID.staff("Keisuke")          # Staff search results for Keisuke.
anilist.extractID.studio("Ghibli")          # Studio search result for Ghibli.

The functions above returns raw json objects that requires extensive parsing before it can be used. Note that .extractID does NOT directly return the ID of the given item. Instead, it returns a json object that contains the item's ID number. The only useful information from .extractID is the ID number of the provided item. All other data retrieved from ExtractID can be found in ExtractInfo with the latter having more details.

Parsing the json obj is annoying. For example, if you would like to view the character desc of Rem:

data = anilist.extractID.character("Rem")

for i in range(len(data["data]["Page"]["characters']):
  first_name = data["data"]["Page"]["characters"][i]['name']["first"]
  last_name = data["data"]["Page"]["characters"][i]['name']["last"]
  print(f"{first_name}, {last_name}")

 user_input = int(input("Select the anime character that you are trying to find: "))
 <checks for corner cases>

 info = anilist.extractInfo.character(data['data']['Page']["characters'][user_input - 1]["id"]
 print(info["data"]["Character"]["description"])

However, worry not! I will be sure to push out more user-friendly functions like the ones I showed at first.

In addition to that, pagination is taken cared of by the new API. By default you retrieve three results but this can be edited to your liking:

extractID(term, page = 1, perpage = 3)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

AnilistPython-0.0.8.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

AnilistPython-0.0.8-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file AnilistPython-0.0.8.tar.gz.

File metadata

  • Download URL: AnilistPython-0.0.8.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.2

File hashes

Hashes for AnilistPython-0.0.8.tar.gz
Algorithm Hash digest
SHA256 a2ba74b93e503787e6560906e4521e1ce04d674cf1af24ec1035534a8f873fa3
MD5 ad78cbcc46a9bd6613c64d1f93b2913c
BLAKE2b-256 fe2dbb85373be92078d988992b192bbaa9e5c8c0242436a8d8ee2347bc15630e

See more details on using hashes here.

File details

Details for the file AnilistPython-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: AnilistPython-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.2

File hashes

Hashes for AnilistPython-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 34b87203969c8f4ebbfa41e7981af600491210c68baf5b67560d685d8fab0f65
MD5 5d60fe1c693ba895555f3a029054816a
BLAKE2b-256 a5fe3cc5e55e4f255f59e5c4430e280e1763575a807e74cfa0725d68e2974e03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page