From 2c4ecb66aa4287cdfccd6fe4b779c2c9bacd47cd Mon Sep 17 00:00:00 2001 From: RLAlpha49 <75044176+RLAlpha49@users.noreply.github.com> Date: Mon, 13 May 2024 19:56:58 -0500 Subject: [PATCH] Add all query and mutation schemas --- AniLinkPy/apis/anilist/query/media.py | 82 +++ AniLinkPy/apis/anilist/query/query.py | 14 + AniLinkPy/apis/anilist/query/user.py | 4 +- .../apis/anilist/schemas/activity_schema.py | 573 ++++++++++++++++++ .../apis/anilist/schemas/basic_schema.py | 51 ++ .../anilist/schemas/cover_image_schema.py | 16 +- .../anilist/schemas/distribution_schema.py | 31 + .../anilist/schemas/external_link_schema.py | 17 + .../apis/anilist/schemas/fuzzy_date_schema.py | 15 + .../apis/anilist/schemas/image_schema.py | 14 +- .../schemas/media_list_entry_schema.py | 15 + .../apis/anilist/schemas/mutation/__init__.py | 0 .../schemas/mutation/favorites_schema.py | 89 +++ AniLinkPy/apis/anilist/schemas/name_schema.py | 18 +- .../schemas/next_airing_episode_schema.py | 17 + .../anilist/schemas/notification_schema.py | 39 ++ .../schemas/query/airing_schedule_schema.py | 25 + .../anilist/schemas/query/character_schema.py | 50 ++ .../query/media_list_collection_schema.py | 24 + .../schemas/query/media_list_schema.py | 58 ++ .../anilist/schemas/query/media_schema.py | 126 ++++ .../schemas/query/media_trend_schema.py | 32 + .../query/media_with_relations_schema.py | 209 +++++++ .../schemas/query/notification_schema.py | 193 ++++++ .../schemas/query/recommendation_schema.py | 30 + .../anilist/schemas/query/review_schema.py | 46 ++ .../schemas/query/site_statistics_schema.py | 39 ++ .../anilist/schemas/query/staff_schema.py | 71 +++ .../anilist/schemas/query/studio_schema.py | 68 +++ .../schemas/query/thread_comment_schema.py | 47 ++ .../anilist/schemas/query/thread_schema.py | 69 +++ .../apis/anilist/schemas/query/user_schema.py | 60 +- .../apis/anilist/schemas/ranking_schema.py | 27 + .../apis/anilist/schemas/site_trend_schema.py | 43 ++ .../schemas/streaming_episode_schema.py | 19 + AniLinkPy/apis/anilist/schemas/tag_schema.py | 24 +- .../apis/anilist/schemas/title_schema.py | 18 +- .../apis/anilist/schemas/trailer_schema.py | 16 + .../apis/anilist/schemas/user_stats_schema.py | 17 +- docs/AniLink/AniList/Mutations/schemas.md | 7 + docs/AniLink/AniList/Queries/schemas.md | 62 +- docs/AniLink/AniList/schemas.md | 50 +- docs/index.md | 6 +- mkdocs.yml | 1 + poetry.lock | 14 +- pyproject.toml | 4 +- setup.cfg | 2 +- tests/test.py | 6 + 48 files changed, 2358 insertions(+), 100 deletions(-) create mode 100644 AniLinkPy/apis/anilist/query/media.py create mode 100644 AniLinkPy/apis/anilist/schemas/activity_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/basic_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/distribution_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/external_link_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/fuzzy_date_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/media_list_entry_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/mutation/__init__.py create mode 100644 AniLinkPy/apis/anilist/schemas/mutation/favorites_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/next_airing_episode_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/notification_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/query/airing_schedule_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/query/character_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/query/media_list_collection_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/query/media_list_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/query/media_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/query/media_trend_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/query/media_with_relations_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/query/notification_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/query/recommendation_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/query/review_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/query/site_statistics_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/query/staff_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/query/studio_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/query/thread_comment_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/query/thread_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/ranking_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/site_trend_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/streaming_episode_schema.py create mode 100644 AniLinkPy/apis/anilist/schemas/trailer_schema.py create mode 100644 docs/AniLink/AniList/Mutations/schemas.md diff --git a/AniLinkPy/apis/anilist/query/media.py b/AniLinkPy/apis/anilist/query/media.py new file mode 100644 index 0000000..fa8ec3d --- /dev/null +++ b/AniLinkPy/apis/anilist/query/media.py @@ -0,0 +1,82 @@ +from typing import Union + +from AniLinkPy.apis.anilist.schemas.query.media_with_relations_schema import ( + MEDIAWITHRELATIONSSCHEMA, +) +from AniLinkPy.base.RequestHandler import send_request + + +class MediaQuery: + """ + This class represents a Media_schema Query in the AniLink API. + + Attributes: + base_url (str): The base URL for the AniLink API. + auth_token (str): The authentication token. + """ + + def __init__(self, auth_token: Union[str, None]) -> None: + """ + The constructor for the MediaQuery class. + + Args: + auth_token (str): The authentication token. + """ + self.base_url = "https://graphql.anilist.co" + self.auth_token = auth_token + + def media(self, variables: dict) -> dict: + """ + This method is used to send a media Query. + + Args: + variables (dict): The variables for the Query. + + Raises: + ValueError: If no variables are provided. + + Returns: + dict: The response from the media Query. + """ + if not variables: + raise ValueError("At least one variable must be provided") + + query = f""" + query ($id: Int, $idMal: Int, $startDate: FuzzyDateInt, $endDate: FuzzyDateInt, $season: + MediaSeason, $seasonYear: Int, $type: MediaType, $format: MediaFormat, $status: MediaStatus, $episodes: Int, + $duration: Int, $chapters: Int, $volumes: Int, $isAdult: Boolean, $genre: String, $tag: String, + $minimumTagRank: Int, $tagCategory: String, $onList: Boolean, $licensedBy: String, $licensedById: Int, + $averageScore: Int, $popularity: Int, $source: MediaSource, $countryOfOrigin: CountryCode, $isLicensed: + Boolean, $search: String, $id_not: Int, $id_in: [Int], $id_not_in: [Int], $idMal_not: Int, $idMal_in: [Int], + $idMal_not_in: [Int], $startDate_greater: FuzzyDateInt, $startDate_lesser: FuzzyDateInt, $startDate_like: + String, $endDate_greater: FuzzyDateInt, $endDate_lesser: FuzzyDateInt, $endDate_like: String, $format_in: [ + MediaFormat], $format_not: MediaFormat, $format_not_in: [MediaFormat], $status_in: [MediaStatus], + $status_not: MediaStatus, $status_not_in: [MediaStatus], $episodes_greater: Int, $episodes_lesser: Int, + $duration_greater: Int, $duration_lesser: Int, $chapters_greater: Int, $chapters_lesser: Int, + $volumes_greater: Int, $volumes_lesser: Int, $genre_in: [String], $genre_not_in: [String], $tag_in: [String], + $tag_not_in: [String], $tagCategory_in: [String], $tagCategory_not_in: [String], $licensedBy_in: [String], + $licensedById_in: [Int], $averageScore_not: Int, $averageScore_greater: Int, $averageScore_lesser: Int, + $popularity_not: Int, $popularity_greater: Int, $popularity_lesser: Int, $source_in: [MediaSource], + $sort: [MediaSort], $asHtml: Boolean) {{ Media (id: $id, idMal: $idMal, startDate: $startDate, + endDate: $endDate, season: $season, seasonYear: $seasonYear, type: $type, format: $format, status: $status, + episodes: $episodes, duration: $duration, chapters: $chapters, volumes: $volumes, isAdult: $isAdult, + genre: $genre, tag: $tag, minimumTagRank: $minimumTagRank, tagCategory: $tagCategory, onList: $onList, + licensedBy: $licensedBy, licensedById: $licensedById, averageScore: $averageScore, popularity: $popularity, + source: $source, countryOfOrigin: $countryOfOrigin, isLicensed: $isLicensed, search: $search, + id_not: $id_not, id_in: $id_in, id_not_in: $id_not_in, idMal_not: $idMal_not, idMal_in: $idMal_in, + idMal_not_in: $idMal_not_in, startDate_greater: $startDate_greater, startDate_lesser: $startDate_lesser, + startDate_like: $startDate_like, endDate_greater: $endDate_greater, endDate_lesser: $endDate_lesser, + endDate_like: $endDate_like, format_in: $format_in, format_not: $format_not, format_not_in: $format_not_in, + status_in: $status_in, status_not: $status_not, status_not_in: $status_not_in, episodes_greater: + $episodes_greater, episodes_lesser: $episodes_lesser, duration_greater: $duration_greater, duration_lesser: + $duration_lesser, chapters_greater: $chapters_greater, chapters_lesser: $chapters_lesser, volumes_greater: + $volumes_greater, volumes_lesser: $volumes_lesser, genre_in: $genre_in, genre_not_in: $genre_not_in, + tag_in: $tag_in, tag_not_in: $tag_not_in, tagCategory_in: $tagCategory_in, tagCategory_not_in: + $tagCategory_not_in, licensedBy_in: $licensedBy_in, licensedById_in: $licensedById_in, averageScore_not: + $averageScore_not, averageScore_greater: $averageScore_greater, averageScore_lesser: $averageScore_lesser, + popularity_not: $popularity_not, popularity_greater: $popularity_greater, popularity_lesser: + $popularity_lesser, source_in: $source_in, sort: $sort) {{ {MEDIAWITHRELATIONSSCHEMA}}}}} + """ + + data = {"query": query, "variables": variables} + return send_request(self.base_url, "POST", data, self.auth_token) diff --git a/AniLinkPy/apis/anilist/query/query.py b/AniLinkPy/apis/anilist/query/query.py index 7975d89..a705439 100644 --- a/AniLinkPy/apis/anilist/query/query.py +++ b/AniLinkPy/apis/anilist/query/query.py @@ -1,5 +1,6 @@ from typing import Union +from AniLinkPy.apis.anilist.query.media import MediaQuery from AniLinkPy.apis.anilist.query.page.page import Page from AniLinkPy.apis.anilist.query.user import UserQuery @@ -22,6 +23,7 @@ def __init__(self, auth_token: Union[str, None]) -> None: """ self.page = Page() self.user_query = UserQuery(auth_token) + self.media_query = MediaQuery(auth_token) def user(self, variables: dict) -> dict: """ @@ -34,3 +36,15 @@ def user(self, variables: dict) -> dict: dict: The response from the user Query. """ return self.user_query.user(variables) + + def media(self, variables: dict) -> dict: + """ + This method is used to get a media. + + Args: + variables (dict): The variables for the Query. + + Returns: + dict: The response from the media Query. + """ + return self.media_query.media(variables) diff --git a/AniLinkPy/apis/anilist/query/user.py b/AniLinkPy/apis/anilist/query/user.py index 4df12fb..7f8db39 100644 --- a/AniLinkPy/apis/anilist/query/user.py +++ b/AniLinkPy/apis/anilist/query/user.py @@ -1,6 +1,6 @@ from typing import Union -from AniLinkPy.apis.anilist.schemas.query.user_schema import UserSchema +from AniLinkPy.apis.anilist.schemas.query.user_schema import USERSCHEMA from AniLinkPy.base.RequestHandler import send_request @@ -43,7 +43,7 @@ def user(self, variables: dict) -> dict: query ($id: Int, $name: String, $isModerator: Boolean, $search: String, $sort: [UserSort], $asHtml: Boolean, $animeStatLimit: Int, $mangaStatLimit: Int, $animeStatSort: [UserStatisticsSort], $mangaStatSort: [UserStatisticsSort]) {{ User (id: $id, name: $name, isModerator: $isModerator, - search: $search, sort: $sort) {{ {UserSchema} + search: $search, sort: $sort) {{ {USERSCHEMA} }} }} """ diff --git a/AniLinkPy/apis/anilist/schemas/activity_schema.py b/AniLinkPy/apis/anilist/schemas/activity_schema.py new file mode 100644 index 0000000..981d19f --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/activity_schema.py @@ -0,0 +1,573 @@ +from AniLinkPy.apis.anilist.schemas.basic_schema import BASICUSERSCHEMA +from AniLinkPy.apis.anilist.schemas.title_schema import TITLESCHEMA + +ACTIVITYREPLYSCHEMA = f""" + id + userId + activityId + text (asHtml: $asHtml) + likeCount + isLiked + createdAt + user {{ + {BASICUSERSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} +""" + +""" +This is the ActivityReplySchema for the Anilist API. It defines the structure of the activity reply data. + +Attributes: + id (int): The id of the activity. + userId (int): The id of the user who created the activity. + activityId (int): The id of the activity. + text (str): The text of the activity. + likeCount (int): The count of likes on the activity. + isLiked (bool): Whether the activity is liked by the user. + createdAt (int): The timestamp when the activity was created. + user (BasicUser): The user who created the activity. + likes (list): The list of users who liked the activity. +""" + +ACTIVITYSCHEMA = """ + activity { + ... on TextActivity { + id + userId + type + replyCount + text (asHtml: $asHtml) + siteUrl + isLocked + isSubscribed + likeCount + isLiked + isPinned + createdAt + } + ... on ListActivity { + id + userId + type + replyCount + status + progress + isLocked + isSubscribed + likeCount + isLiked + isPinned + siteUrl + createdAt + media { + id + title { + romaji + english + } + } + } + ... on MessageActivity { + id + recipientId + messengerId + type + replyCount + message (asHtml: $asHtml) + isLocked + isSubscribed + likeCount + isLiked + isPrivate + siteUrl + createdAt + } + } +""" + +""" +This is the ActivitySchema for the Anilist API. It defines the structure of the activity data + +Attributes: + id (int): The id of the activity. + userId (int): The id of the user who created the activity. + type (str): The type of the activity. + replyCount (int): The count of replies on the activity. + text (str): The text of the activity. + siteUrl (str): The site URL of the activity. + isLocked (bool): Whether the activity is locked. + isSubscribed (bool): Whether the user is subscribed to the activity. + likeCount (int): The count of likes on the activity. + isLiked (bool): Whether the activity is liked by the user. + isPinned (bool): Whether the activity is pinned. + createdAt (int): The timestamp when the activity was created. +""" + +ACTIVITYSCHEMAV2 = f""" + activity {{ + ... on TextActivity {{ + id + userId + type + replyCount + text (asHtml: $asHtml) + siteUrl + isLocked + isSubscribed + likeCount + isLiked + isPinned + createdAt + user {{ + {BASICUSERSCHEMA} + }} + replies {{ + {ACTIVITYREPLYSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} + }} + ... on ListActivity {{ + id + userId + type + replyCount + status + progress + isLocked + isSubscribed + likeCount + isLiked + isPinned + siteUrl + createdAt + media {{ + id + title {{ + romaji + english + }} + }} + user {{ + {BASICUSERSCHEMA} + }} + replies {{ + {ACTIVITYREPLYSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} + }} + ... on MessageActivity {{ + id + recipientId + messengerId + type + replyCount + message (asHtml: $asHtml) + isLocked + isSubscribed + likeCount + isLiked + isPrivate + siteUrl + createdAt + recipient {{ + {BASICUSERSCHEMA} + }} + messenger {{ + {BASICUSERSCHEMA} + }} + replies {{ + {ACTIVITYREPLYSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} + }} + ... on ActivityReply {{ + id + userId + activityId + text (asHtml: $asHtml) + likeCount + isLiked + createdAt + user {{ + {BASICUSERSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} + }} + ... on Thread {{ + id + title + body (asHtml: $asHtml) + ThreadUserId: userId + replyUserId + replyCommentId + ThreadReplyCount: replyCount + viewCount + isLocked + isSticky + isSubscribed + likeCount + isLiked + repliedAt + createdAt + updatedAt + user {{ + {BASICUSERSCHEMA} + }} + replyUser {{ + {BASICUSERSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} + siteUrl + categories {{ + id + name + }} + mediaCategories {{ + id + {TITLESCHEMA} + }} + }} + ... on ThreadComment {{ + id + userId + threadId + comment (asHtml: $asHtml) + likeCount + isLiked + siteUrl + createdAt + updatedAt + thread {{ + id + title + }} + user {{ + {BASICUSERSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} + childComments + isLocked + }} + }} +""" + +""" +This is the ActivitySchemaV2 for the Anilist API. It defines the structure of the activity data + +Attributes: + id (int): The id of the activity. + userId (int): The id of the user who created the activity. + type (str): The type of the activity. + replyCount (int): The count of replies on the activity. + text (str): The text of the activity. + siteUrl (str): The site URL of the activity. + isLocked (bool): Whether the activity is locked. + isSubscribed (bool): Whether the user is subscribed to the activity. + likeCount (int): The count of likes on the activity. + isLiked (bool): Whether the activity is liked by the user. + isPinned (bool): Whether the activity is pinned. + createdAt (int): The timestamp when the activity was created. + user (BasicUser): The user who created the activity. + replies (list): The list of replies to the activity. + likes (list): The list of users who liked the activity. +""" + +ACTIVITYWITHREPLIESSCHEMA = f""" + activity {{ + ... on TextActivity {{ + id + userId + type + replyCount + text (asHtml: $asHtml) + siteUrl + isLocked + isSubscribed + likeCount + isLiked + isPinned + createdAt + user {{ + {BASICUSERSCHEMA} + }} + replies {{ + {ACTIVITYREPLYSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} + }} + ... on ListActivity {{ + id + userId + type + replyCount + status + progress + isLocked + isSubscribed + likeCount + isLiked + isPinned + siteUrl + createdAt + media {{ + id + title {{ + romaji + english + }} + }} + user {{ + {BASICUSERSCHEMA} + }} + replies {{ + {ACTIVITYREPLYSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} + }} + ... on MessageActivity {{ + id + recipientId + messengerId + type + replyCount + message (asHtml: $asHtml) + isLocked + isSubscribed + likeCount + isLiked + isPrivate + siteUrl + createdAt + recipient {{ + BASICUSERSCHEMA + }} + messenger {{ + {BASICUSERSCHEMA} + }} + replies {{ + {ACTIVITYREPLYSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} + }} + }} +""" + +""" +This is the ActivityWithRepliesSchema for the Anilist API. It defines the structure of the activity data + +Attributes: + id (int): The id of the activity. + userId (int): The id of the user who created the activity. + type (str): The type of the activity. + replyCount (int): The count of replies on the activity. + text (str): The text of the activity. + siteUrl (str): The site URL of the activity. + isLocked (bool): Whether the activity is locked. + isSubscribed (bool): Whether the user is subscribed to the activity. + likeCount (int): The count of likes on the activity. + isLiked (bool): Whether the activity is liked by the user. + isPinned (bool): Whether the activity is pinned. + createdAt (int): The timestamp when the activity was created. + user (BasicUser): The user who created the activity. + replies (list): The list of replies to the activity. + likes (list): The list of users who liked the activity. +""" + +TEXTACTIVITYSCHEMA = f""" + id + userId + type + replyCount + text (asHtml: $asHtml) + siteUrl + isLocked + isSubscribed + likeCount + isLiked + isPinned + createdAt + user {{ + {BASICUSERSCHEMA} + }} + replies {{ + {ACTIVITYREPLYSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} +""" + +""" +This is the TextActivitySchema for the Anilist API. It defines the structure of the text activity data. + +Attributes: + id (int): The id of the text activity. + userId (int): The id of the user who created the text activity. + type (str): The type of the text activity. + replyCount (int): The count of replies on the text activity. + text (str): The text of the text activity. + siteUrl (str): The site URL of the text activity. + isLocked (bool): Whether the text activity is locked. + isSubscribed (bool): Whether the user is subscribed to the text activity. + likeCount (int): The count of likes on the text activity. + isLiked (bool): Whether the text activity is liked by the user. + isPinned (bool): Whether the text activity is pinned. + createdAt (int): The timestamp when the text activity was created. + user (BasicUser): The user who created the text activity. + replies (list): The list of replies to the text activity. + likes (list): The list of users who liked the text activity. +""" + +LISTACTIVITYSCHEMA = f""" + id + userId + type + replyCount + status + progress + isLocked + isSubscribed + likeCount + isLiked + isPinned + siteUrl + createdAt + media {{ + id + title {{ + romaji + english + }} + }} + user {{ + {BASICUSERSCHEMA} + }} + replies {{ + {ACTIVITYREPLYSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} +""" + +""" +This is the ListActivitySchema for the Anilist API. It defines the structure of the list activity data. + +Attributes: + id (int): The id of the list activity. + userId (int): The id of the user who created the list activity. + type (str): The type of the list activity. + replyCount (int): The count of replies on the list activity. + status (str): The status of the list activity. + progress (int): The progress of the list activity. + isLocked (bool): Whether the list activity is locked. + isSubscribed (bool): Whether the user is subscribed to the list activity. + likeCount (int): The count of likes on the list activity. + isLiked (bool): Whether the list activity is liked by the user. + isPinned (bool): Whether the list activity is pinned. + siteUrl (str): The site URL of the list activity. + createdAt (int): The timestamp when the list activity was created. + media (dict): The media details of the list activity. + user (BasicUser): The user who created the list activity. + replies (list): The list of replies to the list activity. + likes (list): The list of users who liked the list activity. +""" + +MESSAGEACTIVITYSCHEMA = f""" + id + recipientId + messengerId + type + replyCount + message (asHtml: $asHtml) + isLocked + isSubscribed + likeCount + isLiked + isPrivate + siteUrl + createdAt + recipient {{ + {BASICUSERSCHEMA} + }} + messenger {{ + {BASICUSERSCHEMA} + }} + replies {{ + {ACTIVITYREPLYSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} +""" + +""" +This is the MessageActivitySchema for the Anilist API. It defines the structure of the message activity data. + +Attributes: + id (int): The id of the message activity. + recipientId (int): The id of the recipient of the message activity. + messengerId (int): The id of the messenger of the message activity. + type (str): The type of the message activity. + replyCount (int): The count of replies on the message activity. + message (str): The message of the message activity. + isLocked (bool): Whether the message activity is locked. + isSubscribed (bool): Whether the user is subscribed to the message activity. + likeCount (int): The count of likes on the message activity. + isLiked (bool): Whether the message activity is liked by the user. + isPrivate (bool): Whether the message activity is private. + siteUrl (str): The site URL of the message activity. + createdAt (int): The timestamp when the message activity was created. + recipient (BasicUser): The recipient of the message activity. + messenger (BasicUser): The messenger of the message activity. + replies (list): The list of replies to the message activity. + likes (list): The list of users who liked the message activity. +""" + +ACTIVITYNOTIFICATIONSCHEMA = f""" + id + userId + type + activityId + context + createdAt + {ACTIVITYSCHEMA} + user {{ + {BASICUSERSCHEMA} + }} +""" + +""" +This is the ActivityNotificationSchema for the Anilist API. It defines the structure of the activity notification data. + +Attributes: + id (int): The id of the notification. + userId (int): The id of the user who created the notification. + type (str): The type of the notification. + activityId (int): The id of the activity related to the notification. + context (str): The context of the notification. + createdAt (int): The timestamp when the notification was created. + ActivitySchema (str): The details of the activity related to the notification. + BASICUSERSCHEMA (str): The details of the user who created the notification. +""" diff --git a/AniLinkPy/apis/anilist/schemas/basic_schema.py b/AniLinkPy/apis/anilist/schemas/basic_schema.py new file mode 100644 index 0000000..6d8ab52 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/basic_schema.py @@ -0,0 +1,51 @@ +BASICUSERSCHEMA = """ + id + name + avatar { + large + } +""" + +""" +This is the BasicUserSchema for the AniList API. It defines the structure of the image data that is expected to be +returned from the API. + +Attributes: + id (int): The id of the user. + name (str): The name of the user. + avatar (dict): The avatar of the user with a large size. +""" + +BASICTHREADSCHEMA = """ + id + title + body (asHtml: $asHtml) + siteUrl +""" + +""" +This is the BasicThreadSchema for the AniList API. It defines the structure of the image data that is expected to be +returned from the API. + +Attributes: + id (int): The id of the thread. + title (str): The title of the thread. + body (str): The body of the thread. + siteUrl (str): The site URL of the thread. +""" + +BASICCOMMENTSCHEMA = """ + id + userId + threadId +""" + +""" +This is the BasicCommentSchema for the AniList API. It defines the structure of the image data that is expected to be +returned from the API. + +Attributes: + id (int): The id of the comment. + userId (int): The id of the user who made the comment. + threadId (int): The id of the thread where the comment is. +""" diff --git a/AniLinkPy/apis/anilist/schemas/cover_image_schema.py b/AniLinkPy/apis/anilist/schemas/cover_image_schema.py index 2aa5e4f..ece930b 100644 --- a/AniLinkPy/apis/anilist/schemas/cover_image_schema.py +++ b/AniLinkPy/apis/anilist/schemas/cover_image_schema.py @@ -1,3 +1,11 @@ +COVERIMAGESCHEMA = """ +coverImage { + extraLarge + large + medium +} +""" + """ This is the CoverImageSchema for the Anilist API. It defines the structure of the cover image data that is expected to be returned from the API. @@ -7,11 +15,3 @@ large (str): The URL of the large cover image. medium (str): The URL of the medium cover image. """ - -COVERIMAGESCHEMA = """ -coverImage { - extraLarge - large - medium -} -""" diff --git a/AniLinkPy/apis/anilist/schemas/distribution_schema.py b/AniLinkPy/apis/anilist/schemas/distribution_schema.py new file mode 100644 index 0000000..cee5daa --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/distribution_schema.py @@ -0,0 +1,31 @@ +SCOREDISTRIBUTIONSCHEMA = """ + scoreDistribution { + score + amount + } +""" + +""" +This is the DistributionSchema for the AniList API. It defines the structure of the distribution data that is +expected to be + +Attributes: + score (int): The score of the distribution. + amount (int): The amount of the distribution. +""" + +STATUSDISTRIBUTIONSCHEMA = """ + statusDistribution { + status + amount + } +""" + +""" +This is the DistributionSchema for the AniList API. It defines the structure of the distribution data that is +expected to be + +Attributes: + status (str): The status of the distribution. + amount (int): The amount of the distribution. +""" diff --git a/AniLinkPy/apis/anilist/schemas/external_link_schema.py b/AniLinkPy/apis/anilist/schemas/external_link_schema.py new file mode 100644 index 0000000..99dceb2 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/external_link_schema.py @@ -0,0 +1,17 @@ +EXTERNALLINKSCHEMA = """ + externalLinks { + id + url + site + } +""" + +""" +This is the ExternalLinkSchema for the AniList API. It defines the structure of the external link data that is +expected to be + +Attributes: + id (int): The id of the external link. + url (str): The url of the external link. + site (str): The site of the external link. +""" diff --git a/AniLinkPy/apis/anilist/schemas/fuzzy_date_schema.py b/AniLinkPy/apis/anilist/schemas/fuzzy_date_schema.py new file mode 100644 index 0000000..0c2cc31 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/fuzzy_date_schema.py @@ -0,0 +1,15 @@ +FUZZYDATESCHEMA = """ + year + month + day +""" + +""" +This is the FuzzyDateSchema for the AniList API. It defines the structure of the image data that is expected to be +returned from the API. + +Attributes: + year (int): The year of the date. + month (int): The month of the date. + day (int): The day of the date. +""" diff --git a/AniLinkPy/apis/anilist/schemas/image_schema.py b/AniLinkPy/apis/anilist/schemas/image_schema.py index 5a5dbab..09ddb45 100644 --- a/AniLinkPy/apis/anilist/schemas/image_schema.py +++ b/AniLinkPy/apis/anilist/schemas/image_schema.py @@ -1,3 +1,10 @@ +IMAGESCHEMA = """ +image { + large + medium +} +""" + """ This is the ImageSchema for the Anilist API. It defines the structure of the image data that is expected to be returned from the API. @@ -6,10 +13,3 @@ large (str): The URL of the large image. medium (str): The URL of the medium image. """ - -IMAGESCHEMA = """ -image { - large - medium -} -""" diff --git a/AniLinkPy/apis/anilist/schemas/media_list_entry_schema.py b/AniLinkPy/apis/anilist/schemas/media_list_entry_schema.py new file mode 100644 index 0000000..b8007d5 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/media_list_entry_schema.py @@ -0,0 +1,15 @@ +MEDIALISTENTRYSCHEMA = """ + mediaListEntry { + id + status + } +""" + +""" +This is the MediaListEntrySchema for the AniList API. It defines the structure of the media list entry data that +is expected to be returned from the API. + +Attributes: + id (int): The id of the media list entry. + status (str): The status of the media list entry. +""" diff --git a/AniLinkPy/apis/anilist/schemas/mutation/__init__.py b/AniLinkPy/apis/anilist/schemas/mutation/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/AniLinkPy/apis/anilist/schemas/mutation/favorites_schema.py b/AniLinkPy/apis/anilist/schemas/mutation/favorites_schema.py new file mode 100644 index 0000000..49a1729 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/mutation/favorites_schema.py @@ -0,0 +1,89 @@ +from AniLinkPy.apis.anilist.schemas.title_schema import TITLESCHEMA + +FAVORITESSCHEMA = f""" + anime {{ + edges {{ + id + node {{ + id + {TITLESCHEMA} + }} + }} + nodes {{ + id + {TITLESCHEMA} + }} + }} + manga {{ + edges {{ + id + node {{ + id + {TITLESCHEMA} + }} + }} + nodes {{ + id + {TITLESCHEMA} + }} + }} + characters {{ + edges {{ + id + node {{ + id + name {{ + full + }} + }} + }} + nodes {{ + id + name {{ + full + }} + }} + }} + staff {{ + edges {{ + id + node {{ + id + name {{ + full + }} + }} + }} + nodes {{ + id + name {{ + full + }} + }} + }} + studios {{ + edges {{ + id + node {{ + id + name + }} + }} + nodes {{ + id + name + }} + }} +""" + +""" +FavouritesSchema is a string representing the GraphQL schema for a favourites query. +It includes the anime, manga, characters, staff, and studios schema. + +Attributes: + anime (str): The anime schema of the favourites. + manga (str): The manga schema of the favourites. + characters (str): The characters schema of the favourites. + staff (str): The staff schema of the favourites. + studios (str): The studios schema of the favourites. +""" diff --git a/AniLinkPy/apis/anilist/schemas/name_schema.py b/AniLinkPy/apis/anilist/schemas/name_schema.py index cb390b1..fa12a95 100644 --- a/AniLinkPy/apis/anilist/schemas/name_schema.py +++ b/AniLinkPy/apis/anilist/schemas/name_schema.py @@ -1,3 +1,12 @@ +NAMESCHEMA = """ +name { +first +last +full +native +} +""" + """ This is the NameSchema for the Anilist API. It defines the structure of the name data that is expected to be returned from the API. @@ -8,12 +17,3 @@ full (str): The user's full name. native (str): The user's name in their native language. """ - -NAMESCHEMA = """ -name { -first -last -full -native -} -""" diff --git a/AniLinkPy/apis/anilist/schemas/next_airing_episode_schema.py b/AniLinkPy/apis/anilist/schemas/next_airing_episode_schema.py new file mode 100644 index 0000000..b05bcb1 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/next_airing_episode_schema.py @@ -0,0 +1,17 @@ +NEXTAIRINGEPISODESCHEMA = """ + nextAiringEpisode { + airingAt + timeUntilAiring + episode + } +""" + +""" +This is the NextAiringEpisodeSchema for the AniList API. It defines the structure of the next airing episode data +that is expected to be returned from the API. + +Attributes: + airingAt (int): The airing time of the episode. + timeUntilAiring (int): The time until the episode airs. + episode (int): The episode number. +""" diff --git a/AniLinkPy/apis/anilist/schemas/notification_schema.py b/AniLinkPy/apis/anilist/schemas/notification_schema.py new file mode 100644 index 0000000..30234c5 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/notification_schema.py @@ -0,0 +1,39 @@ +from AniLinkPy.apis.anilist.schemas.basic_schema import ( + BASICCOMMENTSCHEMA, + BASICTHREADSCHEMA, + BASICUSERSCHEMA, +) + +THREADNOTIFICATIONSCHEMA = f""" + id + userId + type + commentId + context + createdAt + thread {{ + {BASICTHREADSCHEMA} + }} + comment {{ + {BASICCOMMENTSCHEMA} + }} + user {{ + {BASICUSERSCHEMA} + }} +""" + +""" +This is the NotificationSchema for the AniList API. It defines the structure of the notification data that is +expected to be returned from the API. + +Attributes: + id (int): The id of the thread notification. + userId (int): The user id associated with the thread notification. + type (str): The type of the thread notification. + commentId (int): The comment id associated with the thread notification. + context (str): The context of the thread notification. + createdAt (str): The creation time of the thread notification. + thread (str): The thread associated with the thread notification. + comment (str): The comment associated with the thread notification. + user (str): The user associated with the thread notification. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/airing_schedule_schema.py b/AniLinkPy/apis/anilist/schemas/query/airing_schedule_schema.py new file mode 100644 index 0000000..c9b5274 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/query/airing_schedule_schema.py @@ -0,0 +1,25 @@ +from AniLinkPy.apis.anilist.schemas.query.media_schema import MEDIASCHEMA + +AIRINGSCHEDULESCHEMA = f""" + id + airingAt + timeUntilAiring + episode + mediaId + media {{ + {MEDIASCHEMA} + }} +""" + +""" +AiringScheduleSchema is a string representing the GraphQL schema for an airing schedule query. +It includes the id, airing time, time until airing, episode number, media id, and the media schema. + +Attributes: + id (int): The id of the airing schedule. + airingAt (int): The airing time of the airing schedule. + timeUntilAiring (int): The time until airing of the airing schedule. + episode (int): The episode number of the airing schedule. + mediaId (int): The media id of the airing schedule. + media (str): The media schema of the airing schedule. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/character_schema.py b/AniLinkPy/apis/anilist/schemas/query/character_schema.py new file mode 100644 index 0000000..6cf24f4 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/query/character_schema.py @@ -0,0 +1,50 @@ +from AniLinkPy.apis.anilist.schemas.fuzzy_date_schema import FUZZYDATESCHEMA +from AniLinkPy.apis.anilist.schemas.image_schema import IMAGESCHEMA +from AniLinkPy.apis.anilist.schemas.name_schema import NAMESCHEMA +from AniLinkPy.apis.anilist.schemas.title_schema import TITLESCHEMA + +CHARACTERSCHEMA = f""" + id + {NAMESCHEMA} + {IMAGESCHEMA} + description(asHtml: $asHtml) + gender + dateOfBirth {{ + {FUZZYDATESCHEMA} + }} + age + bloodType + isFavourite + isFavouriteBlocked + siteUrl + media(sort: $mediaSort, onList: $mediaOnList, page: $mediaPage, perPage: $mediaPerPage) {{ + nodes {{ + id + {TITLESCHEMA} + }} + }} + favourites + modNotes +""" + +""" +CharacterSchema is a string representing the GraphQL schema for a character query. It includes the character's id, +name, image, description, gender, date of birth, age, blood type, favourite status, site URL, associated media, +number of favourites, and moderator notes. + +Attributes: + id (int): The id of the character. + name (str): The name schema of the character. + image (str): The image schema of the character. + description (str): The description of the character. + gender (str): The gender of the character. + dateOfBirth (str): The fuzzy date schema of the character's date of birth. + age (int): The age of the character. + bloodType (str): The blood type of the character. + isFavourite (bool): The favourite status of the character. + isFavouriteBlocked (bool): The favourite blocked status of the character. + siteUrl (str): The site URL of the character. + media (str): The media schema of the character. + favourites (int): The number of favourites of the character. + modNotes (str): The moderator notes of the character. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/media_list_collection_schema.py b/AniLinkPy/apis/anilist/schemas/query/media_list_collection_schema.py new file mode 100644 index 0000000..e377a8b --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/query/media_list_collection_schema.py @@ -0,0 +1,24 @@ +from AniLinkPy.apis.anilist.schemas.query.media_list_schema import MEDIALISTSCHEMA + +MEDIALISTCOLLECTIONSCHEMA = f""" + lists {{ + entries {{ + {MEDIALISTSCHEMA} + name + isCustomList + isSplitCompletedList + status + }} + hasNextChunk + }} +""" + +""" +MediaListCollectionQuerySchema is a string representing the GraphQL schema for a media list collection query. +It includes the media list collection, lists, entries, user, and hasNextChunk status. + +Attributes: + lists (list): The lists of the media list collection. + entries (list): The entries of the media list collection. + hasNextChunk (bool): The hasNextChunk status of the media list collection. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/media_list_schema.py b/AniLinkPy/apis/anilist/schemas/query/media_list_schema.py new file mode 100644 index 0000000..ed1c039 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/query/media_list_schema.py @@ -0,0 +1,58 @@ +from AniLinkPy.apis.anilist.schemas.fuzzy_date_schema import FUZZYDATESCHEMA +from AniLinkPy.apis.anilist.schemas.query.media_schema import MEDIASCHEMA + +MEDIALISTSCHEMA = f""" + id + userId + mediaId + status + score (format: $ScoreFormat) + progress + progressVolumes + repeat + priority + private + notes + hiddenFromStatusLists + customLists (asArray: $asArray) + advancedScores + startedAt {{ + {FUZZYDATESCHEMA} + }} + completedAt {{ + {FUZZYDATESCHEMA} + }} + updatedAt + createdAt + media {{ + {MEDIASCHEMA} + }} +""" + +""" +MediaListSchema is a string representing the GraphQL schema for a media list query. It includes the id, user id, +media id, status, score, progress, progress volumes, repeat, priority, private status, notes, hidden from status +lists status, custom lists, advanced scores, started at date, completed at date, updated at timestamp, created at +timestamp, media, and user. + +Attributes: + id (int): The id of the media list. + userId (int): The user id of the media list. + mediaId (int): The media id of the media list. + status (str): The status of the media list. + score (str): The score of the media list. + progress (int): The progress of the media list. + progressVolumes (int): The progress volumes of the media list. + repeat (int): The repeat of the media list. + priority (int): The priority of the media list. + private (bool): The private status of the media list. + notes (str): The notes of the media list. + hiddenFromStatusLists (bool): The hidden from status lists status of the media list. + customLists (str): The custom lists of the media list. + advancedScores (list): The advanced scores of the media list. + startedAt (str): The started at date of the media list. + completedAt (str): The completed at date of the media list. + updatedAt (int): The updated at timestamp of the media list. + createdAt (int): The created at timestamp of the media list. + media (str): The media of the media list. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/media_schema.py b/AniLinkPy/apis/anilist/schemas/query/media_schema.py new file mode 100644 index 0000000..61ee924 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/query/media_schema.py @@ -0,0 +1,126 @@ +from AniLinkPy.apis.anilist.schemas.cover_image_schema import COVERIMAGESCHEMA +from AniLinkPy.apis.anilist.schemas.distribution_schema import ( + SCOREDISTRIBUTIONSCHEMA, + STATUSDISTRIBUTIONSCHEMA, +) +from AniLinkPy.apis.anilist.schemas.external_link_schema import EXTERNALLINKSCHEMA +from AniLinkPy.apis.anilist.schemas.fuzzy_date_schema import FUZZYDATESCHEMA +from AniLinkPy.apis.anilist.schemas.media_list_entry_schema import MEDIALISTENTRYSCHEMA +from AniLinkPy.apis.anilist.schemas.next_airing_episode_schema import ( + NEXTAIRINGEPISODESCHEMA, +) +from AniLinkPy.apis.anilist.schemas.ranking_schema import RANKINGSCHEMA +from AniLinkPy.apis.anilist.schemas.streaming_episode_schema import ( + STREAMINGEPISODESCHEMA, +) +from AniLinkPy.apis.anilist.schemas.tag_schema import TAGSCHEMA +from AniLinkPy.apis.anilist.schemas.title_schema import TITLESCHEMA +from AniLinkPy.apis.anilist.schemas.trailer_schema import TRAILERSCHEMA + +MEDIASCHEMA = f""" + id + idMal + {TITLESCHEMA} + type + format + status + description (asHtml: $asHtml) + startDate {{ + {FUZZYDATESCHEMA} + }} + endDate {{ + {FUZZYDATESCHEMA} + }} + season + seasonYear + seasonInt + episodes + duration + chapters + volumes + countryOfOrigin + isLicensed + source + hashtag + {TRAILERSCHEMA} + updatedAt + {COVERIMAGESCHEMA} + bannerImage + genres + synonyms + averageScore + meanScore + popularity + isLocked + trending + favourites + tags {{ + {TAGSCHEMA} + }} + isFavourite + isAdult + {NEXTAIRINGEPISODESCHEMA} + {EXTERNALLINKSCHEMA} + {STREAMINGEPISODESCHEMA} + {RANKINGSCHEMA} + {MEDIALISTENTRYSCHEMA} + stats {{ + {STATUSDISTRIBUTIONSCHEMA} + {SCOREDISTRIBUTIONSCHEMA} + }} + siteUrl + autoCreateForumThread + isRecommendationBlocked + modNotes +""" + +""" +This is the MediaSchema for the AniList API. It defines the structure of the media data that is expected to be +returned from the API. + +Attributes: + id (int): The media's ID. + idMal (int): The media's ID on MyAnimeList. + title (dict): The media's title, with 'romaji', 'english', and 'native' versions. + type (str): The type of the media (e.g., ANIME or MANGA). + format (str): The format of the media (e.g., TV, TV_SHORT, MOVIE, SPECIAL, OVA, ONA, MUSIC, MANGA, NOVEL, ONE_SHOT). + status (str): The status of the media (e.g., FINISHED, RELEASING, NOT_YET_RELEASED, CANCELLED). + description (str): The media's description. + startDate (dict): The media's start date, with 'year', 'month', and 'day'. + endDate (dict): The media's end date, with 'year', 'month', and 'day'. + season (str): The media's season (e.g., WINTER, SPRING, SUMMER, FALL). + seasonYear (int): The year of the media's season. + seasonInt (int): The integer representation of the media's season. + episodes (int): The number of episodes in the media. + duration (int): The duration of each episode in the media. + chapters (int): The number of chapters in the media. + volumes (int): The number of volumes in the media. + countryOfOrigin (str): The country of origin of the media. + isLicensed (bool): Whether the media is licensed. + source (str): The source of the media (e.g., ORIGINAL, MANGA, LIGHT_NOVEL, VISUAL_NOVEL, VIDEO_GAME, OTHER). + hashtag (str): The media's hashtag. + updatedAt (int): The timestamp of when the media was last updated. + coverImage (dict): The media's cover image, with 'extraLarge', 'large', 'medium', and 'color' versions. + bannerImage (str): The URL of the media's banner image. + genres (list): The media's genres. + synonyms (list): The media's synonyms. + averageScore (int): The media's average score. + meanScore (int): The media's mean score. + popularity (int): The media's popularity. + isLocked (bool): Whether the media is locked. + trending (int): The media's trending rank. + favourites (int): The number of users who have the media in their favourites. + tags (list): The media's tags. + isFavourite (bool): Whether the media is a favourite. + isAdult (bool): Whether the media is for adults. + nextAiringEpisode (dict): The media's next airing episode, with 'airingAt', 'timeUntilAiring', and 'episode'. + externalLinks (list): The media's external links. + streamingEpisodes (list): The media's streaming episodes. + rankings (list): The media's rankings. + mediaListEntry (dict): The media's list entry. + stats (dict): The media's stats. + siteUrl (str): The media's site URL. + autoCreateForumThread (bool): Whether a forum thread is automatically created for the media. + isRecommendationBlocked (bool): Whether recommendation is blocked for the media. + modNotes (str): The moderator's notes for the media. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/media_trend_schema.py b/AniLinkPy/apis/anilist/schemas/query/media_trend_schema.py new file mode 100644 index 0000000..e8cc683 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/query/media_trend_schema.py @@ -0,0 +1,32 @@ +from AniLinkPy.apis.anilist.schemas.query.media_schema import MEDIASCHEMA + +MEDIATRENDSCHEMA = f""" + mediaId + date + trending + averageScore + popularity + inProgress + releasing + episode + media {{ + {MEDIASCHEMA} + }} +""" + +""" +MediaTrendSchema is a string representing the GraphQL schema for a media trend query. It includes the media's id, +date, trending status, average score, popularity, in progress status, releasing status, episode number, and media of +type `Media`. + +Attributes: + mediaId (int): The id of the media. + date (int): The date of the media trend. + trending (int): The trending status of the media. + averageScore (int): The average score of the media. + popularity (int): The popularity of the media. + inProgress (bool): The in progress status of the media. + releasing (bool): The releasing status of the media. + episode (int): The episode number of the media. + media (str): The media schema of the media. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/media_with_relations_schema.py b/AniLinkPy/apis/anilist/schemas/query/media_with_relations_schema.py new file mode 100644 index 0000000..cfb59f4 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/query/media_with_relations_schema.py @@ -0,0 +1,209 @@ +from AniLinkPy.apis.anilist.schemas.cover_image_schema import COVERIMAGESCHEMA +from AniLinkPy.apis.anilist.schemas.distribution_schema import ( + SCOREDISTRIBUTIONSCHEMA, + STATUSDISTRIBUTIONSCHEMA, +) +from AniLinkPy.apis.anilist.schemas.external_link_schema import EXTERNALLINKSCHEMA +from AniLinkPy.apis.anilist.schemas.fuzzy_date_schema import FUZZYDATESCHEMA +from AniLinkPy.apis.anilist.schemas.image_schema import IMAGESCHEMA +from AniLinkPy.apis.anilist.schemas.media_list_entry_schema import MEDIALISTENTRYSCHEMA +from AniLinkPy.apis.anilist.schemas.name_schema import NAMESCHEMA +from AniLinkPy.apis.anilist.schemas.next_airing_episode_schema import ( + NEXTAIRINGEPISODESCHEMA, +) +from AniLinkPy.apis.anilist.schemas.ranking_schema import RANKINGSCHEMA +from AniLinkPy.apis.anilist.schemas.streaming_episode_schema import ( + STREAMINGEPISODESCHEMA, +) +from AniLinkPy.apis.anilist.schemas.tag_schema import TAGSCHEMA +from AniLinkPy.apis.anilist.schemas.title_schema import TITLESCHEMA +from AniLinkPy.apis.anilist.schemas.trailer_schema import TRAILERSCHEMA + +MEDIAWITHRELATIONSSCHEMA = f""" + id + idMal + {TITLESCHEMA} + type + format + status + description (asHtml: $asHtml) + startDate {{ + {FUZZYDATESCHEMA} + }} + endDate {{ + {FUZZYDATESCHEMA} + }} + season + seasonYear + seasonInt + episodes + duration + chapters + volumes + countryOfOrigin + isLicensed + source + hashtag + {TRAILERSCHEMA} + updatedAt + {COVERIMAGESCHEMA} + bannerImage + genres + synonyms + averageScore + meanScore + popularity + isLocked + trending + favourites + tags {{ + {TAGSCHEMA} + }} + relations {{ + edges {{ + id + relationType + isMainStudio + characters {{ + id + {NAMESCHEMA} + {IMAGESCHEMA} + description (asHtml: $asHtml) + gender + dateOfBirth {{ + {FUZZYDATESCHEMA} + }} + age + bloodType + isFavourite + isFavouriteBlocked + siteUrl + favourites + modNotes + }} + characterRole + characterName + roleNotes + dubGroup + staffRole + node {{ + id + {TITLESCHEMA} + }} + }} + }} + characters {{ + edges {{ + id + role + name + voiceActors {{ + id + {NAMESCHEMA} + {IMAGESCHEMA} + }} + media {{ + id + {TITLESCHEMA} + {COVERIMAGESCHEMA} + }} + favouriteOrder + node {{ + id + {NAMESCHEMA} + {IMAGESCHEMA} + }} + }} + }} + staff {{ + edges {{ + id + role + favouriteOrder + node {{ + id + {NAMESCHEMA} + {IMAGESCHEMA} + }} + }} + }} + studios {{ + edges {{ + id + isMain + favouriteOrder + node {{ + id + name + isAnimationStudio + siteUrl + }} + }} + }} + isFavourite + isAdult + {NEXTAIRINGEPISODESCHEMA} + {EXTERNALLINKSCHEMA} + {STREAMINGEPISODESCHEMA} + {RANKINGSCHEMA} + {MEDIALISTENTRYSCHEMA} + stats {{ + {STATUSDISTRIBUTIONSCHEMA} + {SCOREDISTRIBUTIONSCHEMA} + }} + siteUrl + autoCreateForumThread + isRecommendationBlocked + modNotes +""" + +""" +This is the schema for a media with relations Query. + +Attributes: + id (int): The media's ID. + idMal (int): The media's ID on MyAnimeList. + title (dict): The media's title, with 'romaji', 'english', and 'native' versions. + type (str): The type of the media (e.g., ANIME or MANGA). + format (str): The format of the media (e.g., TV, TV_SHORT, MOVIE, SPECIAL, OVA, ONA, MUSIC, MANGA, NOVEL, ONE_SHOT). + status (str): The status of the media (e.g., FINISHED, RELEASING, NOT_YET_RELEASED, CANCELLED). + description (str): The media's description. + startDate (dict): The media's start date, with 'year', 'month', and 'day'. + endDate (dict): The media's end date, with 'year', 'month', and 'day'. + season (str): The media's season (e.g., WINTER, SPRING, SUMMER, FALL). + seasonYear (int): The year of the media's season. + seasonInt (int): The integer representation of the media's season. + episodes (int): The number of episodes in the media. + duration (int): The duration of each episode in the media. + chapters (int): The number of chapters in the media. + volumes (int): The number of volumes in the media. + countryOfOrigin (str): The country of origin of the media. + isLicensed (bool): Whether the media is licensed. + source (str): The source of the media (e.g., ORIGINAL, MANGA, LIGHT_NOVEL, VISUAL_NOVEL, VIDEO_GAME, OTHER). + hashtag (str): The media's hashtag. + updatedAt (int): The timestamp of when the media was last updated. + coverImage (dict): The media's cover image, with 'extraLarge', 'large', 'medium', and 'color' versions. + bannerImage (str): The URL of the media's banner image. + genres (list): The media's genres. + synonyms (list): The media's synonyms. + averageScore (int): The media's average score. + meanScore (int): The media's mean score. + popularity (int): The media's popularity. + isLocked (bool): Whether the media is locked. + trending (int): The media's trending rank. + favourites (int): The number of users who have the media in their favourites. + tags (list): The media's tags. + isFavourite (bool): Whether the media is a favourite. + isAdult (bool): Whether the media is for adults. + nextAiringEpisode (dict): The media's next airing episode, with 'airingAt', 'timeUntilAiring', and 'episode'. + externalLinks (list): The media's external links. + streamingEpisodes (list): The media's streaming episodes. + rankings (list): The media's rankings. + mediaListEntry (dict): The media's list entry. + stats (dict): The media's stats. + siteUrl (str): The media's site URL. + autoCreateForumThread (bool): Whether a forum thread is automatically created for the media. + isRecommendationBlocked (bool): Whether recommendation is blocked for the media. + modNotes (str): The moderator's notes for the media. + relations (dict): The media's relations with other entities, including characters, staff, and studios. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/notification_schema.py b/AniLinkPy/apis/anilist/schemas/query/notification_schema.py new file mode 100644 index 0000000..bfd5acb --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/query/notification_schema.py @@ -0,0 +1,193 @@ +from AniLinkPy.apis.anilist.schemas.activity_schema import ACTIVITYNOTIFICATIONSCHEMA +from AniLinkPy.apis.anilist.schemas.basic_schema import ( + BASICCOMMENTSCHEMA, + BASICUSERSCHEMA, +) +from AniLinkPy.apis.anilist.schemas.notification_schema import THREADNOTIFICATIONSCHEMA +from AniLinkPy.apis.anilist.schemas.title_schema import TITLESCHEMA + +NOTIFICATIONSCHEMA = f""" + ... on AiringNotification {{ + id + type + animeId + episode + contexts + createdAt + media {{ + id + {TITLESCHEMA} + }} + }} + ... on FollowingNotification {{ + id + type + userId + context + createdAt + user {{ + {BASICUSERSCHEMA} + }} + }} + ... on ActivityMessageNotification {{ + id + userId + type + activityId + context + createdAt + message {{ + id + recipientId + messengerId + type + replyCount + message (asHtml: $asHtml) + isLocked + isSubscribed + likeCount + isLiked + isPrivate + siteUrl + createdAt + replies {{ + id + userId + activityId + text (asHtml: $asHtml) + createdAt + likeCount + isLiked + user {{ + {BASICUSERSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} + }} + likes {{ + {BASICUSERSCHEMA} + }} + }} + user {{ + {BASICUSERSCHEMA} + }} + }} + ... on ActivityMentionNotification {{ + {ACTIVITYNOTIFICATIONSCHEMA} + }} + ... on ActivityReplyNotification {{ + {ACTIVITYNOTIFICATIONSCHEMA} + }} + ... on ActivityReplySubscribedNotification {{ + {ACTIVITYNOTIFICATIONSCHEMA} + }} + ... on ActivityLikeNotification {{ + {ACTIVITYNOTIFICATIONSCHEMA} + }} + ... on ActivityReplyLikeNotification {{ + {ACTIVITYNOTIFICATIONSCHEMA} + }} + ... on ThreadCommentMentionNotification {{ + {THREADNOTIFICATIONSCHEMA} + }} + ... on ThreadCommentReplyNotification {{ + {THREADNOTIFICATIONSCHEMA} + }} + ... on ThreadCommentSubscribedNotification {{ + {THREADNOTIFICATIONSCHEMA} + }} + ... on ThreadCommentLikeNotification {{ + {THREADNOTIFICATIONSCHEMA} + }} + ... on ThreadLikeNotification {{ + id + userId + type + context + createdAt + thread {{ + ${{BasicThreadSchema}} + }} + comment {{ + {BASICCOMMENTSCHEMA} + }} + user {{ + {BASICUSERSCHEMA} + }} + }} + ... on RelatedMediaAdditionNotification {{ + id + type + mediaId + context + createdAt + media {{ + id + {TITLESCHEMA} + }} + }} + ... on MediaDataChangeNotification {{ + id + type + mediaId + context + reason + createdAt + media {{ + id + {TITLESCHEMA} + }} + }} + ... on MediaMergeNotification {{ + id + type + mediaId + deletedMediaTitles + context + reason + createdAt + media {{ + id + {TITLESCHEMA} + }} + }} + ... on MediaDeletionNotification {{ + id + type + deletedMediaTitle + context + reason + createdAt + }} +""" + +""" +NotificationSchema is a string representing the GraphQL schema for a notification query. It includes various types +of notifications such as AiringNotification, FollowingNotification, ActivityMessageNotification, +ActivityMentionNotification, ActivityReplyNotification, ActivityReplySubscribedNotification, +ActivityLikeNotification, ActivityReplyLikeNotification, ThreadCommentMentionNotification, +ThreadCommentReplyNotification, ThreadCommentSubscribedNotification, ThreadCommentLikeNotification, +ThreadLikeNotification, RelatedMediaAdditionNotification, MediaDataChangeNotification, MediaMergeNotification, +and MediaDeletionNotification. + +Attributes: + id (int): The id of the notification. + type (str): The type of the notification. + animeId (int): The anime id of the notification. + episode (int): The episode of the notification. + contexts (list): The contexts of the notification. + createdAt (int): The created at timestamp of the notification. + media (str): The media schema of the notification. + userId (int): The user id of the notification. + context (str): The context of the notification. + user (str): The basic user schema of the notification. + activityId (int): The activity id of the notification. + message (str): The message of the notification. + thread (str): The basic thread schema of the notification. + comment (str): The basic comment schema of the notification. + mediaId (int): The media id of the notification. + reason (str): The reason of the notification. + deletedMediaTitles (list): The deleted media titles of the notification. + deletedMediaTitle (str): The deleted media title of the notification. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/recommendation_schema.py b/AniLinkPy/apis/anilist/schemas/query/recommendation_schema.py new file mode 100644 index 0000000..9903839 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/query/recommendation_schema.py @@ -0,0 +1,30 @@ +from AniLinkPy.apis.anilist.schemas.basic_schema import BASICUSERSCHEMA +from AniLinkPy.apis.anilist.schemas.query.media_schema import MEDIASCHEMA + +RECOMMENDATIONSCHEMA = f""" + id + rating + userRating + media {{ + {MEDIASCHEMA} + }} + mediaRecommendation {{ + {MEDIASCHEMA} + }} + user {{ + {BASICUSERSCHEMA} + }} +""" + +""" +RecommendationSchema is a string representing the GraphQL schema for a recommendation query. +It includes the id, rating, user rating, media, media recommendation, and user. + +Attributes: + id (int): The id of the recommendation. + rating (int): The rating of the recommendation. + userRating (int): The user rating of the recommendation. + media (str): The media schema of the recommendation. + mediaRecommendation (str): The media recommendation schema of the recommendation. + user (str): The basic user schema of the recommendation. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/review_schema.py b/AniLinkPy/apis/anilist/schemas/query/review_schema.py new file mode 100644 index 0000000..9eaf1c8 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/query/review_schema.py @@ -0,0 +1,46 @@ +from AniLinkPy.apis.anilist.schemas.basic_schema import BASICUSERSCHEMA +from AniLinkPy.apis.anilist.schemas.query.media_schema import MEDIASCHEMA + +REVIEWSCHEMA = f""" + id + mediaId + userId + mediaType + summary + body (asHtml: $asHtml) + rating + ratingAmount + score + private + siteUrl + createdAt + updatedAt + user {{ + {BASICUSERSCHEMA} + }} + media {{ + {MEDIASCHEMA} + }} +""" + +""" +ReviewSchema is a string representing the GraphQL schema for a review query. It includes the id, mediaId, userId, +mediaType, summary, body, rating, ratingAmount, score, private status, siteUrl, createdAt, updatedAt, user, and media. + +Attributes: + id (int): The id of the review. + mediaId (int): The media id of the review. + userId (int): The user id of the review. + mediaType (str): The media type of the review. + summary (str): The summary of the review. + body (str): The body of the review. + rating (int): The rating of the review. + ratingAmount (int): The rating amount of the review. + score (int): The score of the review. + private (bool): The private status of the review. + siteUrl (str): The site url of the review. + createdAt (int): The created at timestamp of the review. + updatedAt (int): The updated at timestamp of the review. + user (str): The basic user schema of the review. + media (str): The media schema of the review. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/site_statistics_schema.py b/AniLinkPy/apis/anilist/schemas/query/site_statistics_schema.py new file mode 100644 index 0000000..cb36ea7 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/query/site_statistics_schema.py @@ -0,0 +1,39 @@ +from AniLinkPy.apis.anilist.schemas.site_trend_schema import SITETRENDCONNECTIONSCHEMA + +SITESTATISTICSSCHEMA = f""" + users (sort: $usersSort, page: $usersPage, perPage: $usersPerPage) {{ + {SITETRENDCONNECTIONSCHEMA} + }} + anime (sort: $animeSort, page: $animePage, perPage: $animePerPage) {{ + {SITETRENDCONNECTIONSCHEMA} + }} + manga (sort: $mangaSort, page: $mangaPage, perPage: $mangaPerPage) {{ + {SITETRENDCONNECTIONSCHEMA} + }} + characters (sort: $charactersSort, page: $charactersPage, perPage: $charactersPerPage) {{ + {SITETRENDCONNECTIONSCHEMA} + }} + staff (sort: $staffSort, page: $staffPage, perPage: $staffPerPage) {{ + {SITETRENDCONNECTIONSCHEMA} + }} + studios (sort: $studiosSort, page: $studiosPage, perPage: $studiosPerPage) {{ + {SITETRENDCONNECTIONSCHEMA} + }} + reviews (sort: $reviewsSort, page: $reviewsPage, perPage: $reviewsPerPage) {{ + {SITETRENDCONNECTIONSCHEMA} + }} +""" + +""" +SiteStatisticsSchema is a string representing the GraphQL schema for a site statistics query. +It includes users, anime, manga, characters, staff, studios, and reviews of type `SiteTrendConnection`. + +Attributes: + users (str): The users schema of the site statistics. + anime (str): The anime schema of the site statistics. + manga (str): The manga schema of the site statistics. + characters (str): The characters schema of the site statistics. + staff (str): The staff schema of the site statistics. + studios (str): The studios schema of the site statistics. + reviews (str): The reviews schema of the site statistics. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/staff_schema.py b/AniLinkPy/apis/anilist/schemas/query/staff_schema.py new file mode 100644 index 0000000..6259483 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/query/staff_schema.py @@ -0,0 +1,71 @@ +from AniLinkPy.apis.anilist.schemas.fuzzy_date_schema import FUZZYDATESCHEMA +from AniLinkPy.apis.anilist.schemas.image_schema import IMAGESCHEMA +from AniLinkPy.apis.anilist.schemas.name_schema import NAMESCHEMA +from AniLinkPy.apis.anilist.schemas.title_schema import TITLESCHEMA + +STAFFSCHEMA = f""" + id + {NAMESCHEMA} + languageV2 + {IMAGESCHEMA} + description(asHtml: $asHtml) + primaryOccupations + gender + dateOfBirth {{ + {FUZZYDATESCHEMA} + }} + dateOfDeath {{ + {FUZZYDATESCHEMA} }} age yearsActive homeTown bloodType isFavourite isFavouriteBlocked siteUrl staffMedia (sort: + $staffMediaSort, type: $staffMediaType, onList: $staffMediaOnList, page: $staffMediaPage, + perPage: $staffMediaPerPage) {{ nodes {{ id {TITLESCHEMA} + }} + }} + characters (sort: $charactersSort, page: $charactersPage, perPage: $charactersPerPage) {{ + nodes {{ + id + {NAMESCHEMA} }} }} characterMedia (sort: $characterMediaSort, onList: $characterMediaOnList, + page: $characterMediaPage, perPage: $characterMediaPerPage) {{ nodes {{ id {TITLESCHEMA} + }} + }} + submitter {{ + id + name + }} + submissionStatus + submissionNotes + favourites + modNotes +""" + +""" +StaffSchema is a string representing the GraphQL schema for a staff query. It includes the staff's id, name, +language, image, description, primary occupations, gender, date of birth, date of death, age, years active, hometown, +blood type, favourite status, favourite blocked status, site url, staff media, characters, character media, staff, +submitter, submission status, submission notes, favourites, and mod notes. + +Attributes: + id (int): The id of the staff. + name (str): The name schema of the staff. + languageV2 (str): The language of the staff. + image (str): The image schema of the staff. + description (str): The description of the staff. + primaryOccupations (list): The primary occupations of the staff. + gender (str): The gender of the staff. + dateOfBirth (str): The fuzzy date schema of the staff's date of birth. + dateOfDeath (str): The fuzzy date schema of the staff's date of death. + age (int): The age of the staff. + yearsActive (int): The years active of the staff. + homeTown (str): The hometown of the staff. + bloodType (str): The blood type of the staff. + isFavourite (bool): The favourite status of the staff. + isFavouriteBlocked (bool): The favourite blocked status of the staff. + siteUrl (str): The site url of the staff. + staffMedia (str): The staff media schema of the staff. + characters (str): The characters schema of the staff. + characterMedia (str): The character media schema of the staff. + submitter (str): The submitter of the staff. + submissionStatus (int): The submission status of the staff. + submissionNotes (str): The submission notes of the staff. + favourites (int): The favourites of the staff. + modNotes (str): The mod notes of the staff. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/studio_schema.py b/AniLinkPy/apis/anilist/schemas/query/studio_schema.py new file mode 100644 index 0000000..f0e6b40 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/query/studio_schema.py @@ -0,0 +1,68 @@ +from AniLinkPy.apis.anilist.schemas.image_schema import IMAGESCHEMA +from AniLinkPy.apis.anilist.schemas.name_schema import NAMESCHEMA +from AniLinkPy.apis.anilist.schemas.query.character_schema import CHARACTERSCHEMA +from AniLinkPy.apis.anilist.schemas.query.media_schema import MEDIASCHEMA +from AniLinkPy.apis.anilist.schemas.query.staff_schema import STAFFSCHEMA + +STUDIOSCHEMA = f""" + id + name + isAnimationStudio + media (sort: $mediaSort, isMain: $mediaIsMain onList: $mediaOnList, page: $mediaPage, perPage: $mediaPerPage) {{ + edges {{ + id + relationType + isMainStudio + characters {{ + {CHARACTERSCHEMA} + }} + characterRole + characterName + roleNotes + dubGroup + voiceActors {{ + {STAFFSCHEMA} + }} + voiceActorRoles {{ + voiceActor {{ + id + {NAMESCHEMA} + {IMAGESCHEMA} + }} + roleNotes + dubGroup + }} + favouriteOrder + node {{ + {MEDIASCHEMA} + }} + }} + nodes {{ + {MEDIASCHEMA} + }} + pageInfo {{ + total + perPage + currentPage + lastPage + hasNextPage + }} + }} + siteUrl + isFavourite + favourites +""" + +""" +StudioSchema is a string representing the GraphQL schema for a studio query. +It includes the studio's id, name, animation studio status, media, site url, favourite status, and favourites count. + +Attributes: + id (int): The id of the studio. + name (str): The name of the studio. + isAnimationStudio (bool): The animation studio status of the studio. + media (str): The media schema of the studio. + siteUrl (str): The site url of the studio. + isFavourite (bool): The favourite status of the studio. + favourites (int): The favourites count of the studio. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/thread_comment_schema.py b/AniLinkPy/apis/anilist/schemas/query/thread_comment_schema.py new file mode 100644 index 0000000..5445e49 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/query/thread_comment_schema.py @@ -0,0 +1,47 @@ +from AniLinkPy.apis.anilist.schemas.basic_schema import BASICUSERSCHEMA +from AniLinkPy.apis.anilist.schemas.query.thread_schema import THREADSCHEMA + +THREADCOMMENTSCHEMA = f""" + id + userId + threadId + comment (asHtml: $asHtml) + likeCount + isLiked + siteUrl + createdAt + updatedAt + thread {{ + {THREADSCHEMA} + }} + user {{ + {BASICUSERSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} + childComments + isLocked +""" + +""" +ThreadCommentSchema is a string representing the GraphQL schema for a thread comment query. It includes the +comment's id, userId, threadId, comment, likeCount, isLiked status, siteUrl, createdAt, updatedAt, thread of type +`ThreadResponse`, user of type `BasicUser`, likes of type `BasicUser[]`, childComments, and isLocked status. + +Attributes: + id (int): The id of the thread comment. + userId (int): The user id of the thread comment. + threadId (int): The thread id of the thread comment. + comment (str): The comment of the thread comment. + likeCount (int): The like count of the thread comment. + isLiked (bool): The liked status of the thread comment. + siteUrl (str): The site url of the thread comment. + createdAt (int): The created at timestamp of the thread comment. + updatedAt (int): The updated at timestamp of the thread comment. + thread (str): The thread schema of the thread comment. + user (str): The basic user schema of the thread comment. + likes (str): The basic user schema of the likes of the thread comment. + childComments (str): The child comments of the thread comment. + isLocked (bool): The locked status of the thread comment. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/thread_schema.py b/AniLinkPy/apis/anilist/schemas/query/thread_schema.py new file mode 100644 index 0000000..0234f86 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/query/thread_schema.py @@ -0,0 +1,69 @@ +from AniLinkPy.apis.anilist.schemas.basic_schema import BASICUSERSCHEMA +from AniLinkPy.apis.anilist.schemas.query.media_schema import MEDIASCHEMA + +THREADSCHEMA = f""" + id + title + body (asHtml: $asHtml) + userId + replyUserId + replyCommentId + replyCount + viewCount + isLocked + isSticky + isSubscribed + likeCount + isLiked + repliedAt + createdAt + updatedAt + user {{ + {BASICUSERSCHEMA} + }} + replyUser {{ + {BASICUSERSCHEMA} + }} + likes {{ + {BASICUSERSCHEMA} + }} + siteUrl + categories {{ + id + name + }} + mediaCategories {{ + {MEDIASCHEMA} + }} +""" + +""" +ThreadSchema is a string representing the GraphQL schema for a thread query. It includes the thread's id, title, +body, userId, replyUserId, replyCommentId, replyCount, viewCount, isLocked status, isSticky status, isSubscribed +status, likeCount, isLiked status, repliedAt, createdAt, updatedAt, user of type `BasicUser`, replyUser of type +`BasicUser`, likes of type `BasicUser[]`, siteUrl, categories, and mediaCategories of type `MediaResponse[]`. + +Attributes: + id (int): The id of the thread. + title (str): The title of the thread. + body (str): The body of the thread. + userId (int): The user id of the thread. + replyUserId (int): The reply user id of the thread. + replyCommentId (int): The reply comment id of the thread. + replyCount (int): The reply count of the thread. + viewCount (int): The view count of the thread. + isLocked (bool): The locked status of the thread. + isSticky (bool): The sticky status of the thread. + isSubscribed (bool): The subscribed status of the thread. + likeCount (int): The like count of the thread. + isLiked (bool): The liked status of the thread. + repliedAt (int): The replied at timestamp of the thread. + createdAt (int): The created at timestamp of the thread. + updatedAt (int): The updated at timestamp of the thread. + user (str): The basic user schema of the thread. + replyUser (str): The basic user schema of the reply user of the thread. + likes (str): The basic user schema of the likes of the thread. + siteUrl (str): The site url of the thread. + categories (str): The categories of the thread. + mediaCategories (str): The media schema of the media categories of the thread. +""" diff --git a/AniLinkPy/apis/anilist/schemas/query/user_schema.py b/AniLinkPy/apis/anilist/schemas/query/user_schema.py index 7e28a7d..efee2a2 100644 --- a/AniLinkPy/apis/anilist/schemas/query/user_schema.py +++ b/AniLinkPy/apis/anilist/schemas/query/user_schema.py @@ -1,32 +1,3 @@ -""" -This is the UserSchema for the Anilist API. It defines the structure of the user data that is expected to be -returned from the API. - -Attributes: - id (int): The user's ID. - name (str): The user's name. - about (str): The user's about information. - avatar (dict): The user's avatar, with 'large' and 'medium' sizes. - bannerImage (str): The URL of the user's banner image. - isFollowing (bool): Whether the user is following. - isFollower (bool): Whether the user is a follower. - isBlocked (bool): Whether the user is blocked. - bans (list): The user's bans. - options (dict): The user's options. - mediaListOptions (dict): The user's media list options. - favourites (dict): The user's favourites. - statistics (dict): The user's statistics. - stats (dict): The user's stats. - unreadNotificationCount (int): The user's unread notification count. - siteUrl (str): The user's site URL. - donatorTier (int): The user's donator tier. - donatorBadge (str): The user's donator badge. - moderatorRoles (list): The user's moderator roles. - createdAt (int): The timestamp of when the user was created. - updatedAt (int): The timestamp of when the user was last updated. - previousNames (list): The user's previous names. -""" - from AniLinkPy.apis.anilist.schemas.cover_image_schema import COVERIMAGESCHEMA from AniLinkPy.apis.anilist.schemas.image_schema import IMAGESCHEMA from AniLinkPy.apis.anilist.schemas.name_schema import NAMESCHEMA @@ -37,7 +8,7 @@ USERMANGASTATSSCHEMA, ) -UserSchema = f""" +USERSCHEMA = f""" id name about(asHtml: $asHtml) @@ -390,3 +361,32 @@ updatedAt }} """ + +""" +This is the UserSchema for the Anilist API. It defines the structure of the user data that is expected to be +returned from the API. + +Attributes: + id (int): The user's ID. + name (str): The user's name. + about (str): The user's about information. + avatar (dict): The user's avatar, with 'large' and 'medium' sizes. + bannerImage (str): The URL of the user's banner image. + isFollowing (bool): Whether the user is following. + isFollower (bool): Whether the user is a follower. + isBlocked (bool): Whether the user is blocked. + bans (list): The user's bans. + options (dict): The user's options. + mediaListOptions (dict): The user's media list options. + favourites (dict): The user's favourites. + statistics (dict): The user's statistics. + stats (dict): The user's stats. + unreadNotificationCount (int): The user's unread notification count. + siteUrl (str): The user's site URL. + donatorTier (int): The user's donator tier. + donatorBadge (str): The user's donator badge. + moderatorRoles (list): The user's moderator roles. + createdAt (int): The timestamp of when the user was created. + updatedAt (int): The timestamp of when the user was last updated. + previousNames (list): The user's previous names. +""" diff --git a/AniLinkPy/apis/anilist/schemas/ranking_schema.py b/AniLinkPy/apis/anilist/schemas/ranking_schema.py new file mode 100644 index 0000000..5b8ab1c --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/ranking_schema.py @@ -0,0 +1,27 @@ +RANKINGSCHEMA = """ + rankings { + id + rank + type + format + year + season + allTime + context + } +""" + +""" +This is the RankingSchema for the AniList API. It defines the structure of the ranking data that is expected to be +returned from the API. + +Attributes: + id (int): The id of the ranking. + rank (int): The rank of the ranking. + type (str): The type of the ranking. + format (str): The format of the ranking. + year (int): The year of the ranking. + season (str): The season of the ranking. + allTime (bool): The all-time status of the ranking. + context (str): The context of the ranking. +""" diff --git a/AniLinkPy/apis/anilist/schemas/site_trend_schema.py b/AniLinkPy/apis/anilist/schemas/site_trend_schema.py new file mode 100644 index 0000000..bea21c2 --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/site_trend_schema.py @@ -0,0 +1,43 @@ +SITETRENDSCHEMA = """ + date + count + change +""" + +""" +This is the SiteTrendSchema for the AniList API. It defines the structure of the site trend data that is expected +to be returned from the API. + +Attributes: + date (int): The date of the site trend. + count (int): The count of the site trend. + change (int): The change of the site trend. +""" + +SITETRENDCONNECTIONSCHEMA = f""" + pageInfo {{ + total + perPage + currentPage + lastPage + hasNextPage + }} + edges {{ + node {{ + {SITETRENDSCHEMA} + }} + }} + nodes {{ + {SITETRENDSCHEMA} + }} +""" + +""" +This is the SiteTrendConnectionSchema for the AniList API. It defines the structure of the site trend connection +data that is expected to be returned from the API. + +Attributes: + pageInfo (dict): The page information. + edges (dict): The edges of the site trend connection. + nodes (dict): The nodes of the site trend connection. +""" diff --git a/AniLinkPy/apis/anilist/schemas/streaming_episode_schema.py b/AniLinkPy/apis/anilist/schemas/streaming_episode_schema.py new file mode 100644 index 0000000..1dc580d --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/streaming_episode_schema.py @@ -0,0 +1,19 @@ +STREAMINGEPISODESCHEMA = """ + streamingEpisodes { + title + thumbnail + url + site + } +""" + +""" +This is the StreamingEpisodeSchema for the AniList API. It defines the structure of the streaming episode data +that is expected to be returned from the API. + +Attributes: + title (str): The title of the streaming episode. + thumbnail (str): The thumbnail of the streaming episode. + url (str): The url of the streaming episode. + site (str): The site of the streaming episode. +""" diff --git a/AniLinkPy/apis/anilist/schemas/tag_schema.py b/AniLinkPy/apis/anilist/schemas/tag_schema.py index 4872795..f73b9ba 100644 --- a/AniLinkPy/apis/anilist/schemas/tag_schema.py +++ b/AniLinkPy/apis/anilist/schemas/tag_schema.py @@ -1,3 +1,15 @@ +TAGSCHEMA = """ +id +name +description +category +rank +isGeneralSpoiler +isMediaSpoiler +isAdult +userId +""" + """ This is the TagSchema for the Anilist API. It defines the structure of the tag data that is expected to be returned from the API. @@ -13,15 +25,3 @@ isAdult (bool): Whether the tag is adult. userId (int): The user's ID. """ - -TAGSCHEMA = """ -id -name -description -category -rank -isGeneralSpoiler -isMediaSpoiler -isAdult -userId -""" diff --git a/AniLinkPy/apis/anilist/schemas/title_schema.py b/AniLinkPy/apis/anilist/schemas/title_schema.py index ec8c5f1..09614b1 100644 --- a/AniLinkPy/apis/anilist/schemas/title_schema.py +++ b/AniLinkPy/apis/anilist/schemas/title_schema.py @@ -1,3 +1,12 @@ +TITLESCHEMA = """ +title { + romaji + english + native + userPreferred +} +""" + """ This is the TitleSchema for the Anilist API. It defines the structure of the title data that is expected to be returned from the API. @@ -8,12 +17,3 @@ native (str): The title in the native language. userPreferred (str): The user's preferred title. """ - -TITLESCHEMA = """ -title { - romaji - english - native - userPreferred -} -""" diff --git a/AniLinkPy/apis/anilist/schemas/trailer_schema.py b/AniLinkPy/apis/anilist/schemas/trailer_schema.py new file mode 100644 index 0000000..ecbb74b --- /dev/null +++ b/AniLinkPy/apis/anilist/schemas/trailer_schema.py @@ -0,0 +1,16 @@ +TRAILERSCHEMA = """ + trailer { + id + site + thumbnail + } +""" + +""" +Trailer schema for AniList GraphQL API + +Attributes: + id (str): The ID of the trailer. + site (str): The site of the trailer. + thumbnail (str): The thumbnail of the trailer. +""" diff --git a/AniLinkPy/apis/anilist/schemas/user_stats_schema.py b/AniLinkPy/apis/anilist/schemas/user_stats_schema.py index f68e554..15c380f 100644 --- a/AniLinkPy/apis/anilist/schemas/user_stats_schema.py +++ b/AniLinkPy/apis/anilist/schemas/user_stats_schema.py @@ -1,3 +1,10 @@ +USERANIMESTATSSCHEMA = """ +count +meanScore +minutesWatched +mediaIds +""" + """ This is the UserAnimeStatsSchema for the Anilist API. It defines the structure of the user's anime statistics data that is expected to be returned from the API. @@ -9,10 +16,10 @@ mediaIds (list): The list of IDs of the anime the user has watched. """ -USERANIMESTATSSCHEMA = """ +USERMANGASTATSSCHEMA = """ count meanScore -minutesWatched +chaptersRead mediaIds """ @@ -26,9 +33,3 @@ chaptersRead (int): The total chapters the user has read in manga. mediaIds (list): The list of IDs of the manga the user has read. """ -USERMANGASTATSSCHEMA = """ -count -meanScore -chaptersRead -mediaIds -""" diff --git a/docs/AniLink/AniList/Mutations/schemas.md b/docs/AniLink/AniList/Mutations/schemas.md new file mode 100644 index 0000000..0042ac3 --- /dev/null +++ b/docs/AniLink/AniList/Mutations/schemas.md @@ -0,0 +1,7 @@ +# Mutation Schemas Documentation + +This is the documentation for the Mutation schemas. + +## Favorites Schema + +::: AniLinkPy.apis.anilist.schemas.mutation.favorites_schema \ No newline at end of file diff --git a/docs/AniLink/AniList/Queries/schemas.md b/docs/AniLink/AniList/Queries/schemas.md index b37d20d..9f37747 100644 --- a/docs/AniLink/AniList/Queries/schemas.md +++ b/docs/AniLink/AniList/Queries/schemas.md @@ -2,6 +2,66 @@ This is the documentation for the Query schemas. -## UserSchema +## Airing Schedule Schema + +::: AniLinkPy.apis.anilist.schemas.query.airing_schedule_schema + +## Character Schema + +::: AniLinkPy.apis.anilist.schemas.query.character_schema + +## Media List Collection Schema + +::: AniLinkPy.apis.anilist.schemas.query.media_list_collection_schema + +## Media List Schema + +::: AniLinkPy.apis.anilist.schemas.query.media_list_schema + +## Media Schema + +::: AniLinkPy.apis.anilist.schemas.query.media_schema + +## Media Trend Schema + +::: AniLinkPy.apis.anilist.schemas.query.media_trend_schema + +## Media With Relations Schema + +::: AniLinkPy.apis.anilist.schemas.query.media_with_relations_schema + +## Notification Schema + +::: AniLinkPy.apis.anilist.schemas.query.notification_schema + +## Recommendation Schema + +::: AniLinkPy.apis.anilist.schemas.query.recommendation_schema + +## Review Schema + +::: AniLinkPy.apis.anilist.schemas.query.review_schema + +## Site Statistics Schema + +::: AniLinkPy.apis.anilist.schemas.query.site_statistics_schema + +## Staff Schema + +::: AniLinkPy.apis.anilist.schemas.query.staff_schema + +## Studio Schema + +::: AniLinkPy.apis.anilist.schemas.query.studio_schema + +## Thread Comment Schema + +::: AniLinkPy.apis.anilist.schemas.query.thread_comment_schema + +## Thread Schema + +::: AniLinkPy.apis.anilist.schemas.query.thread_schema + +## User Schema ::: AniLinkPy.apis.anilist.schemas.query.user_schema \ No newline at end of file diff --git a/docs/AniLink/AniList/schemas.md b/docs/AniLink/AniList/schemas.md index 182d751..ca8cef0 100644 --- a/docs/AniLink/AniList/schemas.md +++ b/docs/AniLink/AniList/schemas.md @@ -2,18 +2,62 @@ This is the documentation for the basic schemas. +## Activity Schema + +::: AniLinkPy.apis.anilist.schemas.activity_schema + +## Basic Schema's + +::: AniLinkPy.apis.anilist.schemas.basic_schema + ## CoverImage Schema ::: AniLinkPy.apis.anilist.schemas.cover_image_schema +## Distribution Schema + +::: AniLinkPy.apis.anilist.schemas.distribution_schema + +## ExternalLink Schema + +::: AniLinkPy.apis.anilist.schemas.external_link_schema + +## FuzzyDate Schema + +::: AniLinkPy.apis.anilist.schemas.fuzzy_date_schema + ## Image Schema ::: AniLinkPy.apis.anilist.schemas.image_schema +## MediaListEntry Schema + +::: AniLinkPy.apis.anilist.schemas.media_list_entry_schema + ## Name Schema ::: AniLinkPy.apis.anilist.schemas.name_schema +## NextAiringEpisode Schema + +::: AniLinkPy.apis.anilist.schemas.next_airing_episode_schema + +## Notification Schema + +::: AniLinkPy.apis.anilist.schemas.notification_schema + +## Ranking Schema + +::: AniLinkPy.apis.anilist.schemas.ranking_schema + +## SiteTrend Schema + +::: AniLinkPy.apis.anilist.schemas.site_trend_schema + +## StreamingEpisode Schema + +::: AniLinkPy.apis.anilist.schemas.streaming_episode_schema + ## Tag Schema ::: AniLinkPy.apis.anilist.schemas.tag_schema @@ -22,6 +66,10 @@ This is the documentation for the basic schemas. ::: AniLinkPy.apis.anilist.schemas.title_schema -## User Stats Schema +## Trailer Schema + +::: AniLinkPy.apis.anilist.schemas.trailer_schema + +## UserStats Schema ::: AniLinkPy.apis.anilist.schemas.user_stats_schema \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index e7ab527..d233da0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -10,7 +10,7 @@ AniLink is a Python library for interacting with the AniList API. It provides me Install AniLink with `poetry`, `hatch`, `pip` or `pipx` and start using it in minutes - [:octicons-arrow-right-24: Installation](installation) + [:octicons-arrow-right-24: Installation](installation.md) @@ -22,7 +22,7 @@ AniLink is a Python library for interacting with the AniList API. It provides me Use AniLink to query and mutate data from the AniList API - [:octicons-arrow-right-24: AniList API](AniListAPI) + [:octicons-arrow-right-24: AniList API](AniListAPI.md) - :simple-myanimelist:{ .lg .middle } __MyAnimeList__ @@ -38,7 +38,7 @@ AniLink is a Python library for interacting with the AniList API. It provides me Coming soon: Use AniLink to query and mutate data from the Kitsu API - [:octicons-arrow-right-24: Kitsu API](KitsuAPI) + [:octicons-arrow-right-24: Kitsu API](KitsuAPI.md) diff --git a/mkdocs.yml b/mkdocs.yml index ced93ff..a608127 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -90,6 +90,7 @@ nav: - User: AniLink/AniList/Queries/user.md - Mutation: - AniLink/AniList/Mutations/index.md + - Schemas: AniLink/AniList/Mutations/schemas.md - Mutations: - Update User: AniLink/AniList/Mutations/updateUser.md - Custom: AniLink/AniList/custom.md diff --git a/poetry.lock b/poetry.lock index 6f417cd..25ecd79 100644 --- a/poetry.lock +++ b/poetry.lock @@ -579,13 +579,13 @@ i18n = ["Babel (>=2.7)"] [[package]] name = "keyring" -version = "25.2.0" +version = "25.2.1" description = "Store and access your passwords safely." optional = false python-versions = ">=3.8" files = [ - {file = "keyring-25.2.0-py3-none-any.whl", hash = "sha256:19f17d40335444aab84b19a0d16a77ec0758a9c384e3446ae2ed8bd6d53b67a5"}, - {file = "keyring-25.2.0.tar.gz", hash = "sha256:7045f367268ce42dba44745050164b431e46f6e92f99ef2937dfadaef368d8cf"}, + {file = "keyring-25.2.1-py3-none-any.whl", hash = "sha256:2458681cdefc0dbc0b7eb6cf75d0b98e59f9ad9b2d4edd319d18f68bdca95e50"}, + {file = "keyring-25.2.1.tar.gz", hash = "sha256:daaffd42dbda25ddafb1ad5fec4024e5bbcfe424597ca1ca452b299861e49f1b"}, ] [package.dependencies] @@ -1165,13 +1165,13 @@ windows-terminal = ["colorama (>=0.4.6)"] [[package]] name = "pylint" -version = "3.1.0" +version = "3.1.1" description = "python code static checker" optional = false python-versions = ">=3.8.0" files = [ - {file = "pylint-3.1.0-py3-none-any.whl", hash = "sha256:507a5b60953874766d8a366e8e8c7af63e058b26345cfcb5f91f89d987fd6b74"}, - {file = "pylint-3.1.0.tar.gz", hash = "sha256:6a69beb4a6f63debebaab0a3477ecd0f559aa726af4954fc948c51f7a2549e23"}, + {file = "pylint-3.1.1-py3-none-any.whl", hash = "sha256:862eddf25dab42704c5f06d3688b8bc19ef4c99ad8a836b6ff260a3b2fbafee1"}, + {file = "pylint-3.1.1.tar.gz", hash = "sha256:c7c2652bf8099c7fb7a63bc6af5c5f8f7b9d7b392fa1d320cb020e222aff28c2"}, ] [package.dependencies] @@ -1677,4 +1677,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "a3bededc51e5fbc3a7348a3ff404dfc0dee35ac27406df97481256809e52f8d2" +content-hash = "1b3b300486a334b3e86d7134b409fd60da9623662857d92c29adeb9fe87015b7" diff --git a/pyproject.toml b/pyproject.toml index 1120c4f..80e83b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ python-dotenv = "*" twine = "^5.0.0" isort = "^5.13.2" black = "^24.4.2" -pylint = "^3.1.0" +pylint = "^3.1.1" mypy = "^1.10.0" flake8 = "^7.0.0" mkdocs = "^1.6.0" @@ -63,4 +63,4 @@ max-line-length = 120 [tool.pylint] max-line-length = 120 -disable = "too-few-public-methods,missing-module-docstring,invalid-name" \ No newline at end of file +disable = "too-few-public-methods,missing-module-docstring,invalid-name,R0801" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 2e6ad53..3e4e038 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,4 +7,4 @@ max-line-length = 120 [pylint] max-line-length = 120 -disable = "too-few-public-methods,missing-module-docstring,invalid-name" \ No newline at end of file +disable = "too-few-public-methods,missing-module-docstring,invalid-name,R0801" \ No newline at end of file diff --git a/tests/test.py b/tests/test.py index ec738e0..3324275 100644 --- a/tests/test.py +++ b/tests/test.py @@ -50,6 +50,12 @@ def test_user(self): print(response) self.assertIsNotNone(response) + def test_media(self): + variables = {"id": 1} + response = handle_rate_limit(lambda: self.anilink.anilist.query.media(variables)) + print(response) + self.assertIsNotNone(response) + if __name__ == "__main__": unittest.main()