@irfanshadikrishad/anilist 1.1.1-forbidden.0 → 1.1.1
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 +0 -5
- package/bin/helpers/auth.d.ts +0 -3
- package/bin/helpers/auth.js +2 -155
- package/bin/helpers/fetcher.d.ts +1 -1
- package/bin/helpers/fetcher.js +23 -24
- package/bin/helpers/lists.js +209 -159
- package/bin/helpers/mutations.d.ts +1 -2
- package/bin/helpers/mutations.js +1 -6
- package/bin/helpers/queries.d.ts +3 -6
- package/bin/helpers/queries.js +6 -35
- package/bin/index.js +1 -8
- package/package.json +9 -9
- package/assets/binance.jpg +0 -0
package/README.md
CHANGED
|
@@ -229,9 +229,4 @@ 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
|
-
|
|
237
232
|
#### **_Thanks for visiting 💙_**
|
package/bin/helpers/auth.d.ts
CHANGED
|
@@ -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 };
|
package/bin/helpers/auth.js
CHANGED
|
@@ -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,
|
|
19
|
-
import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation,
|
|
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 };
|
package/bin/helpers/fetcher.d.ts
CHANGED
|
@@ -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
|
|
11
|
+
declare function fetcher(query: string, variables: object): Promise<object | null>;
|
|
12
12
|
export { fetcher };
|
package/bin/helpers/fetcher.js
CHANGED
|
@@ -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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
variables,
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
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
|
-
|
|
51
|
-
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.error(`\nSomething went wrong. ${error.message}.`);
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
52
51
|
});
|
|
53
52
|
}
|
|
54
53
|
export { fetcher };
|
package/bin/helpers/lists.js
CHANGED
|
@@ -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
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
{
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
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
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
{
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
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
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
})
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
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
|
-
|
|
8
|
-
export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, likeActivityMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, saveTextActivityMutation, };
|
|
7
|
+
export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, saveTextActivityMutation, };
|
package/bin/helpers/mutations.js
CHANGED
|
@@ -35,9 +35,4 @@ mutation ($mediaId: Int, $progress: Int, $status: MediaListStatus, $hiddenFromSt
|
|
|
35
35
|
) { id progress hiddenFromStatusLists private }
|
|
36
36
|
}
|
|
37
37
|
`;
|
|
38
|
-
|
|
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, };
|
package/bin/helpers/queries.d.ts
CHANGED
|
@@ -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) {
|
|
21
|
-
declare const malIdToAnilistMangaId = "query ($malId: Int) {\n Media(idMal: $malId, type: MANGA) {
|
|
22
|
-
|
|
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, };
|
package/bin/helpers/queries.js
CHANGED
|
@@ -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) {
|
|
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
|
|
151
|
-
|
|
152
|
-
|
|
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,
|
|
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.1.1
|
|
19
|
+
.version("1.1.1");
|
|
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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@irfanshadikrishad/anilist",
|
|
3
3
|
"description": "Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts",
|
|
4
4
|
"author": "Irfan Shadik Rishad",
|
|
5
|
-
"version": "1.1.1
|
|
5
|
+
"version": "1.1.1",
|
|
6
6
|
"main": "./bin/index.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"types": "./bin/index.d.ts",
|
|
@@ -52,20 +52,20 @@
|
|
|
52
52
|
},
|
|
53
53
|
"license": "MPL-2.0",
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@eslint/js": "^9.
|
|
55
|
+
"@eslint/js": "^9.17.0",
|
|
56
56
|
"@types/json2csv": "^5.0.7",
|
|
57
|
-
"@types/node": "^22.
|
|
58
|
-
"eslint": "^9.
|
|
59
|
-
"globals": "^15.
|
|
60
|
-
"prettier": "^3.
|
|
57
|
+
"@types/node": "^22.10.2",
|
|
58
|
+
"eslint": "^9.17.0",
|
|
59
|
+
"globals": "^15.13.0",
|
|
60
|
+
"prettier": "^3.4.2",
|
|
61
61
|
"prettier-plugin-organize-imports": "^4.1.0",
|
|
62
|
-
"typescript": "^5.
|
|
63
|
-
"typescript-eslint": "^8.
|
|
62
|
+
"typescript": "^5.7.2",
|
|
63
|
+
"typescript-eslint": "^8.18.0"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"commander": "^12.1.0",
|
|
67
67
|
"fast-xml-parser": "^4.5.0",
|
|
68
|
-
"inquirer": "^12.0
|
|
68
|
+
"inquirer": "^12.2.0",
|
|
69
69
|
"json2csv": "^6.0.0-alpha.2",
|
|
70
70
|
"node-fetch": "^3.3.2",
|
|
71
71
|
"open": "^10.1.0"
|
package/assets/binance.jpg
DELETED
|
Binary file
|