mal4py


Namemal4py JSON
Version 0.1.4 PyPI version JSON
download
home_page
SummaryMAL API An unofficial MyAnimeList API for Python 3
upload_time2022-12-12 22:59:23
maintainer
docs_urlNone
author
requires_python>=3.9
licenseMIT License Copyright (c) 2022 AntoBlanco Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords api myanimelist mal anime manga
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Mal4py API Banner](https://image.myanimelist.net/ui/OK6W_koKDTOqqqLDbIoPAphlZzlTj5CPK0fFssPvFnc)
![Python Lang](https://pbs.twimg.com/media/DALAHaRVoAASaTr.png)
# MAL4Py 

MAL API
An unofficial MyAnimeList API for Python 3.
  
Currently, MAL4Py is a small package for download and sync information from MyAnimeList.

#### Version 0.1.4

## API Documentation
[MAL API v2 Beta Documentation](https://myanimelist.net/apiconfig/references/api/v2)

## Installation and Usage

To install the library:

```

pip install -U mal4py

```

To import the library:

```python

from mal4py import *

```

## Example

To call the API, first you need to create an object Auth.

#### Auth Login Example

  

```python

import  asyncio
from mal4py import Auth, get_new_code_verifier, MalToken

"""
	For all cases you must declarate Auth object
"""
# ID Client MAL App Android, recomend replace for own ID Client
auth = Auth("6114d00ca681b7701d1e15fe11a4987e") 
# if your APP has a Client Secret; OMIT in all other cases (i.e. you selected "Android", "iOS", or "Other" as App Type)
auth = Auth("my_clientID","my_clientSecret") 

# UNOFFICIAL WAY TO LOGIN
"""
	This way login can execute basic querys to MAL API, but only unstable_login can you edit user info.
"""

# If you use this way, must load Id Client MAL "6114d00ca681b7701d1e15fe11a4987e" others Id Client Don't Support way

# login with user and password unstable way
account = asyncio.run(auth.unstable_login("my_user","my_password"))

# Guest login without user and password unstable way
account = asyncio.run(auth.guest_login())


# OFFICIAL WAY TO LOGIN (recomended)
""" 
	OAUTH Way generate Code
"""
code_verifier = get_new_code_verifier()
url = auth.get_oauth_url(code_verifier)
print(url)

# Open returned url, accept oauth and use returned code to authorize

authorization_code = input('Copy-paste the Authorization Code: ').strip()
account = asyncio.run(auth.authorize_with_code(authorization_code,code_verifier))

"""
	Load Token saved previously
"""

# Load Token from saved String

jsontoken = '{"token_type":"Bearer","expires_in":xxx,"access_token":"my_access_Token","refresh_token":"my_refresh_token"}'
account = auth.authorize_with_json_string(jsontoken)

# Load Token from saved Dict

token = {"token_type":"Bearer","expires_in":xxx,"access_token":"my_access_Token","refresh_token":"my_refresh_token"}
account = auth.authorize_with_json_obj(token)

# Other way to Load Token load from MalToken object saved

mal_token = MalToken._from_json_string(jsontoken)
# Or
mal_token = MalToken._from_json_obj(token)
# Load MalToken
account = auth.load_token(mal_token)

```
You can generate Token and load usign this script of [ZeroCrystal](https://gitlab.com/-/snippets/2039434)

#### Search Query Example

```python

from mal import MalAccount


# Query Anime for all login types
# the query 'q' value must be minimum 3 characters

search = account.anime.get_details(anime_id=44511)
search = account.anime.get_list("chainsaw",limit=3)
search = account.anime.get_seasonal(2022,"winter",limit=3)
search = account.anime.get_ranking(limit=3)


# Query Anime for oAuth only or password and login user

search = account.anime.get_suggested(limit=3)


# Query Manga for all login types

search = account.manga.get_details(manga_id=13)
search = account.manga.get_list("chainsaw",limit=3)
search = account.manga.get_ranking(limit=3)


# Query Forum for all login types
# Actually MAL API have problems with integrity the object returned. (THIS BETA)

search = account.forum.get_board()
search = account.forum.get_topic_detail(topic_id=41)
search = account.forum.get_topics(q="love",subboard_id=2,board_id=0)


# Query User for only oAuth or user and password login 

search = account.user.get_my_info()
search = account.user.update_mangalist_status(13,{"status":"reading","is_rereading":False,"score":8,"num_volumes_read":1,"num_chapters_read":2,"priority":1,"num_times_reread":0,"reread_value":0,"tags":"Myread","comments":"Amazing Manga"})
search = account.user.delete_mangalist_item(13)
search = account.user.get_mangalist()
search = account.user.update_animelist_status(21,{"status":"on_hold","is_rewatching":False,"score":9,"num_watched_episodes":110,"priority":0,"num_times_rewatched":0,"rewatch_value":0,"tags":"","comments":"Me gusta la serie"})
search = account.user.delete_animelist_item(21)
search = account.user.get_animelist(status="watching")

```

## References

For each parameter required in any query you can review the documentation at [MAL API](https://myanimelist.net/apiconfig/references/api/v2)

This project was inspired by [Node-MyAnimeList](https://github.com/PolyMeilex/node-myanimelist) and [Python MAL API](https://github.com/darenliang/mal-api) projects. 

Thanks to them.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "mal4py",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "antoblanco <tony.white_dev@proton.me>",
    "keywords": "api,myanimelist,MAL,Anime,Manga",
    "author": "",
    "author_email": "Tony White <tony.white_dev@proton.me>",
    "download_url": "https://files.pythonhosted.org/packages/a9/3d/351c2278c78a38b26074154727bc46fb58cbfa04766ea8e9a7901a0a1cbc/mal4py-0.1.4.tar.gz",
    "platform": null,
    "description": "![Mal4py API Banner](https://image.myanimelist.net/ui/OK6W_koKDTOqqqLDbIoPAphlZzlTj5CPK0fFssPvFnc)\n![Python Lang](https://pbs.twimg.com/media/DALAHaRVoAASaTr.png)\n# MAL4Py \n\nMAL API\nAn unofficial MyAnimeList API for Python 3.\n  \nCurrently, MAL4Py is a small package for download and sync information from MyAnimeList.\n\n#### Version 0.1.4\n\n## API Documentation\n[MAL API v2 Beta Documentation](https://myanimelist.net/apiconfig/references/api/v2)\n\n## Installation and Usage\n\nTo install the library:\n\n```\n\npip install -U mal4py\n\n```\n\nTo import the library:\n\n```python\n\nfrom mal4py import *\n\n```\n\n## Example\n\nTo call the API, first you need to create an object Auth.\n\n#### Auth Login Example\n\n  \n\n```python\n\nimport  asyncio\nfrom mal4py import Auth, get_new_code_verifier, MalToken\n\n\"\"\"\n\tFor all cases you must declarate Auth object\n\"\"\"\n# ID Client MAL App Android, recomend replace for own ID Client\nauth = Auth(\"6114d00ca681b7701d1e15fe11a4987e\") \n# if your APP has a Client Secret; OMIT in all other cases (i.e. you selected \"Android\", \"iOS\", or \"Other\" as App Type)\nauth = Auth(\"my_clientID\",\"my_clientSecret\") \n\n# UNOFFICIAL WAY TO LOGIN\n\"\"\"\n\tThis way login can execute basic querys to MAL API, but only unstable_login can you edit user info.\n\"\"\"\n\n# If you use this way, must load Id Client MAL \"6114d00ca681b7701d1e15fe11a4987e\" others Id Client Don't Support way\n\n# login with user and password unstable way\naccount = asyncio.run(auth.unstable_login(\"my_user\",\"my_password\"))\n\n# Guest login without user and password unstable way\naccount = asyncio.run(auth.guest_login())\n\n\n# OFFICIAL WAY TO LOGIN (recomended)\n\"\"\" \n\tOAUTH Way generate Code\n\"\"\"\ncode_verifier = get_new_code_verifier()\nurl = auth.get_oauth_url(code_verifier)\nprint(url)\n\n# Open returned url, accept oauth and use returned code to authorize\n\nauthorization_code = input('Copy-paste the Authorization Code: ').strip()\naccount = asyncio.run(auth.authorize_with_code(authorization_code,code_verifier))\n\n\"\"\"\n\tLoad Token saved previously\n\"\"\"\n\n# Load Token from saved String\n\njsontoken = '{\"token_type\":\"Bearer\",\"expires_in\":xxx,\"access_token\":\"my_access_Token\",\"refresh_token\":\"my_refresh_token\"}'\naccount = auth.authorize_with_json_string(jsontoken)\n\n# Load Token from saved Dict\n\ntoken = {\"token_type\":\"Bearer\",\"expires_in\":xxx,\"access_token\":\"my_access_Token\",\"refresh_token\":\"my_refresh_token\"}\naccount = auth.authorize_with_json_obj(token)\n\n# Other way to Load Token load from MalToken object saved\n\nmal_token = MalToken._from_json_string(jsontoken)\n# Or\nmal_token = MalToken._from_json_obj(token)\n# Load MalToken\naccount = auth.load_token(mal_token)\n\n```\nYou can generate Token and load usign this script of [ZeroCrystal](https://gitlab.com/-/snippets/2039434)\n\n#### Search Query Example\n\n```python\n\nfrom mal import MalAccount\n\n\n# Query Anime for all login types\n# the query 'q' value must be minimum 3 characters\n\nsearch = account.anime.get_details(anime_id=44511)\nsearch = account.anime.get_list(\"chainsaw\",limit=3)\nsearch = account.anime.get_seasonal(2022,\"winter\",limit=3)\nsearch = account.anime.get_ranking(limit=3)\n\n\n# Query Anime for oAuth only or password and login user\n\nsearch = account.anime.get_suggested(limit=3)\n\n\n# Query Manga for all login types\n\nsearch = account.manga.get_details(manga_id=13)\nsearch = account.manga.get_list(\"chainsaw\",limit=3)\nsearch = account.manga.get_ranking(limit=3)\n\n\n# Query Forum for all login types\n# Actually MAL API have problems with integrity the object returned. (THIS BETA)\n\nsearch = account.forum.get_board()\nsearch = account.forum.get_topic_detail(topic_id=41)\nsearch = account.forum.get_topics(q=\"love\",subboard_id=2,board_id=0)\n\n\n# Query User for only oAuth or user and password login \n\nsearch = account.user.get_my_info()\nsearch = account.user.update_mangalist_status(13,{\"status\":\"reading\",\"is_rereading\":False,\"score\":8,\"num_volumes_read\":1,\"num_chapters_read\":2,\"priority\":1,\"num_times_reread\":0,\"reread_value\":0,\"tags\":\"Myread\",\"comments\":\"Amazing Manga\"})\nsearch = account.user.delete_mangalist_item(13)\nsearch = account.user.get_mangalist()\nsearch = account.user.update_animelist_status(21,{\"status\":\"on_hold\",\"is_rewatching\":False,\"score\":9,\"num_watched_episodes\":110,\"priority\":0,\"num_times_rewatched\":0,\"rewatch_value\":0,\"tags\":\"\",\"comments\":\"Me gusta la serie\"})\nsearch = account.user.delete_animelist_item(21)\nsearch = account.user.get_animelist(status=\"watching\")\n\n```\n\n## References\n\nFor each parameter required in any query you can review the documentation at [MAL API](https://myanimelist.net/apiconfig/references/api/v2)\n\nThis project was inspired by [Node-MyAnimeList](https://github.com/PolyMeilex/node-myanimelist) and [Python MAL API](https://github.com/darenliang/mal-api) projects. \n\nThanks to them.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2022 AntoBlanco  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "MAL API An unofficial MyAnimeList API for Python 3",
    "version": "0.1.4",
    "split_keywords": [
        "api",
        "myanimelist",
        "mal",
        "anime",
        "manga"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "ca7382190dae39253fe22eae006e3b7e",
                "sha256": "bcc228ff1938e3727010673522d55e7696d67b52ade4a607418f058b6f71490d"
            },
            "downloads": -1,
            "filename": "mal4py-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ca7382190dae39253fe22eae006e3b7e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 10198,
            "upload_time": "2022-12-12T22:59:20",
            "upload_time_iso_8601": "2022-12-12T22:59:20.486050Z",
            "url": "https://files.pythonhosted.org/packages/4b/85/7fed8dff704198a16d8d2b1aed0fb4fec40d0b9ed7ed5a084e63458f6d44/mal4py-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "a11a635dc450a81433847170c8d47b2a",
                "sha256": "a7054c66d5f93a7de53b96d0f366b2e08855bc080ce921305d4db6446b956815"
            },
            "downloads": -1,
            "filename": "mal4py-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "a11a635dc450a81433847170c8d47b2a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 11073,
            "upload_time": "2022-12-12T22:59:23",
            "upload_time_iso_8601": "2022-12-12T22:59:23.894834Z",
            "url": "https://files.pythonhosted.org/packages/a9/3d/351c2278c78a38b26074154727bc46fb58cbfa04766ea8e9a7901a0a1cbc/mal4py-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-12 22:59:23",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "mal4py"
}
        
Elapsed time: 0.40326s