diff --git a/src/AnimeClient/API/Kitsu/Model.php b/src/AnimeClient/API/Kitsu/Model.php index b894bf0a..76fdce86 100644 --- a/src/AnimeClient/API/Kitsu/Model.php +++ b/src/AnimeClient/API/Kitsu/Model.php @@ -390,27 +390,18 @@ final class Model { private function getListCount(string $type, string $status = ''): int { - $options = [ - 'query' => [ - 'filter' => [ - 'user_id' => $this->getUserId(), - 'kind' => $type, - ], - 'page' => [ - 'limit' => 1 - ], - 'sort' => '-updated_at' - ] + $args = [ + 'type' => strtoupper($type), + 'slug' => $this->getUsername() ]; - - if ( ! empty($status)) + if ($status !== '') { - $options['query']['filter']['status'] = $status; + $args['status'] = strtoupper($status); } - $response = $this->requestBuilder->getRequest('library-entries', $options); + $res = $this->requestBuilder->runQuery('GetLibraryCount', $args); - return $response['meta']['count']; + return $res['data']['findProfileBySlug']['library']['all']['totalCount']; } /** diff --git a/src/AnimeClient/API/Kitsu/Queries/GetLibraryAll.graphql b/src/AnimeClient/API/Kitsu/Queries/GetLibraryAll.graphql new file mode 100644 index 00000000..42507336 --- /dev/null +++ b/src/AnimeClient/API/Kitsu/Queries/GetLibraryAll.graphql @@ -0,0 +1,86 @@ +query ($slug: String!, $type: media_type!, $status: [LibraryEntryStatus!]) { + findProfileBySlug(slug: $slug) { + library { + all(mediaType: $type, status: $status) { +# pageInfo { +# endCursor +# hasNextPage +# hasPreviousPage +# startCursor +# } + totalCount + nodes { + id + notes + nsfw + private + progress + progressedAt + rating + reconsumeCount + reconsuming + status + media { + id + ageRating + ageRatingGuide + categories { + nodes { + title + } + } + mappings { + nodes { + externalId + externalSite + } + } + posterImage { + original { + height + name + url + width + } + views { + height + name + url + width + } + } + sfw + slug + status + type + titles { + canonical + localized + alternatives + } + ...on Anime { + episodeCount + streamingLinks { + nodes { + dubs + subs + regions + streamer { + id + siteName + } + url + } + } + subtype + } + ...on Manga { + chapterCount + subtype + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/AnimeClient/API/Kitsu/Queries/GetLibraryCount.graphql b/src/AnimeClient/API/Kitsu/Queries/GetLibraryCount.graphql new file mode 100644 index 00000000..e3c6ceaa --- /dev/null +++ b/src/AnimeClient/API/Kitsu/Queries/GetLibraryCount.graphql @@ -0,0 +1,9 @@ +query ($slug: String!, $type: media_type!, $status: [LibraryEntryStatus!]) { + findProfileBySlug(slug: $slug) { + library { + all(mediaType: $type, status: $status) { + totalCount + } + } + } +} \ No newline at end of file