@irfanshadikrishad/anilist 1.1.0-forbidden.0 → 1.1.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 CHANGED
@@ -229,4 +229,9 @@ Since you are creating your own API client for login no else else can get your c
229
229
 
230
230
  Want to contribute to the project? Check out complete guideline [here](CONTRIBUTING.md).
231
231
 
232
+ #### Donation
233
+
234
+ <img src='/assets/binance.jpg' alt='irfanshadikrishad_binance_pay' width='200px'><br>
235
+ Support the project if you find it useful to you.
236
+
232
237
  #### **_Thanks for visiting 💙_**
Binary file
@@ -19,8 +19,5 @@ declare class Auth {
19
19
  static Write(status: string): Promise<void>;
20
20
  static callAnimeImporter(): Promise<void>;
21
21
  static callMangaImporter(): Promise<void>;
22
- private static Like;
23
- private static LikeSpecificUser;
24
- static AutoLike(): Promise<void>;
25
22
  }
26
23
  export { Auth };
@@ -15,8 +15,8 @@ import os from "os";
15
15
  import path from "path";
16
16
  import { fetcher } from "./fetcher.js";
17
17
  import { AniList, MyAnimeList } from "./lists.js";
18
- import { deleteActivityMutation, likeActivityMutation, saveTextActivityMutation, } from "./mutations.js";
19
- import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, followingActivitiesQuery, globalActivitiesQuery, specificUserActivitiesQuery, userActivityQuery, userQuery, } from "./queries.js";
18
+ import { deleteActivityMutation, saveTextActivityMutation, } from "./mutations.js";
19
+ import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, userActivityQuery, } from "./queries.js";
20
20
  import { aniListEndpoint, getTitle, redirectUri } from "./workers.js";
21
21
  const home_dir = os.homedir();
22
22
  const save_path = path.join(home_dir, ".anilist_token");
@@ -625,158 +625,5 @@ Statistics (Manga):
625
625
  }
626
626
  });
627
627
  }
628
- static Like(type) {
629
- return __awaiter(this, void 0, void 0, function* () {
630
- var _a, _b, _c, _d;
631
- try {
632
- let page = 1;
633
- let hasMoreActivities = true;
634
- let activity = type === 0
635
- ? followingActivitiesQuery
636
- : type === 1
637
- ? globalActivitiesQuery
638
- : followingActivitiesQuery;
639
- while (hasMoreActivities) {
640
- const activities = yield fetcher(activity, {
641
- page,
642
- perPage: 50,
643
- });
644
- if (activities && ((_b = (_a = activities === null || activities === void 0 ? void 0 : activities.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.activities.length) > 0) {
645
- const activiti = (_d = (_c = activities === null || activities === void 0 ? void 0 : activities.data) === null || _c === void 0 ? void 0 : _c.Page) === null || _d === void 0 ? void 0 : _d.activities;
646
- for (let activ of activiti) {
647
- if (!activ.isLiked && activ.id) {
648
- try {
649
- const like = yield fetcher(likeActivityMutation, {
650
- activityId: activ.id,
651
- });
652
- // const ToggleLike = like?.data?.ToggleLike
653
- console.info(`[${activ.id}] liked ${activ.user.name}`);
654
- }
655
- catch (error) {
656
- console.error(`Activity possibly deleted.`);
657
- }
658
- }
659
- else {
660
- console.log(`[${activ === null || activ === void 0 ? void 0 : activ.id}] ${activ.user.name} already-liked`);
661
- }
662
- // avoiding rate-limit
663
- yield new Promise((resolve) => {
664
- setTimeout(resolve, 2000);
665
- });
666
- }
667
- page++;
668
- }
669
- else {
670
- // No more activities to like
671
- console.log(`\nProbably the end of activities.`);
672
- console.info(activities);
673
- hasMoreActivities = false;
674
- }
675
- }
676
- }
677
- catch (error) {
678
- console.error(`\nError from likeFollowing. ${error.message}`);
679
- }
680
- });
681
- }
682
- static LikeSpecificUser() {
683
- return __awaiter(this, void 0, void 0, function* () {
684
- var _a, _b, _c, _d, _e, _f;
685
- try {
686
- const { username } = yield inquirer.prompt([
687
- {
688
- type: "input",
689
- name: "username",
690
- message: "Username of the user:",
691
- },
692
- ]);
693
- const userDetails = yield fetcher(userQuery, { username: username });
694
- if (userDetails) {
695
- let page = 1;
696
- const perPage = 50;
697
- const userId = (_b = (_a = userDetails === null || userDetails === void 0 ? void 0 : userDetails.data) === null || _a === void 0 ? void 0 : _a.User) === null || _b === void 0 ? void 0 : _b.id;
698
- if (userId) {
699
- while (true) {
700
- const activities = yield fetcher(specificUserActivitiesQuery, {
701
- page,
702
- perPage,
703
- userId,
704
- });
705
- const activiti = (_d = (_c = activities === null || activities === void 0 ? void 0 : activities.data) === null || _c === void 0 ? void 0 : _c.Page) === null || _d === void 0 ? void 0 : _d.activities;
706
- // Break the loop if no more activities are found
707
- if (!activiti || activiti.length === 0) {
708
- console.log("No more activities found.");
709
- break;
710
- }
711
- for (let activ of activiti) {
712
- if (!activ.isLiked && activ.id) {
713
- try {
714
- const like = yield fetcher(likeActivityMutation, {
715
- activityId: activ.id,
716
- });
717
- console.info(`[${activ.id}] liked ${(_e = activ.user) === null || _e === void 0 ? void 0 : _e.name}`);
718
- }
719
- catch (error) {
720
- console.error(`Activity possibly deleted.`);
721
- }
722
- }
723
- else {
724
- console.log(`[${activ === null || activ === void 0 ? void 0 : activ.id}] ${(_f = activ.user) === null || _f === void 0 ? void 0 : _f.name} already liked`);
725
- }
726
- // Avoiding rate limit
727
- yield new Promise((resolve) => {
728
- setTimeout(resolve, 2000);
729
- });
730
- }
731
- // Go to the next page
732
- page += 1;
733
- }
734
- }
735
- }
736
- }
737
- catch (error) {
738
- console.error(`\nError from LikeSpecificUser. ${error.message}`);
739
- }
740
- });
741
- }
742
- static AutoLike() {
743
- return __awaiter(this, void 0, void 0, function* () {
744
- try {
745
- if (!(yield Auth.isLoggedIn())) {
746
- console.error(`\nPlease login to use this feature.`);
747
- return;
748
- }
749
- const { activityType } = yield inquirer.prompt([
750
- {
751
- type: "list",
752
- name: "activityType",
753
- message: "Select activity type:",
754
- choices: [
755
- { name: "Following", value: 1 },
756
- { name: "Global", value: 2 },
757
- { name: "Specific User", value: 3 },
758
- ],
759
- pageSize: 10,
760
- },
761
- ]);
762
- switch (activityType) {
763
- case 1:
764
- yield this.Like(0);
765
- break;
766
- case 2:
767
- yield this.Like(1);
768
- break;
769
- case 3:
770
- yield this.LikeSpecificUser();
771
- break;
772
- default:
773
- console.error(`\nInvalid choice. (${activityType})`);
774
- }
775
- }
776
- catch (error) {
777
- console.error(`\nError from autolike. ${error.message}`);
778
- }
779
- });
780
- }
781
628
  }
782
629
  export { Auth };
@@ -8,5 +8,5 @@
8
8
  * @param {object} variables - An object containing the variables for the query.
9
9
  * @returns {Promise<object|null>} The response from the API as a JSON object if successful; otherwise, null.
10
10
  */
11
- declare function fetcher(query: string, variables?: object): Promise<any | null>;
11
+ declare function fetcher(query: string, variables: object): Promise<object | null>;
12
12
  export { fetcher };
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import fetch from "node-fetch";
11
11
  import { Auth } from "./auth.js";
12
+ import { aniListEndpoint } from "./workers.js";
12
13
  /**
13
14
  * Sends a GraphQL request to the AniList API.
14
15
  *
@@ -21,34 +22,32 @@ import { Auth } from "./auth.js";
21
22
  */
22
23
  function fetcher(query, variables) {
23
24
  return __awaiter(this, void 0, void 0, function* () {
24
- const headers = {
25
- "content-type": "application/json",
26
- };
27
- if (yield Auth.isLoggedIn()) {
28
- headers["Authorization"] = `Bearer ${yield Auth.RetriveAccessToken()}`;
29
- }
30
- const response = yield fetch("https://graphql.anilist.co", {
31
- method: "POST",
32
- headers: headers,
33
- body: JSON.stringify({
34
- query,
35
- variables,
36
- }),
37
- });
38
- // Check if the response is successful
39
- if (response.status !== 200) {
40
- // If the status is 429, handle the rate limit
41
- if (response.status === 429) {
42
- console.warn("Rate limit hit. Waiting for 1 minute before retrying...");
43
- yield new Promise((resolve) => setTimeout(resolve, 60000)); // Wait for 1 minute
44
- return fetcher(query, variables); // Retry the request
25
+ var _a;
26
+ try {
27
+ const headers = {
28
+ "content-type": "application/json",
29
+ };
30
+ if (yield Auth.isLoggedIn()) {
31
+ headers["Authorization"] = `Bearer ${yield Auth.RetriveAccessToken()}`;
32
+ }
33
+ const request = yield fetch(aniListEndpoint, {
34
+ method: "POST",
35
+ headers: headers,
36
+ body: JSON.stringify({ query, variables }),
37
+ });
38
+ const response = yield request.json();
39
+ if (request.status === 200) {
40
+ return response;
45
41
  }
46
42
  else {
47
- throw new Error(`\nError fetching data: ${response.statusText}`);
43
+ console.error(`\n${request.status} ${(_a = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _a === void 0 ? void 0 : _a.message}.`);
44
+ return null;
48
45
  }
49
46
  }
50
- const data = yield response.json();
51
- return data;
47
+ catch (error) {
48
+ console.error(`\nSomething went wrong. ${error.message}.`);
49
+ return null;
50
+ }
52
51
  });
53
52
  }
54
53
  export { fetcher };
@@ -422,61 +422,78 @@ class AniList {
422
422
  return __awaiter(this, void 0, void 0, function* () {
423
423
  var _a, _b, _c, _d, _e;
424
424
  try {
425
- const request = yield fetch(aniListEndpoint, {
426
- method: "POST",
427
- headers: {
428
- "Content-Type": "application/json",
429
- },
430
- body: JSON.stringify({
431
- query: trendingQuery,
432
- variables: { page: 1, perPage: count },
433
- }),
434
- });
435
- const { data, errors } = yield request.json();
436
- if (request.status !== 200 || errors) {
437
- return console.log(`\nSomething went wrong. ${((_a = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _a === void 0 ? void 0 : _a.message) || "Unknown error"}`);
438
- }
439
- const media = (_b = data === null || data === void 0 ? void 0 : data.Page) === null || _b === void 0 ? void 0 : _b.media;
440
- if (!media || media.length === 0) {
441
- return console.log(`\nNo trending available at the moment.`);
442
- }
443
- const { selectedAnime } = yield inquirer.prompt([
444
- {
445
- type: "list",
446
- name: "selectedAnime",
447
- message: "Select anime to add to the list:",
448
- choices: media.map((anime, idx) => ({
449
- name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
450
- value: anime === null || anime === void 0 ? void 0 : anime.id,
451
- })),
452
- pageSize: 10,
453
- },
454
- ]);
455
- const { selectedListType } = yield inquirer.prompt([
456
- {
457
- type: "list",
458
- name: "selectedListType",
459
- message: "Select the list where you want to save this anime:",
460
- choices: [
461
- { name: "Planning", value: "PLANNING" },
462
- { name: "Watching", value: "CURRENT" },
463
- { name: "Completed", value: "COMPLETED" },
464
- { name: "Paused", value: "PAUSED" },
465
- { name: "Dropped", value: "DROPPED" },
466
- ],
467
- },
468
- ]);
469
- if (!(yield Auth.isLoggedIn())) {
470
- return console.error(`\nPlease log in first to use this feature.`);
471
- }
472
- const variables = { mediaId: selectedAnime, status: selectedListType };
473
- const saveResponse = yield fetcher(addAnimeToListMutation, variables);
474
- const saved = (_c = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
475
- if (saved) {
476
- console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
477
- }
478
- else {
479
- console.error(`\nFailed to save the anime. ${((_e = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.message) || "Unknown error"}`);
425
+ let page = 1;
426
+ let allTrending = [];
427
+ while (true) {
428
+ const request = yield fetch(aniListEndpoint, {
429
+ method: "POST",
430
+ headers: {
431
+ "Content-Type": "application/json",
432
+ },
433
+ body: JSON.stringify({
434
+ query: trendingQuery,
435
+ variables: { page, perPage: count },
436
+ }),
437
+ });
438
+ const { data, errors } = yield request.json();
439
+ if (request.status !== 200 || errors) {
440
+ console.error(`\nSomething went wrong. ${((_a = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _a === void 0 ? void 0 : _a.message) || "Unknown error"}`);
441
+ return;
442
+ }
443
+ const media = (_b = data === null || data === void 0 ? void 0 : data.Page) === null || _b === void 0 ? void 0 : _b.media;
444
+ if (!media || media.length === 0) {
445
+ console.log(`\nNo more trending anime available.`);
446
+ break;
447
+ }
448
+ allTrending = [...allTrending, ...media];
449
+ const choices = allTrending.map((anime, idx) => ({
450
+ name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
451
+ value: anime === null || anime === void 0 ? void 0 : anime.id,
452
+ }));
453
+ choices.push({ name: "See more", value: "see_more" });
454
+ const { selectedAnime } = yield inquirer.prompt([
455
+ {
456
+ type: "list",
457
+ name: "selectedAnime",
458
+ message: "Select anime to add to the list:",
459
+ choices,
460
+ pageSize: choices.length + 1,
461
+ },
462
+ ]);
463
+ if (selectedAnime === "see_more") {
464
+ page++;
465
+ continue;
466
+ }
467
+ else {
468
+ const { selectedListType } = yield inquirer.prompt([
469
+ {
470
+ type: "list",
471
+ name: "selectedListType",
472
+ message: "Select the list where you want to save this anime:",
473
+ choices: [
474
+ { name: "Planning", value: "PLANNING" },
475
+ { name: "Watching", value: "CURRENT" },
476
+ { name: "Completed", value: "COMPLETED" },
477
+ { name: "Paused", value: "PAUSED" },
478
+ { name: "Dropped", value: "DROPPED" },
479
+ ],
480
+ },
481
+ ]);
482
+ if (!(yield Auth.isLoggedIn())) {
483
+ console.error(`\nPlease log in first to use this feature.`);
484
+ return;
485
+ }
486
+ const variables = { mediaId: selectedAnime, status: selectedListType };
487
+ const saveResponse = yield fetcher(addAnimeToListMutation, variables);
488
+ const saved = (_c = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
489
+ if (saved) {
490
+ console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
491
+ }
492
+ else {
493
+ console.error(`\nFailed to save the anime. ${((_e = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.message) || "Unknown error"}`);
494
+ }
495
+ break;
496
+ }
480
497
  }
481
498
  }
482
499
  catch (error) {
@@ -488,61 +505,77 @@ class AniList {
488
505
  return __awaiter(this, void 0, void 0, function* () {
489
506
  var _a, _b, _c, _d, _e;
490
507
  try {
491
- const request = yield fetch(aniListEndpoint, {
492
- method: "POST",
493
- headers: {
494
- "Content-Type": "application/json",
495
- },
496
- body: JSON.stringify({
497
- query: popularQuery,
498
- variables: { page: 1, perPage: count },
499
- }),
500
- });
501
- const { data, errors } = yield request.json();
502
- if (request.status !== 200 || errors) {
503
- return console.log(`\nSomething went wrong. ${((_a = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _a === void 0 ? void 0 : _a.message) || "Unknown error"}`);
504
- }
505
- const media = (_b = data === null || data === void 0 ? void 0 : data.Page) === null || _b === void 0 ? void 0 : _b.media;
506
- if (!media || media.length === 0) {
507
- return console.log(`\nNo popular anime available at the moment.`);
508
- }
509
- const { selectedAnime } = yield inquirer.prompt([
510
- {
511
- type: "list",
512
- name: "selectedAnime",
513
- message: "Select anime to add to the list:",
514
- choices: media.map((anime, idx) => ({
515
- name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
516
- value: anime === null || anime === void 0 ? void 0 : anime.id,
517
- })),
518
- pageSize: 10,
519
- },
520
- ]);
521
- const { selectedListType } = yield inquirer.prompt([
522
- {
523
- type: "list",
524
- name: "selectedListType",
525
- message: "Select the list where you want to save this anime:",
526
- choices: [
527
- { name: "Planning", value: "PLANNING" },
528
- { name: "Watching", value: "CURRENT" },
529
- { name: "Completed", value: "COMPLETED" },
530
- { name: "Paused", value: "PAUSED" },
531
- { name: "Dropped", value: "DROPPED" },
532
- ],
533
- },
534
- ]);
535
- if (!(yield Auth.isLoggedIn())) {
536
- return console.error(`\nPlease log in first to use this feature.`);
537
- }
538
- const variables = { mediaId: selectedAnime, status: selectedListType };
539
- const saveResponse = yield fetcher(addAnimeToListMutation, variables);
540
- const saved = (_c = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
541
- if (saved) {
542
- console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
543
- }
544
- else {
545
- console.error(`\nFailed to save the anime. ${((_e = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.message) || "Unknown error"}`);
508
+ let page = 1;
509
+ let allMedia = [];
510
+ while (true) {
511
+ const request = yield fetch(aniListEndpoint, {
512
+ method: "POST",
513
+ headers: {
514
+ "Content-Type": "application/json",
515
+ },
516
+ body: JSON.stringify({
517
+ query: popularQuery,
518
+ variables: { page, perPage: count },
519
+ }),
520
+ });
521
+ const { data, errors } = yield request.json();
522
+ if (request.status !== 200 || errors) {
523
+ console.error(`\nSomething went wrong. ${((_a = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _a === void 0 ? void 0 : _a.message) || "Unknown error"}`);
524
+ return;
525
+ }
526
+ const newMedia = (_b = data === null || data === void 0 ? void 0 : data.Page) === null || _b === void 0 ? void 0 : _b.media;
527
+ if (!newMedia || newMedia.length === 0) {
528
+ console.log(`\nNo more popular anime available.`);
529
+ break;
530
+ }
531
+ allMedia = [...allMedia, ...newMedia];
532
+ const choices = allMedia.map((anime, idx) => ({
533
+ name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
534
+ value: anime === null || anime === void 0 ? void 0 : anime.id,
535
+ }));
536
+ choices.push({ name: "See more", value: "see_more" });
537
+ const { selectedAnime } = yield inquirer.prompt([
538
+ {
539
+ type: "list",
540
+ name: "selectedAnime",
541
+ message: "Select anime to add to the list:",
542
+ choices,
543
+ pageSize: choices.length,
544
+ },
545
+ ]);
546
+ if (selectedAnime === "see_more") {
547
+ page++;
548
+ continue;
549
+ }
550
+ else {
551
+ const { selectedListType } = yield inquirer.prompt([
552
+ {
553
+ type: "list",
554
+ name: "selectedListType",
555
+ message: "Select the list where you want to save this anime:",
556
+ choices: [
557
+ { name: "Planning", value: "PLANNING" },
558
+ { name: "Watching", value: "CURRENT" },
559
+ { name: "Completed", value: "COMPLETED" },
560
+ { name: "Paused", value: "PAUSED" },
561
+ { name: "Dropped", value: "DROPPED" },
562
+ ],
563
+ },
564
+ ]);
565
+ if (!(yield Auth.isLoggedIn())) {
566
+ return console.error(`\nPlease log in first to use this feature.`);
567
+ }
568
+ const variables = { mediaId: selectedAnime, status: selectedListType };
569
+ const saveResponse = yield fetcher(addAnimeToListMutation, variables);
570
+ const saved = (_c = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
571
+ if (saved) {
572
+ console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
573
+ }
574
+ else {
575
+ console.error(`\nFailed to save the anime. ${((_e = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.message) || "Unknown error"}`);
576
+ }
577
+ break;
578
+ }
546
579
  }
547
580
  }
548
581
  catch (error) {
@@ -555,55 +588,72 @@ class AniList {
555
588
  var _a, _b, _c, _d, _e, _f;
556
589
  try {
557
590
  const { nextSeason, nextYear } = getNextSeasonAndYear();
558
- const request = yield fetcher(upcomingAnimesQuery, {
559
- nextSeason,
560
- nextYear,
561
- perPage: count,
562
- });
563
- if (!request || !request.data) {
564
- return console.error(`\nSomething went wrong. ${((_b = (_a = request === null || request === void 0 ? void 0 : request.errors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) || "Unknown error"}`);
565
- }
566
- const upcoming = (_c = request.data.Page.media) !== null && _c !== void 0 ? _c : [];
567
- if (upcoming.length === 0) {
568
- return console.log(`\nNo upcoming anime available.`);
569
- }
570
- const { selectedAnime } = yield inquirer.prompt([
571
- {
572
- type: "list",
573
- name: "selectedAnime",
574
- message: "Select anime to add to the list:",
575
- choices: upcoming.map((anime, idx) => ({
576
- name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
577
- value: anime === null || anime === void 0 ? void 0 : anime.id,
578
- })),
579
- pageSize: 10,
580
- },
581
- ]);
582
- const { selectedListType } = yield inquirer.prompt([
583
- {
584
- type: "list",
585
- name: "selectedListType",
586
- message: "Select the list where you want to save this anime:",
587
- choices: [
588
- { name: "Planning", value: "PLANNING" },
589
- { name: "Watching", value: "CURRENT" },
590
- { name: "Completed", value: "COMPLETED" },
591
- { name: "Paused", value: "PAUSED" },
592
- { name: "Dropped", value: "DROPPED" },
593
- ],
594
- },
595
- ]);
596
- if (!(yield Auth.isLoggedIn())) {
597
- return console.error(`\nPlease log in first to use this feature.`);
598
- }
599
- const variables = { mediaId: selectedAnime, status: selectedListType };
600
- const saveResponse = yield fetcher(addAnimeToListMutation, variables);
601
- const saved = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _d === void 0 ? void 0 : _d.SaveMediaListEntry;
602
- if (saved) {
603
- console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
604
- }
605
- else {
606
- console.error(`\nFailed to save the anime. ${((_f = (_e = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.message) || "Unknown error"}`);
591
+ let page = 1;
592
+ let allUpcoming = [];
593
+ while (true) {
594
+ const request = yield fetcher(upcomingAnimesQuery, {
595
+ nextSeason,
596
+ nextYear,
597
+ page,
598
+ perPage: count,
599
+ });
600
+ if (!request || !request.data) {
601
+ console.error(`\nSomething went wrong. ${((_b = (_a = request === null || request === void 0 ? void 0 : request.errors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) || "Unknown error"}`);
602
+ return;
603
+ }
604
+ const newUpcoming = (_c = request.data.Page.media) !== null && _c !== void 0 ? _c : [];
605
+ if (newUpcoming.length === 0) {
606
+ console.log(`\nNo more upcoming anime available.`);
607
+ break;
608
+ }
609
+ allUpcoming = [...allUpcoming, ...newUpcoming];
610
+ const choices = allUpcoming.map((anime, idx) => ({
611
+ name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
612
+ value: anime === null || anime === void 0 ? void 0 : anime.id,
613
+ }));
614
+ choices.push({ name: "See more", value: "see_more" });
615
+ const { selectedAnime } = yield inquirer.prompt([
616
+ {
617
+ type: "list",
618
+ name: "selectedAnime",
619
+ message: "Select anime to add to the list:",
620
+ choices,
621
+ pageSize: choices.length + 2,
622
+ },
623
+ ]);
624
+ if (selectedAnime === "see_more") {
625
+ page++;
626
+ continue;
627
+ }
628
+ else {
629
+ const { selectedListType } = yield inquirer.prompt([
630
+ {
631
+ type: "list",
632
+ name: "selectedListType",
633
+ message: "Select the list where you want to save this anime:",
634
+ choices: [
635
+ { name: "Planning", value: "PLANNING" },
636
+ { name: "Watching", value: "CURRENT" },
637
+ { name: "Completed", value: "COMPLETED" },
638
+ { name: "Paused", value: "PAUSED" },
639
+ { name: "Dropped", value: "DROPPED" },
640
+ ],
641
+ },
642
+ ]);
643
+ if (!(yield Auth.isLoggedIn())) {
644
+ return console.error(`\nPlease log in first to use this feature.`);
645
+ }
646
+ const variables = { mediaId: selectedAnime, status: selectedListType };
647
+ const saveResponse = yield fetcher(addAnimeToListMutation, variables);
648
+ const saved = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _d === void 0 ? void 0 : _d.SaveMediaListEntry;
649
+ if (saved) {
650
+ console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
651
+ }
652
+ else {
653
+ console.error(`\nFailed to save the anime. ${((_f = (_e = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.message) || "Unknown error"}`);
654
+ }
655
+ break;
656
+ }
607
657
  }
608
658
  }
609
659
  catch (error) {
@@ -4,5 +4,4 @@ declare const deleteActivityMutation = "\nmutation($id: Int!) {\n DeleteActivit
4
4
  declare const saveTextActivityMutation = "\nmutation SaveTextActivity($status: String!) {\n SaveTextActivity(text: $status) { id text userId createdAt }\n}\n";
5
5
  declare const saveAnimeWithProgressMutation = "\nmutation ($mediaId: Int, $progress: Int, $status: MediaListStatus, $hiddenFromStatusLists: Boolean) {\n SaveMediaListEntry(mediaId: $mediaId, progress: $progress, status: $status, hiddenFromStatusLists: $hiddenFromStatusLists) {\n id progress hiddenFromStatusLists\n }\n}\n";
6
6
  declare const saveMangaWithProgressMutation = "\nmutation ($mediaId: Int, $progress: Int, $status: MediaListStatus, $hiddenFromStatusLists: Boolean, $private: Boolean) {\n SaveMediaListEntry( mediaId: $mediaId, progress: $progress, status: $status, hiddenFromStatusLists: $hiddenFromStatusLists, private: $private\n ) { id progress hiddenFromStatusLists private }\n}\n";
7
- declare const likeActivityMutation = "\nmutation($activityId: Int!) {\n ToggleLike(id: $activityId, type: ACTIVITY) { id }\n}\n";
8
- export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, likeActivityMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, saveTextActivityMutation, };
7
+ export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, saveTextActivityMutation, };
@@ -35,9 +35,4 @@ mutation ($mediaId: Int, $progress: Int, $status: MediaListStatus, $hiddenFromSt
35
35
  ) { id progress hiddenFromStatusLists private }
36
36
  }
37
37
  `;
38
- const likeActivityMutation = `
39
- mutation($activityId: Int!) {
40
- ToggleLike(id: $activityId, type: ACTIVITY) { id }
41
- }
42
- `;
43
- export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, likeActivityMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, saveTextActivityMutation, };
38
+ export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, saveTextActivityMutation, };
@@ -17,9 +17,6 @@ declare const activityMangaListQuery = "query ($userId: Int, $page: Int, $perPag
17
17
  declare const activityMessageQuery = "query ($userId: Int, $page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(userId: $userId, type: MESSAGE, sort: ID_DESC) {\n ... on MessageActivity { id type message recipient { id name } createdAt }\n }\n }\n}";
18
18
  declare const activityAllQuery = "query ($userId: Int, $page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(userId: $userId, sort: ID_DESC) {\n ... on TextActivity { id type text createdAt user { id name } }\n ... on ListActivity { id type status progress createdAt media { id title { romaji english native } } }\n ... on MessageActivity { id type message recipient { id name } createdAt }\n }\n }\n}";
19
19
  declare const activityMediaList = "query ($userId: Int, $page: Int, $perPage: Int, $type: ActivityType) {\n Page(page: $page, perPage: $perPage) {\n pageInfo { total currentPage lastPage hasNextPage perPage }\n activities(userId: $userId, type: $type, sort: ID_DESC) {\n ... on ListActivity { id type status progress media { id title { romaji english native } format } createdAt }\n }\n }\n}";
20
- declare const malIdToAnilistAnimeId = "query ($malId: Int) {\n Media(idMal: $malId, type: ANIME) { id title { romaji english } } }\n";
21
- declare const malIdToAnilistMangaId = "query ($malId: Int) {\n Media(idMal: $malId, type: MANGA) { id title { romaji english } } }\n";
22
- declare const followingActivitiesQuery = "\nquery ($page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(isFollowing: true, sort: ID_DESC) {\n ... on TextActivity { id type isLiked createdAt user { id name } }\n ... on ListActivity { id type isLiked status progress media { title { userPreferred } } createdAt user { id name } }\n ... on MessageActivity { id type isLiked message createdAt recipient { id name } }\n }\n }\n}\n";
23
- declare const globalActivitiesQuery = "\nquery ($page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(sort: ID_DESC) {\n ... on TextActivity { id type isLiked createdAt user { id name } }\n ... on ListActivity { id type isLiked status progress media { title { userPreferred } } createdAt user { id name } }\n ... on MessageActivity { id type isLiked message createdAt recipient { id name } }\n }\n }\n}\n";
24
- declare const specificUserActivitiesQuery = "\nquery ($page: Int, $perPage: Int, $userId: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(userId: $userId, sort: ID_DESC) {\n ... on TextActivity { id type isLiked createdAt user { id name } }\n ... on ListActivity { id type isLiked status progress media { title { userPreferred } } createdAt user { id name } }\n ... on MessageActivity { id type isLiked message createdAt recipient { id name } }\n }\n }\n}\n";
25
- export { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, followingActivitiesQuery, globalActivitiesQuery, malIdToAnilistAnimeId, malIdToAnilistMangaId, mangaSearchQuery, popularQuery, specificUserActivitiesQuery, trendingQuery, upcomingAnimesQuery, userActivityQuery, userQuery, };
20
+ declare const malIdToAnilistAnimeId = "query ($malId: Int) {\n Media(idMal: $malId, type: ANIME) {\n id title { romaji english } } \n}\n";
21
+ declare const malIdToAnilistMangaId = "query ($malId: Int) {\n Media(idMal: $malId, type: MANGA) {\n id title { romaji english } } \n}\n";
22
+ export { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, malIdToAnilistAnimeId, malIdToAnilistMangaId, mangaSearchQuery, popularQuery, trendingQuery, upcomingAnimesQuery, userActivityQuery, userQuery, };
@@ -120,42 +120,13 @@ const activityMediaList = `query ($userId: Int, $page: Int, $perPage: Int, $type
120
120
  }
121
121
  }`;
122
122
  const malIdToAnilistAnimeId = `query ($malId: Int) {
123
- Media(idMal: $malId, type: ANIME) { id title { romaji english } } }
124
- `;
125
- const malIdToAnilistMangaId = `query ($malId: Int) {
126
- Media(idMal: $malId, type: MANGA) { id title { romaji english } } }
127
- `;
128
- const followingActivitiesQuery = `
129
- query ($page: Int, $perPage: Int) {
130
- Page(page: $page, perPage: $perPage) {
131
- activities(isFollowing: true, sort: ID_DESC) {
132
- ... on TextActivity { id type isLiked createdAt user { id name } }
133
- ... on ListActivity { id type isLiked status progress media { title { userPreferred } } createdAt user { id name } }
134
- ... on MessageActivity { id type isLiked message createdAt recipient { id name } }
135
- }
136
- }
137
- }
138
- `;
139
- const globalActivitiesQuery = `
140
- query ($page: Int, $perPage: Int) {
141
- Page(page: $page, perPage: $perPage) {
142
- activities(sort: ID_DESC) {
143
- ... on TextActivity { id type isLiked createdAt user { id name } }
144
- ... on ListActivity { id type isLiked status progress media { title { userPreferred } } createdAt user { id name } }
145
- ... on MessageActivity { id type isLiked message createdAt recipient { id name } }
146
- }
147
- }
123
+ Media(idMal: $malId, type: ANIME) {
124
+ id title { romaji english } }
148
125
  }
149
126
  `;
150
- const specificUserActivitiesQuery = `
151
- query ($page: Int, $perPage: Int, $userId: Int) {
152
- Page(page: $page, perPage: $perPage) {
153
- activities(userId: $userId, sort: ID_DESC) {
154
- ... on TextActivity { id type isLiked createdAt user { id name } }
155
- ... on ListActivity { id type isLiked status progress media { title { userPreferred } } createdAt user { id name } }
156
- ... on MessageActivity { id type isLiked message createdAt recipient { id name } }
157
- }
158
- }
127
+ const malIdToAnilistMangaId = `query ($malId: Int) {
128
+ Media(idMal: $malId, type: MANGA) {
129
+ id title { romaji english } }
159
130
  }
160
131
  `;
161
- export { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, followingActivitiesQuery, globalActivitiesQuery, malIdToAnilistAnimeId, malIdToAnilistMangaId, mangaSearchQuery, popularQuery, specificUserActivitiesQuery, trendingQuery, upcomingAnimesQuery, userActivityQuery, userQuery, };
132
+ export { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, malIdToAnilistAnimeId, malIdToAnilistMangaId, mangaSearchQuery, popularQuery, trendingQuery, upcomingAnimesQuery, userActivityQuery, userQuery, };
package/bin/index.js CHANGED
@@ -16,7 +16,7 @@ const cli = new Command();
16
16
  cli
17
17
  .name("anilist")
18
18
  .description("Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts.")
19
- .version("1.0.0-forbidden.0");
19
+ .version("1.1.0");
20
20
  cli
21
21
  .command("login")
22
22
  .description("Login with AniList")
@@ -202,11 +202,4 @@ cli
202
202
  }
203
203
  }
204
204
  }));
205
- cli
206
- .command("autolike")
207
- .alias("al")
208
- .description("Autolike following or global activities.")
209
- .action(() => __awaiter(void 0, void 0, void 0, function* () {
210
- yield Auth.AutoLike();
211
- }));
212
205
  cli.parse(process.argv);
package/package.json CHANGED
@@ -1,73 +1,73 @@
1
- {
2
- "name": "@irfanshadikrishad/anilist",
3
- "description": "Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts",
4
- "author": "Irfan Shadik Rishad",
5
- "version": "1.1.0-forbidden.0",
6
- "main": "./bin/index.js",
7
- "type": "module",
8
- "types": "./bin/index.d.ts",
9
- "bin": {
10
- "anilist": "./bin/index.js"
11
- },
12
- "publishConfig": {
13
- "access": "public"
14
- },
15
- "scripts": {
16
- "build": "rm -rf ./bin && tsc -w",
17
- "format": "prettier . --write",
18
- "format:check": "prettier . --check",
19
- "lint": "eslint ./dist",
20
- "lint:fix": "eslint ./dist --fix",
21
- "all": "npm run lint && npm run lint:fix && npm run format"
22
- },
23
- "keywords": [
24
- "anilist",
25
- "CLI",
26
- "anime",
27
- "manga",
28
- "anime list",
29
- "manga list",
30
- "anime tracker",
31
- "manga tracker",
32
- "anilist API",
33
- "anime progress",
34
- "manga progress",
35
- "media list",
36
- "export anime",
37
- "import anime",
38
- "export manga",
39
- "import manga",
40
- "status tracker",
41
- "watchlist",
42
- "reading list",
43
- "graphql"
44
- ],
45
- "repository": {
46
- "type": "git",
47
- "url": "https://github.com/irfanshadikrishad/anilist"
48
- },
49
- "homepage": "https://github.com/irfanshadikrishad/anilist",
50
- "bugs": {
51
- "url": "https://github.com/irfanshadikrishad/anilist/issues"
52
- },
53
- "license": "MPL-2.0",
54
- "devDependencies": {
55
- "@eslint/js": "^9.13.0",
56
- "@types/json2csv": "^5.0.7",
57
- "@types/node": "^22.8.1",
58
- "eslint": "^9.13.0",
59
- "globals": "^15.11.0",
60
- "prettier": "^3.3.3",
61
- "prettier-plugin-organize-imports": "^4.1.0",
62
- "typescript": "^5.6.3",
63
- "typescript-eslint": "^8.11.0"
64
- },
65
- "dependencies": {
66
- "commander": "^12.1.0",
67
- "fast-xml-parser": "^4.5.0",
68
- "inquirer": "^12.0.1",
69
- "json2csv": "^6.0.0-alpha.2",
70
- "node-fetch": "^3.3.2",
71
- "open": "^10.1.0"
72
- }
73
- }
1
+ {
2
+ "name": "@irfanshadikrishad/anilist",
3
+ "description": "Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts",
4
+ "author": "Irfan Shadik Rishad",
5
+ "version": "1.1.0",
6
+ "main": "./bin/index.js",
7
+ "type": "module",
8
+ "types": "./bin/index.d.ts",
9
+ "bin": {
10
+ "anilist": "./bin/index.js"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "scripts": {
16
+ "build": "rm -rf ./bin && tsc -w",
17
+ "format": "prettier . --write",
18
+ "format:check": "prettier . --check",
19
+ "lint": "eslint ./dist",
20
+ "lint:fix": "eslint ./dist --fix",
21
+ "all": "npm run lint && npm run lint:fix && npm run format"
22
+ },
23
+ "keywords": [
24
+ "anilist",
25
+ "CLI",
26
+ "anime",
27
+ "manga",
28
+ "anime list",
29
+ "manga list",
30
+ "anime tracker",
31
+ "manga tracker",
32
+ "anilist API",
33
+ "anime progress",
34
+ "manga progress",
35
+ "media list",
36
+ "export anime",
37
+ "import anime",
38
+ "export manga",
39
+ "import manga",
40
+ "status tracker",
41
+ "watchlist",
42
+ "reading list",
43
+ "graphql"
44
+ ],
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "https://github.com/irfanshadikrishad/anilist"
48
+ },
49
+ "homepage": "https://github.com/irfanshadikrishad/anilist",
50
+ "bugs": {
51
+ "url": "https://github.com/irfanshadikrishad/anilist/issues"
52
+ },
53
+ "license": "MPL-2.0",
54
+ "devDependencies": {
55
+ "@eslint/js": "^9.14.0",
56
+ "@types/json2csv": "^5.0.7",
57
+ "@types/node": "^22.9.0",
58
+ "eslint": "^9.14.0",
59
+ "globals": "^15.12.0",
60
+ "prettier": "^3.3.3",
61
+ "prettier-plugin-organize-imports": "^4.1.0",
62
+ "typescript": "^5.6.3",
63
+ "typescript-eslint": "^8.14.0"
64
+ },
65
+ "dependencies": {
66
+ "commander": "^12.1.0",
67
+ "fast-xml-parser": "^4.5.0",
68
+ "inquirer": "^12.1.0",
69
+ "json2csv": "^6.0.0-alpha.2",
70
+ "node-fetch": "^3.3.2",
71
+ "open": "^10.1.0"
72
+ }
73
+ }