@irfanshadikrishad/anilist 1.1.1-forbidden.0 → 1.1.2
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/LICENSE +382 -382
- 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 +10 -8
- package/package.json +13 -11
- 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 };
|