[docs]@dataclassclassAnime(JikanResource):""" Get or search for anime. ------------ â Example: ------------ Here's an example of how to get an anime by ID and display it's cover art:: from anmoku import Anime, Anmoku client = Anmoku() anime = client.get(Anime, id = 13759) print( f"Got the anime '{anime.name}', it's english name is '{anime.name.english}' and it was aired in {anime.aired.from_.year}." ) # Display it's image. anime.image.get_image().show() """_get_endpoint="/anime/{id}"_search_endpoint="/anime"data:JikanResponseData[AnimeData]=field(repr=False)id:int=field(init=False)"""The MyAnimeList ID of the anime."""url:str=field(init=False)"""The MyAnimeList URL to this anime."""image:Image=field(init=False)"""The banner image of the anime."""trailer:Trailer=field(init=False)"""The trailer of the anime."""approved:bool=field(init=False)"""Whether the entry is pending approval on MAL or not."""title:Title=field(init=False)"""The anime's title."""name:Title=field(init=False)"""Alias to ``Anime.title``."""type:AnimeTypesData=field(init=False)"""The type of anime."""source:Optional[str]=field(init=False,default=None)"""The original material / source the anime was adapted from."""episodes:int=field(init=False,default=0)"""Episode count of the anime."""status:AiringStatus=field(init=False,default=AiringStatus.NOT_YET_AIRED)"""The airing status of the anime."""aired:DateRange=field(init=False)"""To when and from this anime was aired."""duration:Optional[str]=field(init=False,default=None)"""Duration of each episode of an anime or complete duration of an anime film."""audience_rating:Optional[MALRatings]=field(init=False,default=None)"""Audience rating of this anime."""score:float=field(init=False,default=0.0)"""The anime's score rating."""scored_by:int=field(init=False,default=0)"""Number of users that scored the anime."""rank:int=field(init=False,default=0)popularity:int=field(init=False,default=0)members:int=field(init=False,default=0)favourites:int=field(init=False,default=0)synopsis:Optional[str]=field(init=False,default=None)background:Optional[str]=field(init=False,default=None)description:Optional[str]=field(init=False,default=None)season:Optional[AnimeSeason]=field(init=False,default=None)year:int=field(init=False,default=0)def__post_init__(self):anime=self.data["data"]self.id=anime["mal_id"]self.url=anime["url"]self.image=Image(anime["images"])self.trailer=Trailer(anime["trailer"])self.approved=anime["approved"]self.title=Title(anime["titles"])self.name=self.titleself.type=anime["type"]self.rank=anime["rank"]self.popularity=anime["popularity"]self.members=anime["members"]self.favourites=anime["favorites"]self.synopsis=anime["synopsis"]self.background=anime["background"]self.description=self.synopsisorself.backgroundself.source=anime["source"]self.duration=anime["duration"]self.audience_rating=anime["rating"]# "is not None" is used on the keys below to make sure# they are undefined so the dataclass fields fall back to their# respective default values.season=anime["season"]ifseasonisnotNone:self.season=AnimeSeason(season)episodes=anime["episodes"]ifepisodesisnotNone:self.episodes=episodesstatus=anime["status"]ifstatusisnotNone:self.status=AiringStatus(status)self.aired=DateRange(anime["aired"])score=anime["score"]ifscoreisnotNone:self.score=scorescored_by=anime["scored_by"]ifscored_byisnotNone:self.scored_by=scored_by
[docs]@dataclassclassFullAnime(Anime):# TODO: Finish this. You can use the FullAnimeData type dict to help._get_endpoint="/anime/{id}/full"data:JikanResponseData[FullAnimeData]=field(repr=False)
@dataclassclassTrailer():"""Helper for the anime's trailer."""data:TrailerData=field(repr=False)id:str=field(init=False)url:str=field(init=False)embed_url:str=field(init=False)image:Image=field(init=False)def__post_init__(self):self.id=self.data["youtube_id"]"""Video ID of the trailer."""self.url=self.data["url"]"""Url to trailer."""self.embed_url=self.data["embed_url"]"""Url to the trailer's embed."""self.image=Image(self.data["images"])"""Image of the trailer."""