@irfanshadikrishad/anilist 1.2.0-forbidden.1 → 1.2.1-forbidden.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/LICENSE.md +382 -382
- package/README.md +245 -245
- package/bin/helpers/auth.d.ts +35 -6
- package/bin/helpers/auth.js +38 -60
- package/bin/helpers/fetcher.d.ts +1 -1
- package/bin/helpers/lists.d.ts +1 -1
- package/bin/helpers/lists.js +72 -134
- package/bin/helpers/mutations.js +35 -35
- package/bin/helpers/queries.d.ts +1 -1
- package/bin/helpers/queries.js +153 -153
- package/bin/helpers/types.d.ts +112 -8
- package/bin/helpers/workers.d.ts +2 -1
- package/bin/helpers/workers.js +94 -67
- package/bin/index.js +2 -2
- package/package.json +4 -4
package/bin/helpers/auth.js
CHANGED
|
@@ -17,7 +17,7 @@ import { fetcher } from "./fetcher.js";
|
|
|
17
17
|
import { AniList, MyAnimeList } from "./lists.js";
|
|
18
18
|
import { deleteActivityMutation, likeActivityMutation, saveTextActivityMutation, } from "./mutations.js";
|
|
19
19
|
import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, followingActivitiesQuery, globalActivitiesQuery, specificUserActivitiesQuery, userActivityQuery, userQuery, } from "./queries.js";
|
|
20
|
-
import { aniListEndpoint, getTitle, redirectUri } from "./workers.js";
|
|
20
|
+
import { aniListEndpoint, getTitle, redirectUri, timestampToTimeAgo, } from "./workers.js";
|
|
21
21
|
const home_dir = os.homedir();
|
|
22
22
|
const save_path = path.join(home_dir, ".anilist_token");
|
|
23
23
|
class Auth {
|
|
@@ -109,7 +109,7 @@ class Auth {
|
|
|
109
109
|
}
|
|
110
110
|
static Myself() {
|
|
111
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
112
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
113
113
|
try {
|
|
114
114
|
if (yield Auth.isLoggedIn()) {
|
|
115
115
|
const headers = {
|
|
@@ -147,16 +147,18 @@ Statistics (Anime):
|
|
|
147
147
|
Count: ${(_g = (_f = user === null || user === void 0 ? void 0 : user.statistics) === null || _f === void 0 ? void 0 : _f.anime) === null || _g === void 0 ? void 0 : _g.count}
|
|
148
148
|
Mean Score: ${(_j = (_h = user === null || user === void 0 ? void 0 : user.statistics) === null || _h === void 0 ? void 0 : _h.anime) === null || _j === void 0 ? void 0 : _j.meanScore}
|
|
149
149
|
Minutes Watched: ${(_l = (_k = user === null || user === void 0 ? void 0 : user.statistics) === null || _k === void 0 ? void 0 : _k.anime) === null || _l === void 0 ? void 0 : _l.minutesWatched}
|
|
150
|
+
Episodes Watched: ${(_o = (_m = user === null || user === void 0 ? void 0 : user.statistics) === null || _m === void 0 ? void 0 : _m.anime) === null || _o === void 0 ? void 0 : _o.episodesWatched}
|
|
150
151
|
|
|
151
152
|
Statistics (Manga):
|
|
152
|
-
Count: ${(
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
Count: ${(_q = (_p = user === null || user === void 0 ? void 0 : user.statistics) === null || _p === void 0 ? void 0 : _p.manga) === null || _q === void 0 ? void 0 : _q.count}
|
|
154
|
+
Mean Score: ${(_s = (_r = user === null || user === void 0 ? void 0 : user.statistics) === null || _r === void 0 ? void 0 : _r.manga) === null || _s === void 0 ? void 0 : _s.meanScore}
|
|
155
|
+
Chapters Read: ${(_u = (_t = user === null || user === void 0 ? void 0 : user.statistics) === null || _t === void 0 ? void 0 : _t.manga) === null || _u === void 0 ? void 0 : _u.chaptersRead}
|
|
156
|
+
Volumes Read: ${(_w = (_v = user === null || user === void 0 ? void 0 : user.statistics) === null || _v === void 0 ? void 0 : _v.manga) === null || _w === void 0 ? void 0 : _w.volumesRead}
|
|
155
157
|
`);
|
|
156
158
|
console.log(`\nRecent Activities:`);
|
|
157
159
|
if (activities.length > 0) {
|
|
158
|
-
activities.map(({ status, progress, media }) => {
|
|
159
|
-
console.log(`${status} ${progress ? `${progress} of ` : ""}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
|
|
160
|
+
activities.map(({ status, progress, media, createdAt }) => {
|
|
161
|
+
console.log(`${timestampToTimeAgo(createdAt)}\t${status} ${progress ? `${progress} of ` : ""}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
|
|
160
162
|
});
|
|
161
163
|
}
|
|
162
164
|
return user;
|
|
@@ -217,7 +219,7 @@ Statistics (Manga):
|
|
|
217
219
|
return __awaiter(this, void 0, void 0, function* () {
|
|
218
220
|
var _a, _b;
|
|
219
221
|
if (!(yield Auth.isLoggedIn())) {
|
|
220
|
-
console.
|
|
222
|
+
console.warn(`\nUser not logged in.`);
|
|
221
223
|
return null;
|
|
222
224
|
}
|
|
223
225
|
const token = yield Auth.RetriveAccessToken();
|
|
@@ -281,8 +283,6 @@ Statistics (Manga):
|
|
|
281
283
|
],
|
|
282
284
|
},
|
|
283
285
|
]);
|
|
284
|
-
const userId = yield Auth.MyUserId();
|
|
285
|
-
const variables = { page: 1, perPage: 100, userId };
|
|
286
286
|
const queryMap = {
|
|
287
287
|
0: activityAllQuery,
|
|
288
288
|
1: activityTextQuery,
|
|
@@ -293,6 +293,7 @@ Statistics (Manga):
|
|
|
293
293
|
};
|
|
294
294
|
const query = queryMap[activityType];
|
|
295
295
|
let hasMoreActivities = true;
|
|
296
|
+
let totalCount = 0;
|
|
296
297
|
while (hasMoreActivities) {
|
|
297
298
|
const response = yield fetcher(query, {
|
|
298
299
|
page: 1,
|
|
@@ -315,7 +316,8 @@ Statistics (Manga):
|
|
|
315
316
|
});
|
|
316
317
|
const isDeleted = (_f = (_e = deleteResponse === null || deleteResponse === void 0 ? void 0 : deleteResponse.data) === null || _e === void 0 ? void 0 : _e.DeleteActivity) === null || _f === void 0 ? void 0 : _f.deleted;
|
|
317
318
|
count++;
|
|
318
|
-
|
|
319
|
+
totalCount++;
|
|
320
|
+
console.log(`[${count}/${activities.length}/${totalCount}]\t${act === null || act === void 0 ? void 0 : act.id} ${isDeleted ? "✅" : "❌"}`);
|
|
319
321
|
// Avoiding rate-limit
|
|
320
322
|
yield new Promise((resolve) => setTimeout(resolve, 1100));
|
|
321
323
|
}
|
|
@@ -360,7 +362,7 @@ Statistics (Manga):
|
|
|
360
362
|
const selectedEntries = lists.find((list) => list.name === selectedList);
|
|
361
363
|
if (selectedEntries) {
|
|
362
364
|
console.log(`\nDeleting entries of '${selectedEntries.name}':`);
|
|
363
|
-
for (const [
|
|
365
|
+
for (const [, entry] of selectedEntries.entries.entries()) {
|
|
364
366
|
if (entry === null || entry === void 0 ? void 0 : entry.id) {
|
|
365
367
|
yield Auth.DeleteAnimeById(entry === null || entry === void 0 ? void 0 : entry.id, (_c = entry === null || entry === void 0 ? void 0 : entry.media) === null || _c === void 0 ? void 0 : _c.title);
|
|
366
368
|
yield new Promise((resolve) => setTimeout(resolve, 1100));
|
|
@@ -396,19 +398,8 @@ Statistics (Manga):
|
|
|
396
398
|
return __awaiter(this, void 0, void 0, function* () {
|
|
397
399
|
var _a, _b, _c;
|
|
398
400
|
try {
|
|
399
|
-
const
|
|
400
|
-
|
|
401
|
-
headers: {
|
|
402
|
-
"content-type": "application/json",
|
|
403
|
-
"Authorization": `Bearer ${yield Auth.RetriveAccessToken()}`,
|
|
404
|
-
},
|
|
405
|
-
body: JSON.stringify({
|
|
406
|
-
query: deleteMediaEntryMutation,
|
|
407
|
-
variables: { id },
|
|
408
|
-
}),
|
|
409
|
-
});
|
|
410
|
-
const response = yield request.json();
|
|
411
|
-
if (request.status === 200) {
|
|
401
|
+
const response = yield fetcher(deleteMediaEntryMutation, { id: id });
|
|
402
|
+
if (response === null || response === void 0 ? void 0 : response.data) {
|
|
412
403
|
const deleted = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.DeleteMediaListEntry) === null || _b === void 0 ? void 0 : _b.deleted;
|
|
413
404
|
console.log(`del ${title ? getTitle(title) : ""} ${deleted ? "✅" : "❌"}`);
|
|
414
405
|
}
|
|
@@ -445,7 +436,7 @@ Statistics (Manga):
|
|
|
445
436
|
const selectedEntries = lists.find((list) => list.name === selectedList);
|
|
446
437
|
if (selectedEntries) {
|
|
447
438
|
console.log(`\nDeleting entries of '${selectedEntries.name}':`);
|
|
448
|
-
for (const [
|
|
439
|
+
for (const [, entry] of selectedEntries.entries.entries()) {
|
|
449
440
|
if (entry === null || entry === void 0 ? void 0 : entry.id) {
|
|
450
441
|
yield Auth.DeleteMangaById(entry === null || entry === void 0 ? void 0 : entry.id, (_c = entry === null || entry === void 0 ? void 0 : entry.media) === null || _c === void 0 ? void 0 : _c.title);
|
|
451
442
|
yield new Promise((resolve) => setTimeout(resolve, 1100));
|
|
@@ -477,33 +468,22 @@ Statistics (Manga):
|
|
|
477
468
|
}
|
|
478
469
|
}
|
|
479
470
|
catch (error) {
|
|
480
|
-
console.error(`\nError deleting manga
|
|
471
|
+
console.error(`\nError deleting manga. ${error.message}`);
|
|
481
472
|
}
|
|
482
473
|
});
|
|
483
474
|
}
|
|
484
475
|
static DeleteMangaById(id, title) {
|
|
485
476
|
return __awaiter(this, void 0, void 0, function* () {
|
|
486
|
-
var _a, _b;
|
|
477
|
+
var _a, _b, _c, _d;
|
|
487
478
|
try {
|
|
488
|
-
const
|
|
489
|
-
method: "POST",
|
|
490
|
-
headers: {
|
|
491
|
-
"Content-Type": "application/json",
|
|
492
|
-
"Authorization": `Bearer ${yield Auth.RetriveAccessToken()}`,
|
|
493
|
-
},
|
|
494
|
-
body: JSON.stringify({
|
|
495
|
-
query: deleteMangaEntryMutation,
|
|
496
|
-
variables: { id },
|
|
497
|
-
}),
|
|
498
|
-
});
|
|
499
|
-
const { data, errors } = yield request.json();
|
|
479
|
+
const response = yield fetcher(deleteMangaEntryMutation, { id });
|
|
500
480
|
const statusMessage = title ? getTitle(title) : "";
|
|
501
|
-
if (
|
|
502
|
-
const deleted = (_a =
|
|
481
|
+
if (response === null || response === void 0 ? void 0 : response.data) {
|
|
482
|
+
const deleted = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.DeleteMediaListEntry) === null || _b === void 0 ? void 0 : _b.deleted;
|
|
503
483
|
console.log(`del ${statusMessage} ${deleted ? "✅" : "❌"}`);
|
|
504
484
|
}
|
|
505
485
|
else {
|
|
506
|
-
console.error(`Error deleting manga. ${(
|
|
486
|
+
console.error(`Error deleting manga. ${(_d = (_c = response === null || response === void 0 ? void 0 : response.errors) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.message}`);
|
|
507
487
|
}
|
|
508
488
|
}
|
|
509
489
|
catch (error) {
|
|
@@ -519,12 +499,10 @@ Statistics (Manga):
|
|
|
519
499
|
console.error(`\nPlease login to use this feature.`);
|
|
520
500
|
return;
|
|
521
501
|
}
|
|
522
|
-
const
|
|
523
|
-
const variables = {
|
|
502
|
+
const data = yield fetcher(saveTextActivityMutation, {
|
|
524
503
|
status: status +
|
|
525
504
|
`<br><br><br><br>*Written using [@irfanshadikrishad/anilist](https://www.npmjs.com/package/@irfanshadikrishad/anilist).*`,
|
|
526
|
-
};
|
|
527
|
-
const data = yield fetcher(query, variables);
|
|
505
|
+
});
|
|
528
506
|
if (!data) {
|
|
529
507
|
console.error(`\nSomething went wrong. ${data}.`);
|
|
530
508
|
return;
|
|
@@ -605,7 +583,7 @@ Statistics (Manga):
|
|
|
605
583
|
}
|
|
606
584
|
static LikeFollowing() {
|
|
607
585
|
return __awaiter(this, void 0, void 0, function* () {
|
|
608
|
-
var _a, _b, _c, _d;
|
|
586
|
+
var _a, _b, _c, _d, _e;
|
|
609
587
|
try {
|
|
610
588
|
let page = 1;
|
|
611
589
|
let hasMoreActivities = true;
|
|
@@ -625,14 +603,14 @@ Statistics (Manga):
|
|
|
625
603
|
const like = yield fetcher(likeActivityMutation, {
|
|
626
604
|
activityId: activ.id,
|
|
627
605
|
});
|
|
628
|
-
console.info(`[${activ.id}]
|
|
606
|
+
console.info(`[${activ.id}]\t${(_e = activ.user) === null || _e === void 0 ? void 0 : _e.name} ${(like === null || like === void 0 ? void 0 : like.data) ? "✅" : "❌"}`);
|
|
629
607
|
}
|
|
630
608
|
catch (error) {
|
|
631
|
-
console.error(`Activity possibly deleted
|
|
609
|
+
console.error(`Activity possibly deleted. ${error.message}`);
|
|
632
610
|
}
|
|
633
611
|
}
|
|
634
612
|
else {
|
|
635
|
-
console.log(`[${activ === null || activ === void 0 ? void 0 : activ.id}]
|
|
613
|
+
console.log(`[${activ === null || activ === void 0 ? void 0 : activ.id}]\t${activ.user.name} already-liked`);
|
|
636
614
|
}
|
|
637
615
|
// avoiding rate-limit
|
|
638
616
|
yield new Promise((resolve) => {
|
|
@@ -662,7 +640,7 @@ Statistics (Manga):
|
|
|
662
640
|
}
|
|
663
641
|
static Like(type) {
|
|
664
642
|
return __awaiter(this, void 0, void 0, function* () {
|
|
665
|
-
var _a, _b, _c, _d;
|
|
643
|
+
var _a, _b, _c, _d, _e;
|
|
666
644
|
try {
|
|
667
645
|
let page = 1;
|
|
668
646
|
let hasMoreActivities = true;
|
|
@@ -685,18 +663,18 @@ Statistics (Manga):
|
|
|
685
663
|
activityId: activ.id,
|
|
686
664
|
});
|
|
687
665
|
// const ToggleLike = like?.data?.ToggleLike
|
|
688
|
-
console.info(`[${activ.id}]
|
|
666
|
+
console.info(`[${activ.id}]\t${(_e = activ.user) === null || _e === void 0 ? void 0 : _e.name} ${(like === null || like === void 0 ? void 0 : like.data) ? "✅" : "❌"}`);
|
|
689
667
|
}
|
|
690
668
|
catch (error) {
|
|
691
|
-
console.error(`Activity possibly deleted
|
|
669
|
+
console.error(`Activity possibly deleted. ${error.message}`);
|
|
692
670
|
}
|
|
693
671
|
}
|
|
694
672
|
else {
|
|
695
|
-
console.log(`[${activ === null || activ === void 0 ? void 0 : activ.id}]
|
|
673
|
+
console.log(`[${activ === null || activ === void 0 ? void 0 : activ.id}]\t${activ.user.name} already-liked`);
|
|
696
674
|
}
|
|
697
675
|
// avoiding rate-limit
|
|
698
676
|
yield new Promise((resolve) => {
|
|
699
|
-
setTimeout(resolve,
|
|
677
|
+
setTimeout(resolve, 1500);
|
|
700
678
|
});
|
|
701
679
|
}
|
|
702
680
|
page++;
|
|
@@ -749,18 +727,18 @@ Statistics (Manga):
|
|
|
749
727
|
const like = yield fetcher(likeActivityMutation, {
|
|
750
728
|
activityId: activ.id,
|
|
751
729
|
});
|
|
752
|
-
console.info(`[${activ.id}]
|
|
730
|
+
console.info(`[${activ.id}]\t${(_e = activ.user) === null || _e === void 0 ? void 0 : _e.name} ${(like === null || like === void 0 ? void 0 : like.data) ? "✅" : "❌"}`);
|
|
753
731
|
}
|
|
754
732
|
catch (error) {
|
|
755
|
-
console.error(`Activity possibly deleted
|
|
733
|
+
console.error(`Activity possibly deleted. ${error.message}`);
|
|
756
734
|
}
|
|
757
735
|
}
|
|
758
736
|
else {
|
|
759
|
-
console.log(`[${activ === null || activ === void 0 ? void 0 : activ.id}]
|
|
737
|
+
console.log(`[${activ === null || activ === void 0 ? void 0 : activ.id}]\t${(_f = activ.user) === null || _f === void 0 ? void 0 : _f.name} already-liked`);
|
|
760
738
|
}
|
|
761
739
|
// Avoiding rate limit
|
|
762
740
|
yield new Promise((resolve) => {
|
|
763
|
-
setTimeout(resolve,
|
|
741
|
+
setTimeout(resolve, 1500);
|
|
764
742
|
});
|
|
765
743
|
}
|
|
766
744
|
// Go to the next page
|
package/bin/helpers/fetcher.d.ts
CHANGED
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
* @param {object} variables - An object containing the variables for the query.
|
|
10
10
|
* @returns {Promise<object|null>} The response from the API as a JSON object if successful; otherwise, null.
|
|
11
11
|
*/
|
|
12
|
-
declare function fetcher(query: string, variables: object): Promise<
|
|
12
|
+
declare function fetcher(query: string, variables: object): Promise<object | null>;
|
|
13
13
|
export { fetcher };
|
package/bin/helpers/lists.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare class AniList {
|
|
|
5
5
|
static exportManga(): Promise<void>;
|
|
6
6
|
static MyAnime(): Promise<void>;
|
|
7
7
|
static MyManga(): Promise<void>;
|
|
8
|
-
static getTrendingAnime(count: number): Promise<
|
|
8
|
+
static getTrendingAnime(count: number): Promise<void>;
|
|
9
9
|
static getPopularAnime(count: number): Promise<void>;
|
|
10
10
|
static getUpcomingAnime(count: number): Promise<void>;
|
|
11
11
|
static getUserByUsername(username: string): Promise<void>;
|