ani-client 1.8.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.d.mts +43 -5
- package/dist/index.d.ts +43 -5
- package/dist/index.js +75 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -8
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -699,11 +699,19 @@ interface Media {
|
|
|
699
699
|
siteUrl: string | null;
|
|
700
700
|
}
|
|
701
701
|
interface SearchMediaOptions {
|
|
702
|
+
/** Search Term */
|
|
702
703
|
query?: string;
|
|
704
|
+
/** Filter by country code (e.g., "JP", "KR") */
|
|
705
|
+
countryOfOrigin?: string;
|
|
706
|
+
/** Filter by Anime or Manga */
|
|
703
707
|
type?: MediaType;
|
|
704
|
-
format
|
|
708
|
+
/** Filter by format (For multiple formats: [MediaFormat.TV]) */
|
|
709
|
+
format?: MediaFormat | MediaFormat[];
|
|
710
|
+
/** Filter by status of Media */
|
|
705
711
|
status?: MediaStatus;
|
|
712
|
+
/** Filter by Season (Winter, Spring, Summer, Fall) */
|
|
706
713
|
season?: MediaSeason;
|
|
714
|
+
/** Filter by Year */
|
|
707
715
|
seasonYear?: number;
|
|
708
716
|
/** Single genre filter (kept for backward compat) */
|
|
709
717
|
genre?: string;
|
|
@@ -717,9 +725,23 @@ interface SearchMediaOptions {
|
|
|
717
725
|
genresExclude?: string[];
|
|
718
726
|
/** Exclude media with any of these tags */
|
|
719
727
|
tagsExclude?: string[];
|
|
728
|
+
/** Include or Exclude explicit content (default: false) */
|
|
720
729
|
isAdult?: boolean;
|
|
730
|
+
/** Sort order */
|
|
721
731
|
sort?: MediaSort[];
|
|
732
|
+
/** Page number */
|
|
722
733
|
page?: number;
|
|
734
|
+
/** Results per page (max 50) */
|
|
735
|
+
perPage?: number;
|
|
736
|
+
}
|
|
737
|
+
interface GeneralMediaQueryOptions {
|
|
738
|
+
/** Filter by Anime or Manga */
|
|
739
|
+
type?: MediaType;
|
|
740
|
+
/** Include or Exclude explicit content (default: false) */
|
|
741
|
+
isAdult?: boolean;
|
|
742
|
+
/** Page number */
|
|
743
|
+
page?: number;
|
|
744
|
+
/** Results per page (max 50) */
|
|
723
745
|
perPage?: number;
|
|
724
746
|
}
|
|
725
747
|
interface GetAiringOptions {
|
|
@@ -727,12 +749,18 @@ interface GetAiringOptions {
|
|
|
727
749
|
airingAtGreater?: number;
|
|
728
750
|
/** Only show episodes that aired before this UNIX timestamp */
|
|
729
751
|
airingAtLesser?: number;
|
|
752
|
+
/** Include or Exclude explicit content (default: false) */
|
|
753
|
+
isAdult?: boolean;
|
|
730
754
|
/** Sort order (default: TIME_DESC) */
|
|
731
755
|
sort?: AiringSort[];
|
|
756
|
+
/** Page number */
|
|
732
757
|
page?: number;
|
|
758
|
+
/** Results per page (max 50) */
|
|
733
759
|
perPage?: number;
|
|
734
760
|
}
|
|
735
761
|
interface GetRecentChaptersOptions {
|
|
762
|
+
/** Include or Exclude explicit content (default: false) */
|
|
763
|
+
isAdult?: boolean;
|
|
736
764
|
/** Page number (default: 1) */
|
|
737
765
|
page?: number;
|
|
738
766
|
/** Results per page (default: 20, max 50) */
|
|
@@ -741,9 +769,13 @@ interface GetRecentChaptersOptions {
|
|
|
741
769
|
interface GetPlanningOptions {
|
|
742
770
|
/** Filter by ANIME or MANGA (returns both if omitted) */
|
|
743
771
|
type?: MediaType;
|
|
772
|
+
/** Include or Exclude explicit content (default: false) */
|
|
773
|
+
isAdult?: boolean;
|
|
744
774
|
/** Sort order (default: POPULARITY_DESC) */
|
|
745
775
|
sort?: MediaSort[];
|
|
776
|
+
/** Page number */
|
|
746
777
|
page?: number;
|
|
778
|
+
/** Results per page (max 50) */
|
|
747
779
|
perPage?: number;
|
|
748
780
|
}
|
|
749
781
|
declare enum RecommendationSort {
|
|
@@ -768,7 +800,9 @@ interface GetRecommendationsOptions {
|
|
|
768
800
|
mediaId: number;
|
|
769
801
|
/** Sort order (default: RATING_DESC) */
|
|
770
802
|
sort?: RecommendationSort[];
|
|
803
|
+
/** Page number */
|
|
771
804
|
page?: number;
|
|
805
|
+
/** Results per page (max 50) */
|
|
772
806
|
perPage?: number;
|
|
773
807
|
}
|
|
774
808
|
interface GetSeasonOptions {
|
|
@@ -778,9 +812,13 @@ interface GetSeasonOptions {
|
|
|
778
812
|
seasonYear: number;
|
|
779
813
|
/** Filter by ANIME or MANGA (defaults to ANIME) */
|
|
780
814
|
type?: MediaType;
|
|
815
|
+
/** Allow or disallow explicit content (defaults to False) */
|
|
816
|
+
isAdult?: boolean;
|
|
781
817
|
/** Sort order (default: POPULARITY_DESC) */
|
|
782
818
|
sort?: MediaSort[];
|
|
819
|
+
/** Page number */
|
|
783
820
|
page?: number;
|
|
821
|
+
/** Results per page (max 50) */
|
|
784
822
|
perPage?: number;
|
|
785
823
|
}
|
|
786
824
|
/**
|
|
@@ -1168,11 +1206,11 @@ declare class AniListClient {
|
|
|
1168
1206
|
*/
|
|
1169
1207
|
searchMedia(options?: SearchMediaOptions): Promise<PagedResult<Media>>;
|
|
1170
1208
|
/** Get currently trending anime or manga. */
|
|
1171
|
-
getTrending(
|
|
1209
|
+
getTrending(options?: GeneralMediaQueryOptions): Promise<PagedResult<Media>>;
|
|
1172
1210
|
/** Get the most popular anime or manga. */
|
|
1173
|
-
getPopular(
|
|
1211
|
+
getPopular(options?: GeneralMediaQueryOptions): Promise<PagedResult<Media>>;
|
|
1174
1212
|
/** Get the highest-rated anime or manga. */
|
|
1175
|
-
getTopRated(
|
|
1213
|
+
getTopRated(options?: GeneralMediaQueryOptions): Promise<PagedResult<Media>>;
|
|
1176
1214
|
/** Get recently aired anime episodes. */
|
|
1177
1215
|
getAiredEpisodes(options?: GetAiringOptions): Promise<PagedResult<AiringSchedule>>;
|
|
1178
1216
|
/**
|
|
@@ -1310,7 +1348,7 @@ declare class AniListError extends Error {
|
|
|
1310
1348
|
/**
|
|
1311
1349
|
* Rate limiter with automatic retry for AniList API.
|
|
1312
1350
|
*
|
|
1313
|
-
* AniList allows
|
|
1351
|
+
* AniList allows 30 requests per minute.
|
|
1314
1352
|
* When a 429 (Too Many Requests) is received, the client
|
|
1315
1353
|
* waits for the Retry-After header and retries automatically.
|
|
1316
1354
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -699,11 +699,19 @@ interface Media {
|
|
|
699
699
|
siteUrl: string | null;
|
|
700
700
|
}
|
|
701
701
|
interface SearchMediaOptions {
|
|
702
|
+
/** Search Term */
|
|
702
703
|
query?: string;
|
|
704
|
+
/** Filter by country code (e.g., "JP", "KR") */
|
|
705
|
+
countryOfOrigin?: string;
|
|
706
|
+
/** Filter by Anime or Manga */
|
|
703
707
|
type?: MediaType;
|
|
704
|
-
format
|
|
708
|
+
/** Filter by format (For multiple formats: [MediaFormat.TV]) */
|
|
709
|
+
format?: MediaFormat | MediaFormat[];
|
|
710
|
+
/** Filter by status of Media */
|
|
705
711
|
status?: MediaStatus;
|
|
712
|
+
/** Filter by Season (Winter, Spring, Summer, Fall) */
|
|
706
713
|
season?: MediaSeason;
|
|
714
|
+
/** Filter by Year */
|
|
707
715
|
seasonYear?: number;
|
|
708
716
|
/** Single genre filter (kept for backward compat) */
|
|
709
717
|
genre?: string;
|
|
@@ -717,9 +725,23 @@ interface SearchMediaOptions {
|
|
|
717
725
|
genresExclude?: string[];
|
|
718
726
|
/** Exclude media with any of these tags */
|
|
719
727
|
tagsExclude?: string[];
|
|
728
|
+
/** Include or Exclude explicit content (default: false) */
|
|
720
729
|
isAdult?: boolean;
|
|
730
|
+
/** Sort order */
|
|
721
731
|
sort?: MediaSort[];
|
|
732
|
+
/** Page number */
|
|
722
733
|
page?: number;
|
|
734
|
+
/** Results per page (max 50) */
|
|
735
|
+
perPage?: number;
|
|
736
|
+
}
|
|
737
|
+
interface GeneralMediaQueryOptions {
|
|
738
|
+
/** Filter by Anime or Manga */
|
|
739
|
+
type?: MediaType;
|
|
740
|
+
/** Include or Exclude explicit content (default: false) */
|
|
741
|
+
isAdult?: boolean;
|
|
742
|
+
/** Page number */
|
|
743
|
+
page?: number;
|
|
744
|
+
/** Results per page (max 50) */
|
|
723
745
|
perPage?: number;
|
|
724
746
|
}
|
|
725
747
|
interface GetAiringOptions {
|
|
@@ -727,12 +749,18 @@ interface GetAiringOptions {
|
|
|
727
749
|
airingAtGreater?: number;
|
|
728
750
|
/** Only show episodes that aired before this UNIX timestamp */
|
|
729
751
|
airingAtLesser?: number;
|
|
752
|
+
/** Include or Exclude explicit content (default: false) */
|
|
753
|
+
isAdult?: boolean;
|
|
730
754
|
/** Sort order (default: TIME_DESC) */
|
|
731
755
|
sort?: AiringSort[];
|
|
756
|
+
/** Page number */
|
|
732
757
|
page?: number;
|
|
758
|
+
/** Results per page (max 50) */
|
|
733
759
|
perPage?: number;
|
|
734
760
|
}
|
|
735
761
|
interface GetRecentChaptersOptions {
|
|
762
|
+
/** Include or Exclude explicit content (default: false) */
|
|
763
|
+
isAdult?: boolean;
|
|
736
764
|
/** Page number (default: 1) */
|
|
737
765
|
page?: number;
|
|
738
766
|
/** Results per page (default: 20, max 50) */
|
|
@@ -741,9 +769,13 @@ interface GetRecentChaptersOptions {
|
|
|
741
769
|
interface GetPlanningOptions {
|
|
742
770
|
/** Filter by ANIME or MANGA (returns both if omitted) */
|
|
743
771
|
type?: MediaType;
|
|
772
|
+
/** Include or Exclude explicit content (default: false) */
|
|
773
|
+
isAdult?: boolean;
|
|
744
774
|
/** Sort order (default: POPULARITY_DESC) */
|
|
745
775
|
sort?: MediaSort[];
|
|
776
|
+
/** Page number */
|
|
746
777
|
page?: number;
|
|
778
|
+
/** Results per page (max 50) */
|
|
747
779
|
perPage?: number;
|
|
748
780
|
}
|
|
749
781
|
declare enum RecommendationSort {
|
|
@@ -768,7 +800,9 @@ interface GetRecommendationsOptions {
|
|
|
768
800
|
mediaId: number;
|
|
769
801
|
/** Sort order (default: RATING_DESC) */
|
|
770
802
|
sort?: RecommendationSort[];
|
|
803
|
+
/** Page number */
|
|
771
804
|
page?: number;
|
|
805
|
+
/** Results per page (max 50) */
|
|
772
806
|
perPage?: number;
|
|
773
807
|
}
|
|
774
808
|
interface GetSeasonOptions {
|
|
@@ -778,9 +812,13 @@ interface GetSeasonOptions {
|
|
|
778
812
|
seasonYear: number;
|
|
779
813
|
/** Filter by ANIME or MANGA (defaults to ANIME) */
|
|
780
814
|
type?: MediaType;
|
|
815
|
+
/** Allow or disallow explicit content (defaults to False) */
|
|
816
|
+
isAdult?: boolean;
|
|
781
817
|
/** Sort order (default: POPULARITY_DESC) */
|
|
782
818
|
sort?: MediaSort[];
|
|
819
|
+
/** Page number */
|
|
783
820
|
page?: number;
|
|
821
|
+
/** Results per page (max 50) */
|
|
784
822
|
perPage?: number;
|
|
785
823
|
}
|
|
786
824
|
/**
|
|
@@ -1168,11 +1206,11 @@ declare class AniListClient {
|
|
|
1168
1206
|
*/
|
|
1169
1207
|
searchMedia(options?: SearchMediaOptions): Promise<PagedResult<Media>>;
|
|
1170
1208
|
/** Get currently trending anime or manga. */
|
|
1171
|
-
getTrending(
|
|
1209
|
+
getTrending(options?: GeneralMediaQueryOptions): Promise<PagedResult<Media>>;
|
|
1172
1210
|
/** Get the most popular anime or manga. */
|
|
1173
|
-
getPopular(
|
|
1211
|
+
getPopular(options?: GeneralMediaQueryOptions): Promise<PagedResult<Media>>;
|
|
1174
1212
|
/** Get the highest-rated anime or manga. */
|
|
1175
|
-
getTopRated(
|
|
1213
|
+
getTopRated(options?: GeneralMediaQueryOptions): Promise<PagedResult<Media>>;
|
|
1176
1214
|
/** Get recently aired anime episodes. */
|
|
1177
1215
|
getAiredEpisodes(options?: GetAiringOptions): Promise<PagedResult<AiringSchedule>>;
|
|
1178
1216
|
/**
|
|
@@ -1310,7 +1348,7 @@ declare class AniListError extends Error {
|
|
|
1310
1348
|
/**
|
|
1311
1349
|
* Rate limiter with automatic retry for AniList API.
|
|
1312
1350
|
*
|
|
1313
|
-
* AniList allows
|
|
1351
|
+
* AniList allows 30 requests per minute.
|
|
1314
1352
|
* When a 429 (Too Many Requests) is received, the client
|
|
1315
1353
|
* waits for the Retry-After header and retries automatically.
|
|
1316
1354
|
*/
|
package/dist/index.js
CHANGED
|
@@ -436,7 +436,17 @@ var RELATIONS_FIELDS = `
|
|
|
436
436
|
type
|
|
437
437
|
format
|
|
438
438
|
status
|
|
439
|
-
|
|
439
|
+
startDate { year month day }
|
|
440
|
+
endDate { year month day }
|
|
441
|
+
season
|
|
442
|
+
seasonYear
|
|
443
|
+
episodes
|
|
444
|
+
chapters
|
|
445
|
+
volumes
|
|
446
|
+
coverImage { extraLarge large medium color }
|
|
447
|
+
genres
|
|
448
|
+
averageScore
|
|
449
|
+
studios { nodes { id name isAnimationStudio siteUrl } }
|
|
440
450
|
siteUrl
|
|
441
451
|
}
|
|
442
452
|
}
|
|
@@ -713,8 +723,10 @@ query ($id: Int!) {
|
|
|
713
723
|
var QUERY_MEDIA_SEARCH = `
|
|
714
724
|
query (
|
|
715
725
|
$search: String,
|
|
726
|
+
$countryOfOrigin: CountryCode,
|
|
716
727
|
$type: MediaType,
|
|
717
728
|
$format: MediaFormat,
|
|
729
|
+
$format_in: [MediaFormat],
|
|
718
730
|
$status: MediaStatus,
|
|
719
731
|
$season: MediaSeason,
|
|
720
732
|
$seasonYear: Int,
|
|
@@ -733,8 +745,10 @@ query (
|
|
|
733
745
|
pageInfo { total perPage currentPage lastPage hasNextPage }
|
|
734
746
|
media(
|
|
735
747
|
search: $search,
|
|
748
|
+
countryOfOrigin: $countryOfOrigin,
|
|
736
749
|
type: $type,
|
|
737
750
|
format: $format,
|
|
751
|
+
format_in: $format_in,
|
|
738
752
|
status: $status,
|
|
739
753
|
season: $season,
|
|
740
754
|
seasonYear: $seasonYear,
|
|
@@ -752,16 +766,16 @@ query (
|
|
|
752
766
|
}
|
|
753
767
|
}`;
|
|
754
768
|
var QUERY_TRENDING = `
|
|
755
|
-
query ($type: MediaType, $page: Int, $perPage: Int) {
|
|
769
|
+
query ($type: MediaType, $isAdult: Boolean, $page: Int, $perPage: Int) {
|
|
756
770
|
Page(page: $page, perPage: $perPage) {
|
|
757
771
|
pageInfo { total perPage currentPage lastPage hasNextPage }
|
|
758
|
-
media(type: $type, sort: TRENDING_DESC) {
|
|
772
|
+
media(type: $type, isAdult: $isAdult, sort: TRENDING_DESC) {
|
|
759
773
|
${MEDIA_FIELDS_BASE}
|
|
760
774
|
}
|
|
761
775
|
}
|
|
762
776
|
}`;
|
|
763
777
|
var QUERY_AIRING_SCHEDULE = `
|
|
764
|
-
query ($airingAt_greater: Int, $airingAt_lesser: Int, $sort: [AiringSort], $page: Int, $perPage: Int) {
|
|
778
|
+
query ($airingAt_greater: Int, $airingAt_lesser: Int, $isAdult: Boolean, $sort: [AiringSort], $page: Int, $perPage: Int) {
|
|
765
779
|
Page(page: $page, perPage: $perPage) {
|
|
766
780
|
pageInfo { total perPage currentPage lastPage hasNextPage }
|
|
767
781
|
airingSchedules(airingAt_greater: $airingAt_greater, airingAt_lesser: $airingAt_lesser, sort: $sort) {
|
|
@@ -770,35 +784,49 @@ query ($airingAt_greater: Int, $airingAt_lesser: Int, $sort: [AiringSort], $page
|
|
|
770
784
|
timeUntilAiring
|
|
771
785
|
episode
|
|
772
786
|
mediaId
|
|
773
|
-
media {
|
|
787
|
+
media(isAdult: $isAdult) {
|
|
774
788
|
${MEDIA_FIELDS_BASE}
|
|
775
789
|
}
|
|
776
790
|
}
|
|
777
791
|
}
|
|
778
792
|
}`;
|
|
779
793
|
var QUERY_RECENT_CHAPTERS = `
|
|
780
|
-
query ($page: Int, $perPage: Int) {
|
|
794
|
+
query ($isAdult: Boolean $page: Int, $perPage: Int) {
|
|
781
795
|
Page(page: $page, perPage: $perPage) {
|
|
782
796
|
pageInfo { total perPage currentPage lastPage hasNextPage }
|
|
783
|
-
media(type: MANGA, status: RELEASING, sort: UPDATED_AT_DESC) {
|
|
797
|
+
media(type: MANGA, isAdult: $isAdult status: RELEASING, sort: UPDATED_AT_DESC) {
|
|
784
798
|
${MEDIA_FIELDS_BASE}
|
|
785
799
|
}
|
|
786
800
|
}
|
|
787
801
|
}`;
|
|
788
802
|
var QUERY_PLANNING = `
|
|
789
|
-
query ($type: MediaType, $sort: [MediaSort], $page: Int, $perPage: Int) {
|
|
803
|
+
query ($type: MediaType, $isAdult: Boolean, $sort: [MediaSort], $page: Int, $perPage: Int) {
|
|
790
804
|
Page(page: $page, perPage: $perPage) {
|
|
791
805
|
pageInfo { total perPage currentPage lastPage hasNextPage }
|
|
792
|
-
media(type: $type, status: NOT_YET_RELEASED, sort: $sort) {
|
|
806
|
+
media(type: $type, isAdult: $isAdult, status: NOT_YET_RELEASED, sort: $sort) {
|
|
793
807
|
${MEDIA_FIELDS_BASE}
|
|
794
808
|
}
|
|
795
809
|
}
|
|
796
810
|
}`;
|
|
797
811
|
var QUERY_MEDIA_BY_SEASON = `
|
|
798
|
-
query (
|
|
812
|
+
query (
|
|
813
|
+
$season: MediaSeason!,
|
|
814
|
+
$seasonYear: Int!,
|
|
815
|
+
$type: MediaType,
|
|
816
|
+
$isAdult: Boolean,
|
|
817
|
+
$sort: [MediaSort],
|
|
818
|
+
$page: Int,
|
|
819
|
+
$perPage: Int
|
|
820
|
+
) {
|
|
799
821
|
Page(page: $page, perPage: $perPage) {
|
|
800
822
|
pageInfo { total perPage currentPage lastPage hasNextPage }
|
|
801
|
-
media(
|
|
823
|
+
media(
|
|
824
|
+
season: $season,
|
|
825
|
+
seasonYear: $seasonYear,
|
|
826
|
+
type: $type,
|
|
827
|
+
isAdult: $isAdult,
|
|
828
|
+
sort: $sort
|
|
829
|
+
) {
|
|
802
830
|
${MEDIA_FIELDS_BASE}
|
|
803
831
|
}
|
|
804
832
|
}
|
|
@@ -1197,7 +1225,7 @@ var RateLimiter = class {
|
|
|
1197
1225
|
/** @internal — active sleep timers for cleanup */
|
|
1198
1226
|
activeTimers = /* @__PURE__ */ new Set();
|
|
1199
1227
|
constructor(options = {}) {
|
|
1200
|
-
this.maxRequests = options.maxRequests ??
|
|
1228
|
+
this.maxRequests = options.maxRequests ?? 25;
|
|
1201
1229
|
this.windowMs = options.windowMs ?? 6e4;
|
|
1202
1230
|
this.maxRetries = options.maxRetries ?? 3;
|
|
1203
1231
|
this.retryDelayMs = options.retryDelayMs ?? 2e3;
|
|
@@ -1600,12 +1628,24 @@ async function getMediaByMalId(client, malId, type) {
|
|
|
1600
1628
|
return data.Media;
|
|
1601
1629
|
}
|
|
1602
1630
|
async function searchMedia(client, options = {}) {
|
|
1603
|
-
const {
|
|
1631
|
+
const {
|
|
1632
|
+
query: search,
|
|
1633
|
+
page = 1,
|
|
1634
|
+
perPage = 20,
|
|
1635
|
+
genres,
|
|
1636
|
+
tags,
|
|
1637
|
+
genresExclude,
|
|
1638
|
+
tagsExclude,
|
|
1639
|
+
format,
|
|
1640
|
+
...filters
|
|
1641
|
+
} = options;
|
|
1604
1642
|
return client.pagedRequest(
|
|
1605
1643
|
QUERY_MEDIA_SEARCH,
|
|
1606
1644
|
{
|
|
1607
1645
|
search,
|
|
1608
1646
|
...filters,
|
|
1647
|
+
format: Array.isArray(format) ? void 0 : format,
|
|
1648
|
+
format_in: Array.isArray(format) ? format : void 0,
|
|
1609
1649
|
genre_in: genres,
|
|
1610
1650
|
tag_in: tags,
|
|
1611
1651
|
genre_not_in: genresExclude,
|
|
@@ -1616,14 +1656,17 @@ async function searchMedia(client, options = {}) {
|
|
|
1616
1656
|
"media"
|
|
1617
1657
|
);
|
|
1618
1658
|
}
|
|
1619
|
-
async function getTrending(client,
|
|
1620
|
-
|
|
1659
|
+
async function getTrending(client, options) {
|
|
1660
|
+
const { type = "ANIME" /* ANIME */, isAdult = false, page = 1, perPage = 20 } = options;
|
|
1661
|
+
return client.pagedRequest(QUERY_TRENDING, { type, isAdult, page, perPage: clampPerPage(perPage) }, "media");
|
|
1621
1662
|
}
|
|
1622
|
-
async function getPopular(client,
|
|
1623
|
-
|
|
1663
|
+
async function getPopular(client, options) {
|
|
1664
|
+
const { type = "ANIME" /* ANIME */, isAdult = false, page = 1, perPage = 20 } = options;
|
|
1665
|
+
return searchMedia(client, { type, isAdult, sort: ["POPULARITY_DESC" /* POPULARITY_DESC */], page, perPage });
|
|
1624
1666
|
}
|
|
1625
|
-
async function getTopRated(client,
|
|
1626
|
-
|
|
1667
|
+
async function getTopRated(client, options) {
|
|
1668
|
+
const { type = "ANIME" /* ANIME */, isAdult = false, page = 1, perPage = 20 } = options;
|
|
1669
|
+
return searchMedia(client, { type, isAdult, sort: ["SCORE_DESC" /* SCORE_DESC */], page, perPage });
|
|
1627
1670
|
}
|
|
1628
1671
|
async function getAiredEpisodes(client, options = {}) {
|
|
1629
1672
|
const now = Math.floor(Date.now() / 1e3);
|
|
@@ -1632,6 +1675,7 @@ async function getAiredEpisodes(client, options = {}) {
|
|
|
1632
1675
|
{
|
|
1633
1676
|
airingAt_greater: options.airingAtGreater ?? now - 24 * 3600,
|
|
1634
1677
|
airingAt_lesser: options.airingAtLesser ?? now,
|
|
1678
|
+
isAdult: options.isAdult ?? false,
|
|
1635
1679
|
sort: options.sort,
|
|
1636
1680
|
page: options.page ?? 1,
|
|
1637
1681
|
perPage: clampPerPage(options.perPage ?? 20)
|
|
@@ -1643,6 +1687,7 @@ async function getRecentlyUpdatedManga(client, options = {}) {
|
|
|
1643
1687
|
return client.pagedRequest(
|
|
1644
1688
|
QUERY_RECENT_CHAPTERS,
|
|
1645
1689
|
{
|
|
1690
|
+
isAdult: options.isAdult ?? false,
|
|
1646
1691
|
page: options.page ?? 1,
|
|
1647
1692
|
perPage: clampPerPage(options.perPage ?? 20)
|
|
1648
1693
|
},
|
|
@@ -1654,6 +1699,7 @@ async function getPlanning(client, options = {}) {
|
|
|
1654
1699
|
QUERY_PLANNING,
|
|
1655
1700
|
{
|
|
1656
1701
|
type: options.type,
|
|
1702
|
+
isAdult: options.isAdult ?? false,
|
|
1657
1703
|
sort: options.sort ?? ["POPULARITY_DESC" /* POPULARITY_DESC */],
|
|
1658
1704
|
page: options.page ?? 1,
|
|
1659
1705
|
perPage: clampPerPage(options.perPage ?? 20)
|
|
@@ -1681,6 +1727,7 @@ async function getMediaBySeason(client, options) {
|
|
|
1681
1727
|
season: options.season,
|
|
1682
1728
|
seasonYear: options.seasonYear,
|
|
1683
1729
|
type: options.type,
|
|
1730
|
+
isAdult: options.isAdult ?? false,
|
|
1684
1731
|
sort: options.sort,
|
|
1685
1732
|
page: options.page ?? 1,
|
|
1686
1733
|
perPage: clampPerPage(options.perPage ?? 20)
|
|
@@ -1688,7 +1735,7 @@ async function getMediaBySeason(client, options) {
|
|
|
1688
1735
|
"media"
|
|
1689
1736
|
);
|
|
1690
1737
|
}
|
|
1691
|
-
async function getWeeklySchedule(client, date = /* @__PURE__ */ new Date()) {
|
|
1738
|
+
async function getWeeklySchedule(client, date = /* @__PURE__ */ new Date(), isAdult = false) {
|
|
1692
1739
|
const schedule = {
|
|
1693
1740
|
Monday: [],
|
|
1694
1741
|
Tuesday: [],
|
|
@@ -1710,6 +1757,7 @@ async function getWeeklySchedule(client, date = /* @__PURE__ */ new Date()) {
|
|
|
1710
1757
|
(page) => getAiredEpisodes(client, {
|
|
1711
1758
|
airingAtGreater: startTimestamp,
|
|
1712
1759
|
airingAtLesser: endTimestamp,
|
|
1760
|
+
isAdult,
|
|
1713
1761
|
page,
|
|
1714
1762
|
perPage: 50
|
|
1715
1763
|
}),
|
|
@@ -1855,7 +1903,7 @@ function mapFavorites(fav) {
|
|
|
1855
1903
|
|
|
1856
1904
|
// src/client/index.ts
|
|
1857
1905
|
var DEFAULT_API_URL = "https://graphql.anilist.co";
|
|
1858
|
-
var LIB_VERSION = "
|
|
1906
|
+
var LIB_VERSION = "2.0.0" ;
|
|
1859
1907
|
var AniListClient = class {
|
|
1860
1908
|
apiUrl;
|
|
1861
1909
|
headers;
|
|
@@ -2008,16 +2056,16 @@ var AniListClient = class {
|
|
|
2008
2056
|
return searchMedia(this, options);
|
|
2009
2057
|
}
|
|
2010
2058
|
/** Get currently trending anime or manga. */
|
|
2011
|
-
async getTrending(
|
|
2012
|
-
return getTrending(this,
|
|
2059
|
+
async getTrending(options = {}) {
|
|
2060
|
+
return getTrending(this, options);
|
|
2013
2061
|
}
|
|
2014
2062
|
/** Get the most popular anime or manga. */
|
|
2015
|
-
async getPopular(
|
|
2016
|
-
return getPopular(this,
|
|
2063
|
+
async getPopular(options = {}) {
|
|
2064
|
+
return getPopular(this, options);
|
|
2017
2065
|
}
|
|
2018
2066
|
/** Get the highest-rated anime or manga. */
|
|
2019
|
-
async getTopRated(
|
|
2020
|
-
return getTopRated(this,
|
|
2067
|
+
async getTopRated(options = {}) {
|
|
2068
|
+
return getTopRated(this, options);
|
|
2021
2069
|
}
|
|
2022
2070
|
/** Get recently aired anime episodes. */
|
|
2023
2071
|
async getAiredEpisodes(options = {}) {
|