anilist
AniList(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 AniListAnime 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_implicit_grant function.
Source code in api/src/anipy_api/anilist.py
from_implicit_grant(access_token, client_id=None)
staticmethod
¶
Authenticate via Implicit Grant to retrieve access token
Returns:
Type | Description |
---|---|
AniList
|
The AniList client object |
Source code in api/src/anipy_api/anilist.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 |
---|---|
AniListAnime
|
The anime that corresponds to the id |
Source code in api/src/anipy_api/anilist.py
get_anime_list(status_filter=None)
¶
Get the anime list of the currently authenticated user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
status_filter
|
Optional[AniListMyListStatusEnum]
|
A filter that determines which list status is retrieved |
None
|
Returns:
Type | Description |
---|---|
List[AniListAnime]
|
List of anime in the anime list |
Source code in api/src/anipy_api/anilist.py
get_search(search, limit=20, pages=1)
¶
Search AniList.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
search
|
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[AniListAnime]
|
A list of search results |
Source code in api/src/anipy_api/anilist.py
get_user()
¶
Get information about the currently authenticated user.
Returns:
Type | Description |
---|---|
AniListUser
|
A object with user information |
Source code in api/src/anipy_api/anilist.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/anilist.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[AniListMyListStatusEnum]
|
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 |
---|---|
AniListMyListStatus
|
Object of the updated anime |
Source code in api/src/anipy_api/anilist.py
AniListAdapter(myanimelist, provider)
¶
A adapter class that can adapt MyAnimeList anime to Provider anime.
Attributes:
Name | Type | Description |
---|---|---|
anilist |
AniList
|
The AniList object |
provider |
BaseProvider
|
The provider object |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
anilist
|
The AniList object to use |
required | |
provider
|
BaseProvider
|
The provider object to use |
required |
Source code in api/src/anipy_api/anilist.py
from_anilist(anilist_anime, minimum_similarity_ratio=0.8, use_filters=True, use_alternative_names=True)
¶
Adapt an anime from a AniListAnime to a provider Anime. This uses Levenshtein Distance to calculate the similarity of names.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
anilist_anime
|
AniListAnime
|
The anilist 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/anilist.py
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 |
|
from_provider(anime, minimum_similarity_ratio=0.8, use_alternative_names=True)
¶
Adapt an anime from provider Anime to a AniListAnime. 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[AniListAnime]
|
A AniListAnime object if adapting was successfull |
Source code in api/src/anipy_api/anilist.py
AniListAlternativeTitles(english=None, native=None, romaji=None)
dataclass
¶
Bases: DataClassJsonMixin
A json-serializable class that holds alternative anime titles.
Attributes:
Name | Type | Description |
---|---|---|
en |
The (offical) english variant of the name |
|
ja |
The (offical) japanese variant of the name |
|
synonyms |
Other synonymous names |
AniListAnime(id, title, media_type, num_episodes=None, alternative_titles=None, year=None, 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 |
Title
|
Title of the anime |
media_type |
AniListMediaTypeEnum
|
Media type of the anime |
num_episodes |
Optional[int]
|
Number of episodes the anime has, if unknown it is 0 |
alternative_titles |
Optional[AniListAlternativeTitles]
|
Alternative titles for an anime |
start_season |
Optional[AniListAlternativeTitles]
|
Season/Year the anime started in |
my_list_status |
Optional[AniListMyListStatus]
|
If the anime is in the user's list, this holds the information of the list status |
AniListMediaTypeEnum
¶
Bases: Enum
A enum of possible media types.
Attributes:
Name | Type | Description |
---|---|---|
TV |
|
|
TV_SHORT |
|
|
MOVIE |
|
|
SPECIAL |
|
|
OVA |
|
|
ONA |
|
|
MUSIC |
|
AniListMyListStatus(entry_id, notes, num_episodes_watched, status, score, tags=list())
dataclass
¶
Bases: DataClassJsonMixin
A json-serializable class that holds a user's list status. It accompanies [AniListAnime][anipy_api.mal.AniListAnime].
Attributes:
Name | Type | Description |
---|---|---|
entry_id |
int
|
The unique ID of the user's list entry. Used to identify this anime entry in the user's AniList media list. |
num_episodes_watched |
int
|
Watched episodes, this number may exceed
that of the |
tags |
List[str]
|
List of tags associated with the anime |
status |
AniListMyListStatusEnum
|
Current status of the anime |
score |
int
|
The user's score of the anime |
AniListMyListStatusEnum
¶
Bases: Enum
A enum of possible list states.
Attributes:
Name | Type | Description |
---|---|---|
WATCHING |
|
|
COMPLETED |
|
|
ON_HOLD |
|
|
DROPPED |
|
|
PLAN_TO_WATCH |
|
|
REPEATING |
|
AniListSeasonEnum
¶
Bases: Enum
A enum of possible seasons.
Attributes:
Name | Type | Description |
---|---|---|
WINTER |
|
|
SPRING |
|
|
SUMMER |
|
|
FALL |
|
AniListStartSeason(year, season)
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 |
AniListSeasonEnum
|
Season of airing |
year |
int
|
Year of airing |
AniListUser(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[Picture]
|
Users's profile picture |