@irfanshadikrishad/anilist 1.2.4 → 1.3.2-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.
@@ -1,28 +1,28 @@
1
- Mozilla Public License Version 2.0
2
- ==================================
1
+ # Mozilla Public License Version 2.0
3
2
 
4
3
  1. Definitions
5
- --------------
4
+
5
+ ---
6
6
 
7
7
  1.1. "Contributor"
8
- means each individual or legal entity that creates, contributes to
9
- the creation of, or owns Covered Software.
8
+ means each individual or legal entity that creates, contributes to
9
+ the creation of, or owns Covered Software.
10
10
 
11
11
  1.2. "Contributor Version"
12
- means the combination of the Contributions of others (if any) used
13
- by a Contributor and that particular Contributor's Contribution.
12
+ means the combination of the Contributions of others (if any) used
13
+ by a Contributor and that particular Contributor's Contribution.
14
14
 
15
15
  1.3. "Contribution"
16
- means Covered Software of a particular Contributor.
16
+ means Covered Software of a particular Contributor.
17
17
 
18
18
  1.4. "Covered Software"
19
- means Source Code Form to which the initial Contributor has attached
20
- the notice in Exhibit A, the Executable Form of such Source Code
21
- Form, and Modifications of such Source Code Form, in each case
22
- including portions thereof.
19
+ means Source Code Form to which the initial Contributor has attached
20
+ the notice in Exhibit A, the Executable Form of such Source Code
21
+ Form, and Modifications of such Source Code Form, in each case
22
+ including portions thereof.
23
23
 
24
24
  1.5. "Incompatible With Secondary Licenses"
25
- means
25
+ means
26
26
 
27
27
  (a) that the initial Contributor has attached the notice described
28
28
  in Exhibit B to the Covered Software; or
@@ -32,22 +32,22 @@ Mozilla Public License Version 2.0
32
32
  terms of a Secondary License.
33
33
 
34
34
  1.6. "Executable Form"
35
- means any form of the work other than Source Code Form.
35
+ means any form of the work other than Source Code Form.
36
36
 
37
37
  1.7. "Larger Work"
38
- means a work that combines Covered Software with other material, in
39
- a separate file or files, that is not Covered Software.
38
+ means a work that combines Covered Software with other material, in
39
+ a separate file or files, that is not Covered Software.
40
40
 
41
41
  1.8. "License"
42
- means this document.
42
+ means this document.
43
43
 
44
44
  1.9. "Licensable"
45
- means having the right to grant, to the maximum extent possible,
46
- whether at the time of the initial grant or subsequently, any and
47
- all of the rights conveyed by this License.
45
+ means having the right to grant, to the maximum extent possible,
46
+ whether at the time of the initial grant or subsequently, any and
47
+ all of the rights conveyed by this License.
48
48
 
49
49
  1.10. "Modifications"
50
- means any of the following:
50
+ means any of the following:
51
51
 
52
52
  (a) any file in Source Code Form that results from an addition to,
53
53
  deletion from, or modification of the contents of Covered
@@ -57,34 +57,35 @@ Mozilla Public License Version 2.0
57
57
  Software.
58
58
 
59
59
  1.11. "Patent Claims" of a Contributor
60
- means any patent claim(s), including without limitation, method,
61
- process, and apparatus claims, in any patent Licensable by such
62
- Contributor that would be infringed, but for the grant of the
63
- License, by the making, using, selling, offering for sale, having
64
- made, import, or transfer of either its Contributions or its
65
- Contributor Version.
60
+ means any patent claim(s), including without limitation, method,
61
+ process, and apparatus claims, in any patent Licensable by such
62
+ Contributor that would be infringed, but for the grant of the
63
+ License, by the making, using, selling, offering for sale, having
64
+ made, import, or transfer of either its Contributions or its
65
+ Contributor Version.
66
66
 
67
67
  1.12. "Secondary License"
68
- means either the GNU General Public License, Version 2.0, the GNU
69
- Lesser General Public License, Version 2.1, the GNU Affero General
70
- Public License, Version 3.0, or any later versions of those
71
- licenses.
68
+ means either the GNU General Public License, Version 2.0, the GNU
69
+ Lesser General Public License, Version 2.1, the GNU Affero General
70
+ Public License, Version 3.0, or any later versions of those
71
+ licenses.
72
72
 
73
73
  1.13. "Source Code Form"
74
- means the form of the work preferred for making modifications.
74
+ means the form of the work preferred for making modifications.
75
75
 
76
76
  1.14. "You" (or "Your")
77
- means an individual or a legal entity exercising rights under this
78
- License. For legal entities, "You" includes any entity that
79
- controls, is controlled by, or is under common control with You. For
80
- purposes of this definition, "control" means (a) the power, direct
81
- or indirect, to cause the direction or management of such entity,
82
- whether by contract or otherwise, or (b) ownership of more than
83
- fifty percent (50%) of the outstanding shares or beneficial
84
- ownership of such entity.
77
+ means an individual or a legal entity exercising rights under this
78
+ License. For legal entities, "You" includes any entity that
79
+ controls, is controlled by, or is under common control with You. For
80
+ purposes of this definition, "control" means (a) the power, direct
81
+ or indirect, to cause the direction or management of such entity,
82
+ whether by contract or otherwise, or (b) ownership of more than
83
+ fifty percent (50%) of the outstanding shares or beneficial
84
+ ownership of such entity.
85
85
 
86
86
  2. License Grants and Conditions
87
- --------------------------------
87
+
88
+ ---
88
89
 
89
90
  2.1. Grants
90
91
 
@@ -92,14 +93,14 @@ Each Contributor hereby grants You a world-wide, royalty-free,
92
93
  non-exclusive license:
93
94
 
94
95
  (a) under intellectual property rights (other than patent or trademark)
95
- Licensable by such Contributor to use, reproduce, make available,
96
- modify, display, perform, distribute, and otherwise exploit its
97
- Contributions, either on an unmodified basis, with Modifications, or
98
- as part of a Larger Work; and
96
+ Licensable by such Contributor to use, reproduce, make available,
97
+ modify, display, perform, distribute, and otherwise exploit its
98
+ Contributions, either on an unmodified basis, with Modifications, or
99
+ as part of a Larger Work; and
99
100
 
100
101
  (b) under Patent Claims of such Contributor to make, use, sell, offer
101
- for sale, have made, import, and otherwise transfer either its
102
- Contributions or its Contributor Version.
102
+ for sale, have made, import, and otherwise transfer either its
103
+ Contributions or its Contributor Version.
103
104
 
104
105
  2.2. Effective Date
105
106
 
@@ -116,15 +117,15 @@ Notwithstanding Section 2.1(b) above, no patent license is granted by a
116
117
  Contributor:
117
118
 
118
119
  (a) for any code that a Contributor has removed from Covered Software;
119
- or
120
+ or
120
121
 
121
122
  (b) for infringements caused by: (i) Your and any other third party's
122
- modifications of Covered Software, or (ii) the combination of its
123
- Contributions with other software (except as part of its Contributor
124
- Version); or
123
+ modifications of Covered Software, or (ii) the combination of its
124
+ Contributions with other software (except as part of its Contributor
125
+ Version); or
125
126
 
126
127
  (c) under Patent Claims infringed by Covered Software in the absence of
127
- its Contributions.
128
+ its Contributions.
128
129
 
129
130
  This License does not grant any rights in the trademarks, service marks,
130
131
  or logos of any Contributor (except as may be necessary to comply with
@@ -155,7 +156,8 @@ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155
156
  in Section 2.1.
156
157
 
157
158
  3. Responsibilities
158
- -------------------
159
+
160
+ ---
159
161
 
160
162
  3.1. Distribution of Source Form
161
163
 
@@ -172,15 +174,15 @@ Form.
172
174
  If You distribute Covered Software in Executable Form then:
173
175
 
174
176
  (a) such Covered Software must also be made available in Source Code
175
- Form, as described in Section 3.1, and You must inform recipients of
176
- the Executable Form how they can obtain a copy of such Source Code
177
- Form by reasonable means in a timely manner, at a charge no more
178
- than the cost of distribution to the recipient; and
177
+ Form, as described in Section 3.1, and You must inform recipients of
178
+ the Executable Form how they can obtain a copy of such Source Code
179
+ Form by reasonable means in a timely manner, at a charge no more
180
+ than the cost of distribution to the recipient; and
179
181
 
180
182
  (b) You may distribute such Executable Form under the terms of this
181
- License, or sublicense it under different terms, provided that the
182
- license for the Executable Form does not attempt to limit or alter
183
- the recipients' rights in the Source Code Form under this License.
183
+ License, or sublicense it under different terms, provided that the
184
+ license for the Executable Form does not attempt to limit or alter
185
+ the recipients' rights in the Source Code Form under this License.
184
186
 
185
187
  3.3. Distribution of a Larger Work
186
188
 
@@ -217,7 +219,8 @@ disclaimers of warranty and limitations of liability specific to any
217
219
  jurisdiction.
218
220
 
219
221
  4. Inability to Comply Due to Statute or Regulation
220
- ---------------------------------------------------
222
+
223
+ ---
221
224
 
222
225
  If it is impossible for You to comply with any of the terms of this
223
226
  License with respect to some or all of the Covered Software due to
@@ -230,7 +233,8 @@ or regulation, such description must be sufficiently detailed for a
230
233
  recipient of ordinary skill to be able to understand it.
231
234
 
232
235
  5. Termination
233
- --------------
236
+
237
+ ---
234
238
 
235
239
  5.1. The rights granted under this License will terminate automatically
236
240
  if You fail to comply with any of its terms. However, if You become
@@ -258,50 +262,55 @@ end user license agreements (excluding distributors and resellers) which
258
262
  have been validly granted by You or Your distributors under this License
259
263
  prior to termination shall survive termination.
260
264
 
261
- ************************************************************************
262
- * *
263
- * 6. Disclaimer of Warranty *
264
- * ------------------------- *
265
- * *
266
- * Covered Software is provided under this License on an "as is" *
267
- * basis, without warranty of any kind, either expressed, implied, or *
268
- * statutory, including, without limitation, warranties that the *
269
- * Covered Software is free of defects, merchantable, fit for a *
270
- * particular purpose or non-infringing. The entire risk as to the *
271
- * quality and performance of the Covered Software is with You. *
272
- * Should any Covered Software prove defective in any respect, You *
273
- * (not any Contributor) assume the cost of any necessary servicing, *
274
- * repair, or correction. This disclaimer of warranty constitutes an *
275
- * essential part of this License. No use of any Covered Software is *
276
- * authorized under this License except under this disclaimer. *
277
- * *
278
- ************************************************************************
279
-
280
- ************************************************************************
281
- * *
282
- * 7. Limitation of Liability *
283
- * -------------------------- *
284
- * *
285
- * Under no circumstances and under no legal theory, whether tort *
286
- * (including negligence), contract, or otherwise, shall any *
287
- * Contributor, or anyone who distributes Covered Software as *
288
- * permitted above, be liable to You for any direct, indirect, *
289
- * special, incidental, or consequential damages of any character *
290
- * including, without limitation, damages for lost profits, loss of *
291
- * goodwill, work stoppage, computer failure or malfunction, or any *
292
- * and all other commercial damages or losses, even if such party *
293
- * shall have been informed of the possibility of such damages. This *
294
- * limitation of liability shall not apply to liability for death or *
295
- * personal injury resulting from such party's negligence to the *
296
- * extent applicable law prohibits such limitation. Some *
297
- * jurisdictions do not allow the exclusion or limitation of *
298
- * incidental or consequential damages, so this exclusion and *
299
- * limitation may not apply to You. *
300
- * *
301
- ************************************************************************
265
+ ---
266
+
267
+ - *
268
+ - 6. Disclaimer of Warranty \*
269
+ - ------------------------- \*
270
+ - *
271
+ - Covered Software is provided under this License on an "as is" \*
272
+ - basis, without warranty of any kind, either expressed, implied, or \*
273
+ - statutory, including, without limitation, warranties that the \*
274
+ - Covered Software is free of defects, merchantable, fit for a \*
275
+ - particular purpose or non-infringing. The entire risk as to the \*
276
+ - quality and performance of the Covered Software is with You. \*
277
+ - Should any Covered Software prove defective in any respect, You \*
278
+ - (not any Contributor) assume the cost of any necessary servicing, \*
279
+ - repair, or correction. This disclaimer of warranty constitutes an \*
280
+ - essential part of this License. No use of any Covered Software is \*
281
+ - authorized under this License except under this disclaimer. \*
282
+ - *
283
+
284
+ ---
285
+
286
+ ---
287
+
288
+ - *
289
+ - 7. Limitation of Liability \*
290
+ - -------------------------- \*
291
+ - *
292
+ - Under no circumstances and under no legal theory, whether tort \*
293
+ - (including negligence), contract, or otherwise, shall any \*
294
+ - Contributor, or anyone who distributes Covered Software as \*
295
+ - permitted above, be liable to You for any direct, indirect, \*
296
+ - special, incidental, or consequential damages of any character \*
297
+ - including, without limitation, damages for lost profits, loss of \*
298
+ - goodwill, work stoppage, computer failure or malfunction, or any \*
299
+ - and all other commercial damages or losses, even if such party \*
300
+ - shall have been informed of the possibility of such damages. This \*
301
+ - limitation of liability shall not apply to liability for death or \*
302
+ - personal injury resulting from such party's negligence to the \*
303
+ - extent applicable law prohibits such limitation. Some \*
304
+ - jurisdictions do not allow the exclusion or limitation of \*
305
+ - incidental or consequential damages, so this exclusion and \*
306
+ - limitation may not apply to You. \*
307
+ - *
308
+
309
+ ---
302
310
 
303
311
  8. Litigation
304
- -------------
312
+
313
+ ---
305
314
 
306
315
  Any litigation relating to this License may be brought only in the
307
316
  courts of a jurisdiction where the defendant maintains its principal
@@ -311,7 +320,8 @@ Nothing in this Section shall prevent a party's ability to bring
311
320
  cross-claims or counter-claims.
312
321
 
313
322
  9. Miscellaneous
314
- ----------------
323
+
324
+ ---
315
325
 
316
326
  This License represents the complete agreement concerning the subject
317
327
  matter hereof. If any provision of this License is held to be
@@ -321,7 +331,8 @@ that the language of a contract shall be construed against the drafter
321
331
  shall not be used to construe this License against a Contributor.
322
332
 
323
333
  10. Versions of the License
324
- ---------------------------
334
+
335
+ ---
325
336
 
326
337
  10.1. New Versions
327
338
 
@@ -352,12 +363,11 @@ If You choose to distribute Source Code Form that is Incompatible With
352
363
  Secondary Licenses under the terms of this version of the License, the
353
364
  notice described in Exhibit B of this License must be attached.
354
365
 
355
- Exhibit A - Source Code Form License Notice
356
- -------------------------------------------
366
+ ## Exhibit A - Source Code Form License Notice
357
367
 
358
- This Source Code Form is subject to the terms of the Mozilla Public
359
- License, v. 2.0. If a copy of the MPL was not distributed with this
360
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
368
+ This Source Code Form is subject to the terms of the Mozilla Public
369
+ License, v. 2.0. If a copy of the MPL was not distributed with this
370
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
361
371
 
362
372
  If it is not possible or desirable to put the notice in a particular
363
373
  file, then You may include the notice in a location (such as a LICENSE
@@ -366,8 +376,7 @@ for such a notice.
366
376
 
367
377
  You may add additional accurate notices of copyright ownership.
368
378
 
369
- Exhibit B - "Incompatible With Secondary Licenses" Notice
370
- ---------------------------------------------------------
379
+ ## Exhibit B - "Incompatible With Secondary Licenses" Notice
371
380
 
372
- This Source Code Form is "Incompatible With Secondary Licenses", as
373
- defined by the Mozilla Public License, v. 2.0.
381
+ This Source Code Form is "Incompatible With Secondary Licenses", as
382
+ defined by the Mozilla Public License, v. 2.0.
@@ -48,5 +48,9 @@ declare class Auth {
48
48
  static Write(status: string): Promise<void>;
49
49
  static callAnimeImporter(): Promise<void>;
50
50
  static callMangaImporter(): Promise<void>;
51
+ private static LikeFollowing;
52
+ private static Like;
53
+ private static LikeSpecificUser;
54
+ static AutoLike(): Promise<void>;
51
55
  }
52
56
  export { Auth };
@@ -15,9 +15,9 @@ 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, saveTextActivityMutation, } from "./mutations.js";
19
- import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, userActivityQuery, } from "./queries.js";
20
- import { aniListEndpoint, getTitle, redirectUri, timestampToTimeAgo, } from "./workers.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";
20
+ import { activityBy, 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 {
@@ -581,5 +581,215 @@ Statistics (Manga):
581
581
  }
582
582
  });
583
583
  }
584
+ static LikeFollowing() {
585
+ return __awaiter(this, void 0, void 0, function* () {
586
+ var _a, _b, _c, _d;
587
+ try {
588
+ let page = 1;
589
+ let hasMoreActivities = true;
590
+ let retryCount = 0;
591
+ const maxRetries = 5;
592
+ while (hasMoreActivities) {
593
+ const activities = yield fetcher(followingActivitiesQuery, {
594
+ page,
595
+ perPage: 50,
596
+ });
597
+ 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) {
598
+ retryCount = 0; // Reset retry count on successful fetch
599
+ 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;
600
+ for (let activ of activiti) {
601
+ if (!activ.isLiked && activ.id) {
602
+ try {
603
+ const like = yield fetcher(likeActivityMutation, {
604
+ activityId: activ.id,
605
+ });
606
+ console.info(`${activityBy(activ)} ${(like === null || like === void 0 ? void 0 : like.data) ? "✅" : "❌"}`);
607
+ }
608
+ catch (error) {
609
+ console.error(`Activity possibly deleted. ${error.message}`);
610
+ }
611
+ }
612
+ else {
613
+ console.log(`${activityBy(activ)} 🔵`);
614
+ }
615
+ // avoiding rate-limit
616
+ yield new Promise((resolve) => {
617
+ setTimeout(resolve, 2000);
618
+ });
619
+ }
620
+ page++;
621
+ }
622
+ else {
623
+ if (retryCount < maxRetries) {
624
+ retryCount++;
625
+ console.warn(`Empty activities returned. Retrying... (${retryCount}/${maxRetries})`);
626
+ yield new Promise((resolve) => setTimeout(resolve, 3000));
627
+ }
628
+ else {
629
+ console.log(`\nProbably the end of activities after ${maxRetries} retries.`);
630
+ console.info(activities);
631
+ hasMoreActivities = false;
632
+ }
633
+ }
634
+ }
635
+ }
636
+ catch (error) {
637
+ console.error(`\nError from likeFollowing. ${error.message}`);
638
+ }
639
+ });
640
+ }
641
+ static Like(type) {
642
+ return __awaiter(this, void 0, void 0, function* () {
643
+ var _a, _b, _c, _d;
644
+ try {
645
+ let page = 1;
646
+ let hasMoreActivities = true;
647
+ let activity = type === 0
648
+ ? followingActivitiesQuery
649
+ : type === 1
650
+ ? globalActivitiesQuery
651
+ : followingActivitiesQuery;
652
+ while (hasMoreActivities) {
653
+ const activities = yield fetcher(activity, {
654
+ page,
655
+ perPage: 50,
656
+ });
657
+ 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) {
658
+ 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;
659
+ for (let activ of activiti) {
660
+ if (!activ.isLiked && activ.id) {
661
+ try {
662
+ const like = yield fetcher(likeActivityMutation, {
663
+ activityId: activ.id,
664
+ });
665
+ // const ToggleLike = like?.data?.ToggleLike
666
+ console.info(`${activityBy(activ)} ${(like === null || like === void 0 ? void 0 : like.data) ? "✅" : "❌"}`);
667
+ }
668
+ catch (error) {
669
+ console.error(`Activity possibly deleted. ${error.message}`);
670
+ }
671
+ }
672
+ else {
673
+ console.log(`${activityBy(activ)} 🔵`);
674
+ }
675
+ // avoiding rate-limit
676
+ yield new Promise((resolve) => {
677
+ setTimeout(resolve, 1500);
678
+ });
679
+ }
680
+ page++;
681
+ }
682
+ else {
683
+ // No more activities to like
684
+ console.log(`\nProbably the end of activities.`);
685
+ console.info(activities);
686
+ hasMoreActivities = false;
687
+ }
688
+ }
689
+ }
690
+ catch (error) {
691
+ console.error(`\nError from likeFollowing. ${error.message}`);
692
+ }
693
+ });
694
+ }
695
+ static LikeSpecificUser() {
696
+ return __awaiter(this, void 0, void 0, function* () {
697
+ var _a, _b, _c, _d;
698
+ try {
699
+ const { username } = yield inquirer.prompt([
700
+ {
701
+ type: "input",
702
+ name: "username",
703
+ message: "Username of the user:",
704
+ },
705
+ ]);
706
+ const userDetails = yield fetcher(userQuery, { username: username });
707
+ if (userDetails) {
708
+ let page = 1;
709
+ const perPage = 50;
710
+ 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;
711
+ if (userId) {
712
+ while (true) {
713
+ const activities = yield fetcher(specificUserActivitiesQuery, {
714
+ page,
715
+ perPage,
716
+ userId,
717
+ });
718
+ 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;
719
+ // Break the loop if no more activities are found
720
+ if (!activiti || activiti.length === 0) {
721
+ console.log("No more activities found.");
722
+ break;
723
+ }
724
+ for (let activ of activiti) {
725
+ if (!activ.isLiked && activ.id) {
726
+ try {
727
+ const like = yield fetcher(likeActivityMutation, {
728
+ activityId: activ.id,
729
+ });
730
+ console.info(`${activityBy(activ)} ${(like === null || like === void 0 ? void 0 : like.data) ? "✅" : "❌"}`);
731
+ }
732
+ catch (error) {
733
+ console.error(`Activity possibly deleted. ${error.message}`);
734
+ }
735
+ }
736
+ else {
737
+ console.log(`${activityBy(activ)} 🔵`);
738
+ }
739
+ // Avoiding rate limit
740
+ yield new Promise((resolve) => {
741
+ setTimeout(resolve, 1500);
742
+ });
743
+ }
744
+ // Go to the next page
745
+ page += 1;
746
+ }
747
+ }
748
+ }
749
+ }
750
+ catch (error) {
751
+ console.error(`\nError from LikeSpecificUser. ${error.message}`);
752
+ }
753
+ });
754
+ }
755
+ static AutoLike() {
756
+ return __awaiter(this, void 0, void 0, function* () {
757
+ try {
758
+ if (!(yield Auth.isLoggedIn())) {
759
+ console.error(`\nPlease login to use this feature.`);
760
+ return;
761
+ }
762
+ const { activityType } = yield inquirer.prompt([
763
+ {
764
+ type: "list",
765
+ name: "activityType",
766
+ message: "Select activity type:",
767
+ choices: [
768
+ { name: "Following", value: 1 },
769
+ { name: "Global", value: 2 },
770
+ { name: "Specific User", value: 3 },
771
+ ],
772
+ pageSize: 10,
773
+ },
774
+ ]);
775
+ switch (activityType) {
776
+ case 1:
777
+ yield this.LikeFollowing();
778
+ break;
779
+ case 2:
780
+ yield this.Like(1);
781
+ break;
782
+ case 3:
783
+ yield this.LikeSpecificUser();
784
+ break;
785
+ default:
786
+ console.error(`\nInvalid choice. (${activityType})`);
787
+ }
788
+ }
789
+ catch (error) {
790
+ console.error(`\nError from autolike. ${error.message}`);
791
+ }
792
+ });
793
+ }
584
794
  }
585
795
  export { Auth };
@@ -4,4 +4,5 @@ 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
- export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, saveTextActivityMutation, };
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, };
@@ -35,4 +35,9 @@ mutation ($mediaId: Int, $progress: Int, $status: MediaListStatus, $hiddenFromSt
35
35
  ) { id progress hiddenFromStatusLists private }
36
36
  }
37
37
  `;
38
- export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, saveTextActivityMutation, };
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, };
@@ -17,6 +17,9 @@ 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) {\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, };
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 { messenger { name } 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, };
@@ -120,13 +120,42 @@ 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
- id title { romaji english } }
125
- }
123
+ Media(idMal: $malId, type: ANIME) { id title { romaji english } } }
126
124
  `;
127
125
  const malIdToAnilistMangaId = `query ($malId: Int) {
128
- Media(idMal: $malId, type: MANGA) {
129
- id title { romaji english } }
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
+ }
148
+ }
149
+ `;
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 { messenger { name } id type isLiked message createdAt recipient { id name } }
157
+ }
158
+ }
130
159
  }
131
160
  `;
132
- export { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, malIdToAnilistAnimeId, malIdToAnilistMangaId, mangaSearchQuery, popularQuery, trendingQuery, upcomingAnimesQuery, userActivityQuery, userQuery, };
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, };
@@ -212,4 +212,29 @@ interface MediaListEntry {
212
212
  hiddenFromStatusLists?: boolean;
213
213
  private?: boolean;
214
214
  }
215
- export { AniListMediaStatus, AnimeDetails, AnimeList, DateMonthYear, DeleteMangaResponse, List, MALAnimeStatus, MALAnimeXML, MALMangaStatus, MalIdToAnilistIdResponse, MediaEntry, MediaList, MediaListEntry, MediaTitle, MediaWithProgress, Myself, saveAnimeWithProgressResponse, };
215
+ interface TheActivity {
216
+ type: string;
217
+ id: number;
218
+ message?: string;
219
+ createdAt: number;
220
+ recipient?: {
221
+ id: number;
222
+ name: string;
223
+ };
224
+ isLiked?: boolean;
225
+ user?: {
226
+ id?: number;
227
+ name?: string;
228
+ };
229
+ messenger?: {
230
+ name: string;
231
+ };
232
+ media?: {
233
+ title?: {
234
+ userPreferred: string;
235
+ };
236
+ };
237
+ progress?: string | null;
238
+ status?: string;
239
+ }
240
+ export { AniListMediaStatus, AnimeDetails, AnimeList, DateMonthYear, DeleteMangaResponse, List, MALAnimeStatus, MALAnimeXML, MALMangaStatus, MalIdToAnilistIdResponse, MediaEntry, MediaList, MediaListEntry, MediaTitle, MediaWithProgress, Myself, TheActivity, saveAnimeWithProgressResponse, };
@@ -1,4 +1,4 @@
1
- import { MALAnimeStatus, MALMangaStatus, MediaWithProgress } from "./types.js";
1
+ import { MALAnimeStatus, MALMangaStatus, MediaWithProgress, TheActivity } from "./types.js";
2
2
  declare const aniListEndpoint = "https://graphql.anilist.co";
3
3
  declare const redirectUri = "https://anilist.co/api/v2/oauth/pin";
4
4
  declare function getTitle(title: {
@@ -36,4 +36,5 @@ declare function createAnimeListXML(mediaWithProgress: MediaWithProgress[]): Pro
36
36
  declare function createMangaListXML(mediaWithProgress: MediaWithProgress[]): Promise<string>;
37
37
  declare function getCurrentPackageVersion(): string | null;
38
38
  declare function timestampToTimeAgo(timestamp: number): string;
39
- export { aniListEndpoint, createAnimeListXML, createAnimeXML, createMangaListXML, createMangaXML, formatDateObject, getCurrentPackageVersion, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, selectFile, timestampToTimeAgo, };
39
+ declare function activityBy(activity: TheActivity): string;
40
+ export { activityBy, aniListEndpoint, createAnimeListXML, createAnimeXML, createMangaListXML, createMangaXML, formatDateObject, getCurrentPackageVersion, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, selectFile, timestampToTimeAgo, };
@@ -17,7 +17,7 @@ import { homedir } from "os";
17
17
  import { join } from "path";
18
18
  import process from "process";
19
19
  import { Auth } from "./auth.js";
20
- import { MALAnimeStatus, MALMangaStatus } from "./types.js";
20
+ import { MALAnimeStatus, MALMangaStatus, } from "./types.js";
21
21
  const aniListEndpoint = `https://graphql.anilist.co`;
22
22
  const redirectUri = "https://anilist.co/api/v2/oauth/pin";
23
23
  function getTitle(title) {
@@ -314,4 +314,24 @@ function timestampToTimeAgo(timestamp) {
314
314
  return `${years} year${years === 1 ? "" : "s"} ago`;
315
315
  }
316
316
  }
317
- export { aniListEndpoint, createAnimeListXML, createAnimeXML, createMangaListXML, createMangaXML, formatDateObject, getCurrentPackageVersion, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, selectFile, timestampToTimeAgo, };
317
+ function activityBy(activity) {
318
+ var _a, _b, _c, _d;
319
+ if ((_a = activity === null || activity === void 0 ? void 0 : activity.messenger) === null || _a === void 0 ? void 0 : _a.name) {
320
+ return `[${activity.id}]\t${activity.messenger.name} messaged ${activity.recipient.name}`;
321
+ }
322
+ else if ((_c = (_b = activity === null || activity === void 0 ? void 0 : activity.media) === null || _b === void 0 ? void 0 : _b.title) === null || _c === void 0 ? void 0 : _c.userPreferred) {
323
+ if (activity.progress) {
324
+ return `[${activity.id}]\t${activity.user.name} ${activity.status} ${activity.progress} of ${activity.media.title.userPreferred}`;
325
+ }
326
+ else {
327
+ return `[${activity.id}]\t${activity.user.name} ${activity.status} ${activity.media.title.userPreferred}`;
328
+ }
329
+ }
330
+ else if ((_d = activity === null || activity === void 0 ? void 0 : activity.user) === null || _d === void 0 ? void 0 : _d.name) {
331
+ return `[${activity.id}]\t${activity.user.name}`;
332
+ }
333
+ else {
334
+ return `[${activity === null || activity === void 0 ? void 0 : activity.id}] ???`;
335
+ }
336
+ }
337
+ export { activityBy, aniListEndpoint, createAnimeListXML, createAnimeXML, createMangaListXML, createMangaXML, formatDateObject, getCurrentPackageVersion, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, selectFile, timestampToTimeAgo, };
package/bin/index.js CHANGED
@@ -203,4 +203,11 @@ cli
203
203
  }
204
204
  }
205
205
  }));
206
+ cli
207
+ .command("autolike")
208
+ .alias("al")
209
+ .description("Autolike following or global activities.")
210
+ .action(() => __awaiter(void 0, void 0, void 0, function* () {
211
+ yield Auth.AutoLike();
212
+ }));
206
213
  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.2.4",
5
+ "version": "1.3.2-forbidden.1",
6
6
  "main": "./bin/index.js",
7
7
  "type": "module",
8
8
  "types": "./bin/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "format:check": "prettier . --check",
20
20
  "lint": "eslint ./dist",
21
21
  "lint:fix": "eslint ./dist --fix",
22
- "all": "npm run lint && npm run lint:fix && npm run format && npm test",
22
+ "all": "npm run build && npm run lint && npm run lint:fix && npm run format && npm test",
23
23
  "test": "jest ./tests"
24
24
  },
25
25
  "keywords": [
@@ -65,9 +65,9 @@
65
65
  "prettier-plugin-organize-imports": "^4.1.0",
66
66
  "ts-jest": "^29.2.5",
67
67
  "ts-node": "^10.9.2",
68
- "typescript": "^5.7.2",
68
+ "typescript": "^5.7.3",
69
69
  "@babel/preset-env": "^7.26.0",
70
- "@typescript-eslint/eslint-plugin": "^8.19.0"
70
+ "@typescript-eslint/eslint-plugin": "^8.19.1"
71
71
  },
72
72
  "dependencies": {
73
73
  "commander": "^13.0.0",