mal
MALAlternativeTitles(en=None, ja=None, synonyms=None)
dataclass
¶
Bases: DataClassJsonMixin
A json-serializable class that holds alternative anime titles.
Attributes:
Name | Type | Description |
---|---|---|
en |
Optional[str]
|
The (offical) english variant of the name |
ja |
Optional[str]
|
The (offical) japanese variant of the name |
synonyms |
Optional[List[str]]
|
Other synonymous names |
MALAnime(id, title, media_type, num_episodes, alternative_titles=None, start_season=None, my_list_status=None)
dataclass
¶
Bases: DataClassJsonMixin
A json-serializable class that holds information about an anime and the user's list status if the anime is in their list.
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
Id of the anime |
title |
str
|
Title of the anime |
media_type |
MALMediaTypeEnum
|
Media type of the anime |
num_episodes |
int
|
Number of episodes the anime has, if unknown it is 0 |
alternative_titles |
Optional[MALAlternativeTitles]
|
Alternative titles for an anime |
start_season |
Optional[MALStartSeason]
|
Season/Year the anime started in |
my_list_status |
Optional[MALMyListStatus]
|
If the anime is in the user's list, this holds the information of the list status |
MALMediaTypeEnum
¶
Bases: Enum
A enum of possible media types.
Attributes:
Name | Type | Description |
---|---|---|
TV |
|
|
MOVIE |
|
|
OVA |
|
|
ONA |
|
|
SPECIAL |
|
|
TV_SPECIAL |
|
|
MUSIC |
|
|
CM |
|
|
UNKNOWN |
|
MALMyListStatus(num_episodes_watched, tags, status, score)
dataclass
¶
Bases: DataClassJsonMixin
A json-serializable class that holds a user's list status. It accompanies MALAnime.
Attributes:
Name | Type | Description |
---|---|---|
num_episodes_watched |
int
|
Watched episodes, this number may exceed
that of the |
tags |
List[str]
|
List of tags associated with the anime |
status |
MALMyListStatusEnum
|
Current status of the anime |
score |
int
|
The user's score of the anime |
MALMyListStatusEnum
¶
Bases: Enum
A enum of possible list states.
Attributes:
Name | Type | Description |
---|---|---|
WATCHING |
|
|
COMPLETED |
|
|
ON_HOLD |
|
|
DROPPED |
|
|
PLAN_TO_WATCH |
|
MALSeasonEnum
¶
Bases: Enum
A enum of possible seasons.
Attributes:
Name | Type | Description |
---|---|---|
WINTER |
|
|
SPRING |
|
|
SUMMER |
|
|
FALL |
|
MALStartSeason(season, year)
dataclass
¶
Bases: DataClassJsonMixin
A json-serializable class that holds a season/year combination indicating the time this anime was aired in.
Attributes:
Name | Type | Description |
---|---|---|
season |
MALSeasonEnum
|
Season of airing |
year |
int
|
Year of airing |
MALUser(id, name, picture=None)
dataclass
¶
Bases: DataClassJsonMixin
A json-serializable class that holds user data.
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
Users's id |
name |
str
|
Users's name |
picture |
Optional[str]
|
Users's profile picture |
MyAnimeList(client_id=None)
¶
MyAnimeList api client that implements some of the endpoints documented here.
Attributes:
Name | Type | Description |
---|---|---|
API_BASE |
The base url of the api (https://api.myanimelist.net/v2) |
|
CLIENT_ID |
The client being used to access the api |
|
RESPONSE_FIELDS |
Corresponds to fields of MALAnime object (read here for explaination) |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client_id
|
Optional[str]
|
Overrides the default client id |
None
|
Info
Please note that that currently no complex oauth autentication scheme is implemented, this client uses the client id of the official MyAnimeList android app, this gives us the ability to login via a username/password combination. If you pass your own client id you will not be able to use the from_password_grant function.
Source code in api/src/anipy_api/mal.py
from_password_grant(user, password, client_id=None)
staticmethod
¶
Authenticate via a username/password combination.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user
|
str
|
MyAnimeList username |
required |
password
|
str
|
MyAnimeList password |
required |
client_id
|
Optional[str]
|
Overrides the default client id |
None
|
Returns:
Type | Description |
---|---|
MyAnimeList
|
The MyAnimeList client object |
Source code in api/src/anipy_api/mal.py
from_rt_grant(refresh_token, client_id=None)
staticmethod
¶
Authenticate via a refresh token. The refresh token will be saved in
MyAnimeList._refresh_token
and used to periodically refresh the
access token, the refresh token may change if the current one expires.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
refresh_token
|
str
|
The refresh token |
required |
client_id
|
Optional[str]
|
Overrides the default client id |
None
|
Returns:
Type | Description |
---|---|
MyAnimeList
|
The MyAnimeList client object |
Source code in api/src/anipy_api/mal.py
get_anime(anime_id)
¶
Get a MyAnimeList anime by its id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
anime_id
|
int
|
The id of the anime |
required |
Returns:
Type | Description |
---|---|
MALAnime
|
The anime that corresponds to the id |
Source code in api/src/anipy_api/mal.py
get_anime_list(status_filter=None)
¶
Get the anime list of the currently authenticated user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
status_filter
|
Optional[MALMyListStatusEnum]
|
A filter that determines which list status is retrieved |
None
|
Returns:
Type | Description |
---|---|
List[MALAnime]
|
List of anime in the anime list |
Source code in api/src/anipy_api/mal.py
get_search(query, limit=20, pages=1)
¶
Search MyAnimeList.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str
|
Search query |
required |
limit
|
int
|
The amount of results per page |
20
|
pages
|
int
|
The amount of pages to return, note the total number of results is limit times pages |
1
|
Returns:
Type | Description |
---|---|
List[MALAnime]
|
A list of search results |
Source code in api/src/anipy_api/mal.py
get_user()
¶
Get information about the currently authenticated user.
Returns:
Type | Description |
---|---|
MALUser
|
A object with user information |
Source code in api/src/anipy_api/mal.py
remove_from_anime_list(anime_id)
¶
Remove an anime from the currently authenticated user's anime list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
anime_id
|
int
|
Id of the anime to be removed |
required |
Source code in api/src/anipy_api/mal.py
update_anime_list(anime_id, status=None, watched_episodes=None, tags=None)
¶
Update a specific anime in the currently authenticated users's anime list. Only pass the arguments you want to update.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
anime_id
|
int
|
The anime id of the anime to update |
required |
status
|
Optional[MALMyListStatusEnum]
|
Updated status of the anime |
None
|
watched_episodes
|
Optional[int]
|
Updated watched episodes |
None
|
tags
|
Optional[List[str]]
|
Updated list of tags, note that this ovewrites the already existing tags, if you want to retain the old ones you have to merge the old ones with the new ones yourself. |
None
|
Returns:
Type | Description |
---|---|
MALMyListStatus
|
Object of the updated anime |
Source code in api/src/anipy_api/mal.py
MyAnimeListAdapter(myanimelist, provider)
¶
A adapter class that can adapt MyAnimeList anime to Provider anime.
Attributes:
Name | Type | Description |
---|---|---|
mal |
MyAnimeList
|
The MyAnimeList object |
provider |
BaseProvider
|
The provider object |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
myanimelist
|
MyAnimeList
|
The MyAnimeList object to use |
required |
provider
|
BaseProvider
|
The provider object to use |
required |
Source code in api/src/anipy_api/mal.py
from_myanimelist(mal_anime, minimum_similarity_ratio=0.8, use_filters=True, use_alternative_names=True)
¶
Adapt an anime from a MALAnime to a provider Anime. This uses Levenshtein Distance to calculate the similarity of names.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mal_anime
|
MALAnime
|
The mal anime to adapt from |
required |
minimum_similarity_ratio
|
float
|
The minimum accepted similarity ratio. This should be a number from 0-1, 1 meaning the names are identical 0 meaning there are no identical charachters whatsoever. If it is not met the function will return None. |
0.8
|
use_filters
|
bool
|
Use filters for the provider to cut down on possible wrong results, do note that this will take more time. |
True
|
use_alternative_names
|
bool
|
Use alternative names for matching, this may yield a higher chance of finding a match but takes more time. |
True
|
Returns:
Type | Description |
---|---|
Optional[Anime]
|
A Anime object if adapting was successfull |
Source code in api/src/anipy_api/mal.py
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 |
|
from_provider(anime, minimum_similarity_ratio=0.8, use_alternative_names=True)
¶
Adapt an anime from provider Anime to a MALAnime. This uses Levenshtein Distance to calculate the similarity of names.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
anime
|
Anime
|
The anime to adapt from |
required |
minimum_similarity_ratio
|
float
|
The minimum accepted similarity ratio. This should be a number from 0-1, 1 meaning the names are identical 0 meaning there are no identical charachters whatsoever. If it is not met the function will return None. |
0.8
|
use_alternative_names
|
bool
|
Use alternative names for matching, this may yield a higher chance of finding a match but takes more time. |
True
|
Returns:
Type | Description |
---|---|
Optional[MALAnime]
|
A MALAnime object if adapting was successfull |