@irfanshadikrishad/anilist 3.0.0-forbidden.0 → 3.1.0-forbidden.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  #### @irfanshadikrishad/anilist
2
2
 
3
- Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts.
3
+ Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts. With features like sync or shift lists from other tracking platforms like MyAnimeList/AniDB, Unfollow users who doesn't follow you back, etc.
4
4
 
5
- ![NPM Version](https://img.shields.io/npm/v/%40irfanshadikrishad%2Fanilist?style=for-the-badge&color=%23adc178)
6
- ![NPM Downloads](https://img.shields.io/npm/dw/%40irfanshadikrishad%2Fanilist?style=for-the-badge&color=%23eaac8b)
7
- ![NPM License](https://img.shields.io/npm/l/%40irfanshadikrishad%2Fanilist?style=for-the-badge&color=%23f2d0a4)
5
+ ![NPM Version](https://img.shields.io/npm/v/%40irfanshadikrishad%2Fanilist%2Fforbidden?style=for-the-badge&labelColor=141b23&color=%2385c1dc)
6
+ ![NPM Downloads](https://img.shields.io/npm/dw/%40irfanshadikrishad%2Fanilist?style=for-the-badge&labelColor=141b23&color=%2385c1dc)
7
+ ![NPM License](https://img.shields.io/npm/l/%40irfanshadikrishad%2Fanilist?style=for-the-badge&labelColor=141b23&color=%2385c1dc)
8
8
 
9
9
  #### How to install?
10
10
 
@@ -64,6 +64,7 @@ anilist login -i <client-id> -s <client-secret>
64
64
  | `export` <br> _(alias: `exp`)_ | `-a, --anime` <br> `-m, --manga` | Export anime or manga list in JSON, CSV or XML (MyAnimeList/AniDB) |
65
65
  | `import` <br> _(alias: `imp`)_ | `-a, --anime` <br> `-m, --manga` | Import anime or manga list from exported JSON, MyAnimeList (XML) or AniDB (json-large) |
66
66
  | `social` <br> _(alias: `sol`)_ | `-f, --follow` <br> `-u, --unfollow` <br> `-i, --inactive <months>` | Follow users who follows you, unfollow who doesn't follow you back, or unfollow stale/inactive accounts |
67
+ | `autolike` <br> _(alias: `al`)_ | _None_ | Auto-Like features |
67
68
 
68
69
  #### Command Breakdown:
69
70
 
@@ -260,21 +261,28 @@ anilist sol -i 6
260
261
  - `-i, --inactive <months>`: To unfollow users you follow who haven't posted any activity in the given number of months, to help clear out stale/inactive accounts.
261
262
  - Description: It follows users who follows you, unfollows users who doesn't follow you back, or unfollows stale accounts with no recent activity, all at ease.
262
263
 
264
+ #### `autolike` _(alias: `al`)_:
265
+
266
+ ```bash
267
+ anilist al
268
+ ```
269
+
270
+ ```bash
271
+ anilist al -o 1 -c 15
272
+ ```
273
+
274
+ - Options:
275
+ - Selectable options (Following • v1 | Following • v2 | Global | Specific User), or
276
+ - `-c, --count <number>`: How many likes to give
277
+ - `-o, --option <number>`: Option as number (asc)
278
+ - Description: Gives likes automatically based on mode.
279
+
263
280
  #### Security
264
281
 
265
- Since you are creating your own API client for login no else else can get your credentials and the generated access token will be stored in your own system. So, As long as you don't share your device (in case you do, just logout) you are safe.
282
+ Since you are creating your own API client for login no one else can get your credentials and the generated access token will be stored in your own system. So, As long as you don't share your device (in case you do, just logout) you are safe.
266
283
 
267
284
  #### Contribution
268
285
 
269
286
  Want to contribute to the project? Check out complete guideline [here](CONTRIBUTING.md).
270
287
 
271
- #### Publish
272
-
273
- • Bump the version (since you have real changes since 2.0.0-forbidden was published, you can't republish that exact version):
274
- `npm version prerelease --preid=forbidden --no-git-tag-version`
275
- This takes 2.0.0-forbidden → 2.0.0-forbidden.0, matching the pattern of past releases (1.1.0-forbidden.0, .7, etc.).
276
- • Build: `npm run build`
277
- • Publish under the forbidden tag, not latest:
278
- `npm publish --tag forbidden`
279
-
280
288
  #### _Thanks for visiting 💙_
@@ -31,7 +31,7 @@ declare class Auth {
31
31
  private static LikeGlobal;
32
32
  private static LikeSpecificUser;
33
33
  static LikeFollowingActivityV2(perPage: number): Promise<void>;
34
- static AutoLike(): Promise<void>;
34
+ static AutoLike(option: number, passed_count: number): Promise<void>;
35
35
  }
36
36
  declare class Social {
37
37
  /**
@@ -19,11 +19,12 @@ import Spinner from 'tiny-spinner';
19
19
  import { fetcher } from './fetcher.js';
20
20
  import { colorize } from './lib/colorize.js';
21
21
  import { rate_limit_time_ms, symbol_done, symbol_fail, symbol_neutral, } from './lib/constants.js';
22
+ import { renderUserProfile } from './lib/render.js';
22
23
  import { AniDB, AniList, MyAnimeList } from './lists.js';
23
- import { deleteActivityMutation, deleteMangaEntryMutation, deleteMediaEntryMutation, likeActivityMutation, saveTextActivityMutation, toggleFollowMutation, } from './mutations.js';
24
+ import { deleteMangaEntryMutation, deleteMediaEntryMutation, likeActivityMutation, saveTextActivityMutation, toggleFollowMutation, } from './mutations.js';
24
25
  import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, followingActivitiesQuery, globalActivitiesQuery, specificUserActivitiesQuery, userActivityQuery, userFollowersQuery, userFollowingQuery, userQuery, } from './queries.js';
25
26
  import { responsiveOutput } from './truncate.js';
26
- import { activityBy, aniListEndpoint, getTitle, redirectUri, sleep, timestampToTimeAgo, } from './workers.js';
27
+ import { activityBy, aniListEndpoint, deleteActivities, getTitle, redirectUri, sleep, timestampToTimeAgo, } from './workers.js';
27
28
  const home_dir = os.homedir();
28
29
  const save_path = path.join(home_dir, '.anilist_token');
29
30
  const spinner = new Spinner();
@@ -71,12 +72,10 @@ class Auth {
71
72
  static RetriveAccessToken() {
72
73
  return __awaiter(this, void 0, void 0, function* () {
73
74
  try {
74
- if (fs.existsSync(save_path)) {
75
- return vigenere.decrypt(fs.readFileSync(save_path, { encoding: 'utf8' }));
76
- }
77
- else {
75
+ if (!fs.existsSync(save_path)) {
78
76
  return null;
79
77
  }
78
+ return vigenere.decrypt(fs.readFileSync(save_path, { encoding: 'utf8' }));
80
79
  }
81
80
  catch (error) {
82
81
  console.error(`\nError retriving acess-token. ${error.message}`);
@@ -106,19 +105,13 @@ class Auth {
106
105
  }),
107
106
  });
108
107
  const token_Data = yield tokenResponse.json();
109
- if (token_Data === null || token_Data === void 0 ? void 0 : token_Data.access_token) {
110
- yield Auth.StoreAccessToken(token_Data === null || token_Data === void 0 ? void 0 : token_Data.access_token);
111
- const name = yield Auth.MyUserName();
112
- if (name) {
113
- console.log(`\nWelcome Back, ${name}!`);
114
- }
115
- else {
116
- console.log(`\nLogged in successfull!`);
117
- }
118
- }
119
- else {
108
+ if (!(token_Data === null || token_Data === void 0 ? void 0 : token_Data.access_token)) {
120
109
  console.error('\nFailed to get access token:', token_Data);
110
+ return;
121
111
  }
112
+ yield Auth.StoreAccessToken(token_Data.access_token);
113
+ const name = yield Auth.MyUserName();
114
+ console.log(name ? `\nWelcome Back, ${name}!` : '\nLogged in successfully!');
122
115
  }
123
116
  catch (error) {
124
117
  console.error(`\nFailed logging in. ${error.message}`);
@@ -127,81 +120,53 @@ class Auth {
127
120
  }
128
121
  static Myself() {
129
122
  return __awaiter(this, void 0, void 0, function* () {
130
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
123
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
131
124
  try {
132
- if (yield Auth.isLoggedIn()) {
133
- const headers = {
125
+ if (!(yield Auth.isLoggedIn())) {
126
+ console.error('\nPlease login first to use this feature.');
127
+ return null;
128
+ }
129
+ const accessToken = yield Auth.RetriveAccessToken();
130
+ const request = yield fetch(aniListEndpoint, {
131
+ method: 'POST',
132
+ headers: {
134
133
  'Content-Type': 'application/json',
135
- 'Authorization': `Bearer ${yield Auth.RetriveAccessToken()}`,
136
- };
137
- const request = yield fetch(aniListEndpoint, {
138
- method: 'POST',
139
- headers: headers,
140
- body: JSON.stringify({ query: currentUserQuery }),
141
- });
142
- const { data, errors } = yield request.json();
143
- if (request.status === 200) {
144
- const user = data === null || data === void 0 ? void 0 : data.Viewer;
145
- const activiResponse = yield fetcher(userActivityQuery, {
146
- id: user === null || user === void 0 ? void 0 : user.id,
147
- page: 1,
148
- perPage: 10,
149
- });
150
- const activities = (_b = (_a = activiResponse === null || activiResponse === void 0 ? void 0 : activiResponse.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.activities;
151
- // Get follower/following information
152
- const req_followers = yield fetcher(userFollowersQuery, {
153
- userId: user === null || user === void 0 ? void 0 : user.id,
154
- });
155
- const req_following = yield fetcher(userFollowingQuery, {
156
- userId: user === null || user === void 0 ? void 0 : user.id,
157
- });
158
- const followersCount = ((_e = (_d = (_c = req_followers === null || req_followers === void 0 ? void 0 : req_followers.data) === null || _c === void 0 ? void 0 : _c.Page) === null || _d === void 0 ? void 0 : _d.pageInfo) === null || _e === void 0 ? void 0 : _e.total) || 0;
159
- const followingCount = ((_h = (_g = (_f = req_following === null || req_following === void 0 ? void 0 : req_following.data) === null || _f === void 0 ? void 0 : _f.Page) === null || _g === void 0 ? void 0 : _g.pageInfo) === null || _h === void 0 ? void 0 : _h.total) || 0;
160
- console.log(`
161
- ID: ${user === null || user === void 0 ? void 0 : user.id}
162
- Name: ${user === null || user === void 0 ? void 0 : user.name}
163
- siteUrl: ${user === null || user === void 0 ? void 0 : user.siteUrl}
164
- profileColor: ${(_j = user === null || user === void 0 ? void 0 : user.options) === null || _j === void 0 ? void 0 : _j.profileColor}
165
- timeZone: ${(_k = user === null || user === void 0 ? void 0 : user.options) === null || _k === void 0 ? void 0 : _k.timezone}
166
- activityMergeTime: ${(_l = user === null || user === void 0 ? void 0 : user.options) === null || _l === void 0 ? void 0 : _l.activityMergeTime}
167
- donatorTier: ${user === null || user === void 0 ? void 0 : user.donatorTier}
168
- donatorBadge: ${user === null || user === void 0 ? void 0 : user.donatorBadge}
169
- unreadNotificationCount:${user === null || user === void 0 ? void 0 : user.unreadNotificationCount}
170
- Account Created: ${new Date((user === null || user === void 0 ? void 0 : user.createdAt) * 1000).toUTCString()}
171
- Account Updated: ${new Date((user === null || user === void 0 ? void 0 : user.updatedAt) * 1000).toUTCString()}
172
-
173
- Followers: ${followersCount}
174
- Following: ${followingCount}
175
-
176
- Statistics (Anime):
177
- Count: ${(_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.count}
178
- Mean Score: ${(_q = (_p = user === null || user === void 0 ? void 0 : user.statistics) === null || _p === void 0 ? void 0 : _p.anime) === null || _q === void 0 ? void 0 : _q.meanScore}
179
- Minutes Watched: ${(_s = (_r = user === null || user === void 0 ? void 0 : user.statistics) === null || _r === void 0 ? void 0 : _r.anime) === null || _s === void 0 ? void 0 : _s.minutesWatched}
180
- Episodes Watched: ${(_u = (_t = user === null || user === void 0 ? void 0 : user.statistics) === null || _t === void 0 ? void 0 : _t.anime) === null || _u === void 0 ? void 0 : _u.episodesWatched}
181
-
182
- Statistics (Manga):
183
- Count: ${(_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.count}
184
- Mean Score: ${(_y = (_x = user === null || user === void 0 ? void 0 : user.statistics) === null || _x === void 0 ? void 0 : _x.manga) === null || _y === void 0 ? void 0 : _y.meanScore}
185
- Chapters Read: ${(_0 = (_z = user === null || user === void 0 ? void 0 : user.statistics) === null || _z === void 0 ? void 0 : _z.manga) === null || _0 === void 0 ? void 0 : _0.chaptersRead}
186
- Volumes Read: ${(_2 = (_1 = user === null || user === void 0 ? void 0 : user.statistics) === null || _1 === void 0 ? void 0 : _1.manga) === null || _2 === void 0 ? void 0 : _2.volumesRead}
187
- `);
188
- console.log(`\nRecent Activities:`);
189
- if (activities.length > 0) {
190
- activities.map(({ status, progress, media, createdAt }) => {
191
- responsiveOutput(`${timestampToTimeAgo(createdAt)}\t${status} ${progress ? `${progress} of ` : ''}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
192
- });
193
- }
194
- return user;
195
- }
196
- else {
197
- console.error(`\nSomething went wrong. Please log in again. ${errors[0].message}`);
198
- return null;
199
- }
134
+ 'Authorization': `Bearer ${accessToken}`,
135
+ },
136
+ body: JSON.stringify({ query: currentUserQuery }),
137
+ });
138
+ const { data, errors } = yield request.json();
139
+ if (!request.ok) {
140
+ console.error(`\nSomething went wrong. Please log in again. ${(_b = (_a = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'Unknown error'}`);
141
+ return null;
200
142
  }
201
- else {
202
- console.error(`\nPlease login first to use this feature.`);
143
+ const user = data === null || data === void 0 ? void 0 : data.Viewer;
144
+ if (!user) {
145
+ console.error('\nUnable to retrieve user information.');
203
146
  return null;
204
147
  }
148
+ const [activityResponse, followersResponse, followingResponse] = yield Promise.all([
149
+ fetcher(userActivityQuery, {
150
+ id: user.id,
151
+ page: 1,
152
+ perPage: 10,
153
+ }),
154
+ fetcher(userFollowersQuery, {
155
+ userId: user.id,
156
+ }),
157
+ fetcher(userFollowingQuery, {
158
+ userId: user.id,
159
+ }),
160
+ ]);
161
+ const activities = (_e = (_d = (_c = activityResponse === null || activityResponse === void 0 ? void 0 : activityResponse.data) === null || _c === void 0 ? void 0 : _c.Page) === null || _d === void 0 ? void 0 : _d.activities) !== null && _e !== void 0 ? _e : [];
162
+ const followersCount = (_j = (_h = (_g = (_f = followersResponse === null || followersResponse === void 0 ? void 0 : followersResponse.data) === null || _f === void 0 ? void 0 : _f.Page) === null || _g === void 0 ? void 0 : _g.pageInfo) === null || _h === void 0 ? void 0 : _h.total) !== null && _j !== void 0 ? _j : 0;
163
+ const followingCount = (_o = (_m = (_l = (_k = followingResponse === null || followingResponse === void 0 ? void 0 : followingResponse.data) === null || _k === void 0 ? void 0 : _k.Page) === null || _l === void 0 ? void 0 : _l.pageInfo) === null || _m === void 0 ? void 0 : _m.total) !== null && _o !== void 0 ? _o : 0;
164
+ renderUserProfile(user, followersCount, followingCount);
165
+ console.log('\nRecent Activities:');
166
+ activities.forEach(({ status, progress, media, createdAt }) => {
167
+ responsiveOutput(`${timestampToTimeAgo(createdAt)}\t${status} ${progress ? `${progress} of ` : ''}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
168
+ });
169
+ return user;
205
170
  }
206
171
  catch (error) {
207
172
  console.error(`\nError from Myself. ${error.message}`);
@@ -266,7 +231,7 @@ Statistics (Manga):
266
231
  }
267
232
  static DeleteMyActivities() {
268
233
  return __awaiter(this, void 0, void 0, function* () {
269
- var _a, _b, _c, _d, _e, _f;
234
+ var _a, _b;
270
235
  try {
271
236
  if (!(yield Auth.isLoggedIn())) {
272
237
  console.error(`\nPlease log in to delete your activities.`);
@@ -304,34 +269,19 @@ Statistics (Manga):
304
269
  perPage: 50,
305
270
  userId: yield Auth.MyUserId(),
306
271
  });
307
- if ((_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.activities) {
308
- let count = 0;
309
- const activities = (_d = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.Page) === null || _d === void 0 ? void 0 : _d.activities;
310
- if (!activities || activities.length === 0) {
311
- console.log(`\nNo more activities available.`);
312
- hasMoreActivities = false;
313
- }
314
- else {
315
- for (const act of activities) {
316
- if (act === null || act === void 0 ? void 0 : act.id) {
317
- const deleteResponse = yield fetcher(deleteActivityMutation, {
318
- id: act === null || act === void 0 ? void 0 : act.id,
319
- });
320
- 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;
321
- count++;
322
- totalCount++;
323
- console.log(`[${count}/${activities.length}/${totalCount}]\t${act === null || act === void 0 ? void 0 : act.id} ${isDeleted ? symbol_done : symbol_fail}`);
324
- // Avoiding rate-limit
325
- yield sleep(rate_limit_time_ms);
326
- }
327
- }
328
- }
329
- }
330
- else {
272
+ const activities = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.activities;
273
+ if (!activities) {
331
274
  // In case of an unexpected null response, exit the loop
332
275
  console.log(`\nProbably deleted all the activities of this type.`);
333
276
  hasMoreActivities = false;
334
277
  }
278
+ else if (activities.length === 0) {
279
+ console.log(`\nNo more activities available.`);
280
+ hasMoreActivities = false;
281
+ }
282
+ else {
283
+ totalCount = yield deleteActivities(activities, totalCount);
284
+ }
335
285
  }
336
286
  }
337
287
  catch (error) {
@@ -597,15 +547,19 @@ Statistics (Manga):
597
547
  }
598
548
  });
599
549
  }
600
- static LikeGlobal() {
550
+ static LikeGlobal(count) {
601
551
  return __awaiter(this, void 0, void 0, function* () {
602
552
  var _a, _b, _c, _d, _e, _f;
553
+ const MAX_GLOBAL_LIKES = 999;
554
+ const normalized = Number.isFinite(count) ? Math.floor(count) : 0;
555
+ const limit = normalized > 0 ? normalized : MAX_GLOBAL_LIKES;
603
556
  try {
604
557
  let page = 1;
605
558
  let hasMoreActivities = true;
606
559
  let likedCount = 0;
560
+ let successCount = 0;
607
561
  spinner.start(`Getting global activities...`);
608
- while (hasMoreActivities) {
562
+ while (hasMoreActivities && successCount < limit) {
609
563
  const activities = yield fetcher(globalActivitiesQuery, {
610
564
  page,
611
565
  perPage: 50,
@@ -614,25 +568,33 @@ Statistics (Manga):
614
568
  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;
615
569
  spinner.success(`Got ${activiti.length} activities...`);
616
570
  for (let activ of activiti) {
571
+ // Stop as soon as the limit is reached
572
+ if (successCount >= limit)
573
+ break;
617
574
  const result = yield Auth.attemptLikeActivity(activ);
618
575
  if (result === 'liked' || result === 'failed') {
619
576
  likedCount++;
577
+ if (result === 'liked')
578
+ successCount++;
620
579
  responsiveOutput(`${result === 'liked' ? symbol_done : symbol_fail} ${activityBy(activ, likedCount)}`);
621
580
  }
622
581
  else if (result === 'skipped') {
623
582
  responsiveOutput(`${symbol_neutral} ${activityBy(activ, likedCount)}`);
624
583
  }
625
- // avoiding rate-limit
584
+ if (successCount >= limit)
585
+ break;
626
586
  yield sleep(rate_limit_time_ms);
627
587
  }
628
588
  page++;
629
589
  }
630
590
  else {
631
- // No more activities to like
632
591
  spinner.error(`Probably the end of activities. ${(_f = (_e = activities === null || activities === void 0 ? void 0 : activities.data) === null || _e === void 0 ? void 0 : _e.Page) === null || _f === void 0 ? void 0 : _f.activities}`);
633
592
  hasMoreActivities = false;
634
593
  }
635
594
  }
595
+ if (successCount >= limit) {
596
+ spinner.success(`Reached the limit of ${limit} likes.`);
597
+ }
636
598
  }
637
599
  catch (error) {
638
600
  console.error(`\nError from likeFollowing. ${error.message}`);
@@ -796,50 +758,58 @@ Statistics (Manga):
796
758
  }
797
759
  });
798
760
  }
799
- static AutoLike() {
761
+ static AutoLike(option, passed_count) {
800
762
  return __awaiter(this, void 0, void 0, function* () {
801
763
  try {
802
764
  if (!(yield Auth.isLoggedIn())) {
803
765
  console.error(`\nPlease login to use this feature.`);
804
766
  return;
805
767
  }
806
- const { activityType } = yield inquirer.prompt([
807
- {
808
- type: 'list',
809
- name: 'activityType',
810
- message: 'Select activity type:',
811
- choices: [
812
- { name: 'Following • v1', value: 1 },
813
- { name: 'Following • v2', value: 2 },
814
- { name: 'Global', value: 3 },
815
- { name: 'Specific User', value: 4 },
816
- ],
817
- pageSize: 10,
818
- },
819
- ]);
820
- switch (activityType) {
768
+ let final_option = option;
769
+ if (!(final_option > 0 && final_option <= 4)) {
770
+ const { activityType } = yield inquirer.prompt([
771
+ {
772
+ type: 'list',
773
+ name: 'activityType',
774
+ message: 'Select activity type:',
775
+ choices: [
776
+ { name: 'Following • v1', value: 1 },
777
+ { name: 'Following • v2', value: 2 },
778
+ { name: 'Global', value: 3 },
779
+ { name: 'Specific User', value: 4 },
780
+ ],
781
+ pageSize: 10,
782
+ },
783
+ ]);
784
+ final_option = activityType;
785
+ }
786
+ switch (final_option) {
821
787
  case 1:
822
788
  yield this.LikeFollowing();
823
789
  break;
824
790
  case 2: {
825
- const { count } = yield inquirer.prompt([
826
- {
827
- type: 'number',
828
- name: 'count',
829
- message: 'Likes to give:',
830
- },
831
- ]);
832
- yield this.LikeFollowingActivityV2(count);
791
+ let final_count = passed_count;
792
+ if (final_count === 0) {
793
+ const { count } = yield inquirer.prompt([
794
+ {
795
+ type: 'number',
796
+ name: 'count',
797
+ message: 'Likes to give:',
798
+ },
799
+ ]);
800
+ final_count = count;
801
+ }
802
+ yield this.LikeFollowingActivityV2(final_count);
833
803
  break;
834
804
  }
835
805
  case 3:
836
- yield this.LikeGlobal();
806
+ yield this.LikeGlobal(passed_count);
837
807
  break;
838
808
  case 4:
839
809
  yield this.LikeSpecificUser();
840
810
  break;
841
811
  default:
842
- console.error(`\nInvalid choice. (${activityType})`);
812
+ console.error(`\nInvalid choice. (${final_option})`);
843
813
  }
844
814
  }
845
815
  catch (error) {
@@ -1,13 +1,9 @@
1
1
  /**
2
2
  * Sends a GraphQL request to the AniList API.
3
3
  *
4
- * This function constructs a request with the provided query and variables,
5
- * handles authorization, and processes the API response. If a rate-limit error (429) is returned,
6
- * it waits for 1 minute and retries the request.
7
- *
8
- * @param {string} query - The AniList GraphQL query to be executed.
9
- * @param {object} variables - An object containing the variables for the query.
10
- * @returns {Promise<object|null>} The response from the API as a JSON object if successful; otherwise, null.
4
+ * @param query - The GraphQL query to execute.
5
+ * @param variables - Variables for the GraphQL query.
6
+ * @returns The API response if successful; otherwise, null.
11
7
  */
12
- declare function fetcher(query: string, variables: object): Promise<object | null>;
8
+ declare function fetcher<T = Record<string, unknown>>(query: string, variables: object): Promise<T | null>;
13
9
  export { fetcher };
@@ -13,13 +13,9 @@ import { aniListEndpoint, handleRateLimitRetry } from './workers.js';
13
13
  /**
14
14
  * Sends a GraphQL request to the AniList API.
15
15
  *
16
- * This function constructs a request with the provided query and variables,
17
- * handles authorization, and processes the API response. If a rate-limit error (429) is returned,
18
- * it waits for 1 minute and retries the request.
19
- *
20
- * @param {string} query - The AniList GraphQL query to be executed.
21
- * @param {object} variables - An object containing the variables for the query.
22
- * @returns {Promise<object|null>} The response from the API as a JSON object if successful; otherwise, null.
16
+ * @param query - The GraphQL query to execute.
17
+ * @param variables - Variables for the GraphQL query.
18
+ * @returns The API response if successful; otherwise, null.
23
19
  */
24
20
  function fetcher(query, variables) {
25
21
  return __awaiter(this, void 0, void 0, function* () {
@@ -35,24 +31,22 @@ function fetcher(query, variables) {
35
31
  headers['Authorization'] = `Bearer ${token}`;
36
32
  const request = yield fetch(aniListEndpoint, {
37
33
  method: 'POST',
38
- headers: headers,
34
+ headers,
39
35
  body: JSON.stringify({ query, variables }),
40
36
  });
41
- const response = yield request.json();
37
+ const response = (yield request.json());
42
38
  if (request.status === 200) {
43
39
  return response;
44
40
  }
45
- else if (request.status === 429) {
41
+ if (request.status === 429) {
46
42
  yield handleRateLimitRetry(60);
47
- return yield fetcher(query, variables);
48
- }
49
- else {
50
- console.error(`\n${request.status} ${((_b = (_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) || 'Unknown error'}.`);
51
- return null;
43
+ return fetcher(query, variables);
52
44
  }
45
+ console.error(`\n${request.status} ${((_b = (_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) || 'Unknown error'}.`);
46
+ return null;
53
47
  }
54
48
  catch (error) {
55
- console.error(`\nSomething went wrong. ${error.message}.`);
49
+ console.error(`\nSomething went wrong. ${error instanceof Error ? error.message : String(error)}.`);
56
50
  return null;
57
51
  }
58
52
  });
@@ -4,5 +4,6 @@ declare class colorize {
4
4
  static Yellow(txt: string): string;
5
5
  static BgGreen(txt: string): string;
6
6
  static BgRed(txt: string): string;
7
+ static Metal(txt: string): string;
7
8
  }
8
9
  export { colorize };
@@ -15,5 +15,8 @@ class colorize {
15
15
  static BgRed(txt) {
16
16
  return String(chalk.bgRed(txt));
17
17
  }
18
+ static Metal(txt) {
19
+ return String(chalk.hex('#343A40')(txt));
20
+ }
18
21
  }
19
22
  export { colorize };
@@ -0,0 +1,2 @@
1
+ import { User } from '../types.js';
2
+ export declare function renderUserProfile(user: User, followersCount: number, followingCount: number): void;
@@ -0,0 +1,35 @@
1
+ import Table from 'cli-table3';
2
+ export function renderUserProfile(user, followersCount, followingCount) {
3
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
4
+ const table = new Table({
5
+ chars: {
6
+ 'top': '',
7
+ 'top-mid': '',
8
+ 'top-left': '',
9
+ 'top-right': '',
10
+ 'bottom': '',
11
+ 'bottom-mid': '',
12
+ 'bottom-left': '',
13
+ 'bottom-right': '',
14
+ 'left': '',
15
+ 'left-mid': '',
16
+ 'mid': '',
17
+ 'mid-mid': '',
18
+ 'right': '',
19
+ 'right-mid': '',
20
+ 'middle': '',
21
+ },
22
+ style: {
23
+ 'padding-left': 0,
24
+ 'padding-right': 0,
25
+ 'head': [],
26
+ 'border': [],
27
+ },
28
+ });
29
+ const row = (label, value) => [
30
+ label.padEnd(30),
31
+ String(value !== null && value !== void 0 ? value : 'null'),
32
+ ];
33
+ table.push(row('ID:', user.id), row('Name:', user.name), row('siteUrl:', user.siteUrl), row('profileColor:', (_a = user.options) === null || _a === void 0 ? void 0 : _a.profileColor), row('timeZone:', (_b = user.options) === null || _b === void 0 ? void 0 : _b.timezone), row('activityMergeTime:', (_c = user.options) === null || _c === void 0 ? void 0 : _c.activityMergeTime), row('donatorTier:', user.donatorTier), row('donatorBadge:', user.donatorBadge), row('unreadNotificationCount:', user.unreadNotificationCount), row('Account Created:', new Date(user.createdAt * 1000).toUTCString()), row('Account Updated:', new Date(user.updatedAt * 1000).toUTCString()), ['', ''], row('Followers:', followersCount), row('Following:', followingCount), ['', ''], ['Statistics (Anime):', ''], row(' Count:', (_e = (_d = user.statistics) === null || _d === void 0 ? void 0 : _d.anime) === null || _e === void 0 ? void 0 : _e.count), row(' Mean Score:', (_g = (_f = user.statistics) === null || _f === void 0 ? void 0 : _f.anime) === null || _g === void 0 ? void 0 : _g.meanScore), row(' Minutes Watched:', (_j = (_h = user.statistics) === null || _h === void 0 ? void 0 : _h.anime) === null || _j === void 0 ? void 0 : _j.minutesWatched), row(' Episodes Watched:', (_l = (_k = user.statistics) === null || _k === void 0 ? void 0 : _k.anime) === null || _l === void 0 ? void 0 : _l.episodesWatched), ['', ''], ['Statistics (Manga):', ''], row(' Count:', (_o = (_m = user.statistics) === null || _m === void 0 ? void 0 : _m.manga) === null || _o === void 0 ? void 0 : _o.count), row(' Mean Score:', (_q = (_p = user.statistics) === null || _p === void 0 ? void 0 : _p.manga) === null || _q === void 0 ? void 0 : _q.meanScore), row(' Chapters Read:', (_s = (_r = user.statistics) === null || _r === void 0 ? void 0 : _r.manga) === null || _s === void 0 ? void 0 : _s.chaptersRead), row(' Volumes Read:', (_u = (_t = user.statistics) === null || _t === void 0 ? void 0 : _t.manga) === null || _u === void 0 ? void 0 : _u.volumesRead));
34
+ console.log(`\n${table.toString()}`);
35
+ }
@@ -19,7 +19,7 @@ import { animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserM
19
19
  import { responsiveOutput } from './truncate.js';
20
20
  import { AniListMediaStatus, } from './types.js';
21
21
  import { Validate } from './validation.js';
22
- import { anidbToanilistMapper, formatDateObject, getDownloadFolderPath, getNextSeasonAndYear, getTitle, logUserDetails, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, saveJSONasXML, selectFile, simpleDateFormat, timestampToTimeAgo, } from './workers.js';
22
+ import { formatDateObject, getDownloadFolderPath, getNextSeasonAndYear, getTitle, logUserDetails, processAnimeList, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, saveJSONasXML, selectFile, simpleDateFormat, timestampToTimeAgo, } from './workers.js';
23
23
  class AniList {
24
24
  /**
25
25
  * Prompt the user for a list status (Planning/Watching-Reading/Completed/Paused/Dropped)
@@ -675,7 +675,6 @@ class MyAnimeList {
675
675
  class AniDB {
676
676
  static importAnime() {
677
677
  return __awaiter(this, void 0, void 0, function* () {
678
- var _a, _b;
679
678
  try {
680
679
  const filename = yield selectFile('.json');
681
680
  if (!filename) {
@@ -688,76 +687,17 @@ class AniDB {
688
687
  console.error(`\nInvalid JSON Large file.`);
689
688
  return;
690
689
  }
691
- if (js0n_repaired) {
692
- const obj3ct = yield JSON.parse(js0n_repaired);
693
- const animeList = obj3ct === null || obj3ct === void 0 ? void 0 : obj3ct.anime;
694
- if ((animeList === null || animeList === void 0 ? void 0 : animeList.length) > 0) {
695
- let count = 0;
696
- let iteration = 0;
697
- let missed = [];
698
- for (const anime of animeList) {
699
- iteration++;
700
- const anidbId = anime.id;
701
- const released = anime.broadcastDate; // DD-MM-YYYY (eg: "23.07.2016")
702
- const status = anime.status;
703
- // const type = anime.type
704
- const totalEpisodes = anime.totalEpisodes;
705
- const ownEpisodes = anime.ownEpisodes;
706
- const romanjiName = anime.romanjiName;
707
- const englishName = anime.englishName;
708
- function getStatus(anidbStatus, episodesSeen) {
709
- if (anidbStatus === 'complete') {
710
- return AniListMediaStatus.COMPLETED;
711
- }
712
- else if (anidbStatus === 'incomplete' &&
713
- Number(episodesSeen) > 0) {
714
- return AniListMediaStatus.CURRENT;
715
- }
716
- else {
717
- return AniListMediaStatus.PLANNING;
718
- }
719
- }
720
- let anilistId = yield anidbToanilistMapper(romanjiName, Number(released.split('.')[2]), englishName);
721
- if (anilistId) {
722
- try {
723
- const saveResponse = yield fetcher(saveAnimeWithProgressMutation, {
724
- mediaId: anilistId,
725
- progress: ownEpisodes - 2,
726
- status: getStatus(status, ownEpisodes),
727
- hiddenFromStatusLists: false,
728
- private: false,
729
- });
730
- const entryId = (_b = (_a = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _a === void 0 ? void 0 : _a.SaveMediaListEntry) === null || _b === void 0 ? void 0 : _b.id;
731
- if (entryId) {
732
- count++;
733
- responsiveOutput(`[${count}]\t${entryId} ✅\t${anidbId}\t${anilistId}\t(${ownEpisodes}/${totalEpisodes})\t${status}–>${getStatus(status, ownEpisodes)}`);
734
- }
735
- }
736
- catch (error) {
737
- console.error(`Error processing AniDB ID ${anidbId}: ${error.message}`);
738
- }
739
- }
740
- else {
741
- missed.push({
742
- anidbId: anidbId,
743
- englishTitle: englishName,
744
- romajiTitle: romanjiName,
745
- });
746
- }
747
- }
748
- responsiveOutput(`\nAccuracy: ${(((animeList.length - missed.length) / animeList.length) * 100).toFixed(2)}%\tTotal Processed: ${iteration}\tMissed: ${missed.length}`);
749
- if (missed.length > 0) {
750
- responsiveOutput(`Exporting missed entries to JSON file, Please add them manually.`);
751
- yield saveJSONasJSON(missed, 'anidb-missed');
752
- }
753
- }
754
- else {
755
- console.log(`\nNo anime list found in the file.`);
756
- }
757
- }
758
- else {
690
+ if (!js0n_repaired) {
759
691
  console.log(`\nNo content found in the file or unable to read.`);
692
+ return;
693
+ }
694
+ const obj3ct = yield JSON.parse(js0n_repaired);
695
+ const animeList = obj3ct === null || obj3ct === void 0 ? void 0 : obj3ct.anime;
696
+ if (!((animeList === null || animeList === void 0 ? void 0 : animeList.length) > 0)) {
697
+ console.log(`\nNo anime list found in the file.`);
698
+ return;
760
699
  }
700
+ yield processAnimeList(animeList);
761
701
  }
762
702
  catch (error) {
763
703
  console.error(`\nError in AniDB import process: ${error.message}`);
@@ -399,4 +399,29 @@ type MangaDetails = {
399
399
  };
400
400
  errors?: Error;
401
401
  };
402
+ export type DeleteActivityResponse = {
403
+ data?: {
404
+ DeleteActivity: {
405
+ deleted: boolean;
406
+ };
407
+ };
408
+ errors?: {
409
+ message: string;
410
+ }[];
411
+ };
412
+ export type MissedEntry = {
413
+ anidbId: number;
414
+ englishTitle?: string;
415
+ romajiTitle?: string;
416
+ };
417
+ export type EntryResult = 'saved' | 'skipped' | 'missed';
418
+ export type AniDBAnimeEntry = {
419
+ id: number;
420
+ broadcastDate: string;
421
+ status: string;
422
+ totalEpisodes: number | string;
423
+ ownEpisodes: number | string;
424
+ romanjiName: string;
425
+ englishName?: string;
426
+ };
402
427
  export { Activity, AniListMediaStatus, AnimeDetails, AnimeList, AnimeSearchResponse, DateMonthYear, DeleteMangaResponse, DeleteMediaListResponse, LikeActivityResponse, List, MALAnimeStatus, MALAnimeXML, MALMangaStatus, MalIdToAnilistIdResponse, MangaDetails, MediaEntry, MediaList, MediaListCollectionResponse, MediaListEntry, MediaTitle, MediaWithProgress, Myself, SaveMediaListEntryResponse, SaveTextActivityResponse, SpecificUserActivitiesResponse, TheActivity, ToggleFollowResponse, User, UserActivitiesResponse, UserFollower, UserFollowing, UserResponse, saveAnimeWithProgressResponse, };
@@ -1,4 +1,4 @@
1
- import { DateMonthYear, MALAnimeStatus, MALMangaStatus, MediaWithProgress, TheActivity, User } from './types.js';
1
+ import { Activity, AniDBAnimeEntry, DateMonthYear, MALAnimeStatus, MALMangaStatus, MediaWithProgress, TheActivity, User } 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: {
@@ -50,4 +50,30 @@ declare function simpleDateFormat(date: DateMonthYear): string;
50
50
  declare function sleep(ms: number): Promise<void>;
51
51
  declare function handleRateLimitRetry(retryCount: number): Promise<void>;
52
52
  declare function logUserDetails(user: User, followersCount: number, followingCount: number): void;
53
+ /**
54
+ * Dispatch to exactly one handler out of a set of mutually-exclusive options
55
+ * (eg: --anime/--manga, --follow/--unfollow/--inactive), optionally requiring login.
56
+ */
57
+ export declare function dispatchOneOf(options: {
58
+ flag: boolean;
59
+ name: string;
60
+ handler: () => Promise<unknown>;
61
+ }[], { requireLogin }?: {
62
+ requireLogin?: boolean;
63
+ }): Promise<void>;
64
+ /**
65
+ * Deletes a single activity and returns whether the API reported it as deleted.
66
+ */
67
+ export declare function deleteActivity(id: number): Promise<boolean>;
68
+ /**
69
+ * Deletes every activity in the page (skipping entries without an id),
70
+ * logging progress and respecting the rate limit.
71
+ * Returns the updated running total.
72
+ */
73
+ export declare function deleteActivities(activities: Activity[], totalCount: number): Promise<number>;
74
+ /**
75
+ * Processes the whole anime list, prints the summary,
76
+ * and exports unmapped entries to JSON.
77
+ */
78
+ export declare function processAnimeList(animeList: AniDBAnimeEntry[]): Promise<void>;
53
79
  export { activityBy, anidbToanilistMapper, aniListEndpoint, createAnimeListXML, createAnimeXML, createMangaListXML, createMangaXML, formatDateObject, getCurrentPackageVersion, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, handleRateLimitRetry, logUserDetails, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, saveJSONasXML, saveToPath, selectFile, simpleDateFormat, sleep, timestampToTimeAgo, };
@@ -30,8 +30,12 @@ import process from 'process';
30
30
  import Spinner from 'tiny-spinner';
31
31
  import { Auth } from './auth.js';
32
32
  import { fetcher } from './fetcher.js';
33
+ import { colorize } from './lib/colorize.js';
34
+ import { rate_limit_time_ms, symbol_done, symbol_fail, } from './lib/constants.js';
35
+ import { deleteActivityMutation, saveAnimeWithProgressMutation, } from './mutations.js';
33
36
  import { animeSearchQuery } from './queries.js';
34
- import { MALAnimeStatus, MALMangaStatus, } from './types.js';
37
+ import { responsiveOutput } from './truncate.js';
38
+ import { AniListMediaStatus, MALAnimeStatus, MALMangaStatus, } from './types.js';
35
39
  const aniListEndpoint = `https://graphql.anilist.co`;
36
40
  const redirectUri = 'https://anilist.co/api/v2/oauth/pin';
37
41
  const spinner = new Spinner();
@@ -386,14 +390,14 @@ function activityBy(activity, count) {
386
390
  var _a, _b, _c, _d;
387
391
  const countStr = `[${count ? count : '?'}]`.padEnd(6);
388
392
  if ((_a = activity === null || activity === void 0 ? void 0 : activity.messenger) === null || _a === void 0 ? void 0 : _a.name) {
389
- return `${countStr}${activity.messenger.name} >> messaged ${activity.recipient.name}`;
393
+ return `${countStr}${activity.messenger.name} ${colorize.Metal('>>')} messaged ${activity.recipient.name}`;
390
394
  }
391
395
  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) {
392
396
  if (activity.progress) {
393
- return `${countStr}${activity.user.name} >> ${activity.status} ${activity.progress} of ${activity.media.title.userPreferred}`;
397
+ return `${countStr}${activity.user.name} ${colorize.Metal('>>')} ${activity.status} ${activity.progress} of ${activity.media.title.userPreferred}`;
394
398
  }
395
399
  else {
396
- return `${countStr}${activity.user.name} >> ${activity.status} ${activity.media.title.userPreferred}`;
400
+ return `${countStr}${activity.user.name} ${colorize.Metal('>>')} ${activity.status} ${activity.media.title.userPreferred}`;
397
401
  }
398
402
  }
399
403
  else if ((_d = activity === null || activity === void 0 ? void 0 : activity.user) === null || _d === void 0 ? void 0 : _d.name) {
@@ -476,4 +480,135 @@ function logUserDetails(user, followersCount, followingCount) {
476
480
  'Volumes Read': ((_p = (_o = user.statistics) === null || _o === void 0 ? void 0 : _o.manga) === null || _p === void 0 ? void 0 : _p.volumesRead) || 0,
477
481
  });
478
482
  }
483
+ /**
484
+ * Dispatch to exactly one handler out of a set of mutually-exclusive options
485
+ * (eg: --anime/--manga, --follow/--unfollow/--inactive), optionally requiring login.
486
+ */
487
+ export function dispatchOneOf(options_1) {
488
+ return __awaiter(this, arguments, void 0, function* (options, { requireLogin = false } = {}) {
489
+ const selected = options.filter(({ flag }) => flag);
490
+ if (selected.length !== 1) {
491
+ const names = options.map(({ name }) => `--${name}`);
492
+ const optionList = names.length <= 2
493
+ ? names.join(' or ')
494
+ : `${names.slice(0, -1).join(', ')} or ${names[names.length - 1]}`;
495
+ console.error(`\nMust select an option, either ${optionList}`);
496
+ return;
497
+ }
498
+ if (requireLogin && !(yield Auth.isLoggedIn())) {
499
+ console.error(`\nPlease login to use this feature.`);
500
+ return;
501
+ }
502
+ yield selected[0].handler();
503
+ });
504
+ }
505
+ /**
506
+ * Deletes a single activity and returns whether the API reported it as deleted.
507
+ */
508
+ export function deleteActivity(id) {
509
+ return __awaiter(this, void 0, void 0, function* () {
510
+ var _a, _b;
511
+ const deleteResponse = yield fetcher(deleteActivityMutation, { id });
512
+ return Boolean((_b = (_a = deleteResponse === null || deleteResponse === void 0 ? void 0 : deleteResponse.data) === null || _a === void 0 ? void 0 : _a.DeleteActivity) === null || _b === void 0 ? void 0 : _b.deleted);
513
+ });
514
+ }
515
+ /**
516
+ * Deletes every activity in the page (skipping entries without an id),
517
+ * logging progress and respecting the rate limit.
518
+ * Returns the updated running total.
519
+ */
520
+ export function deleteActivities(activities, totalCount) {
521
+ return __awaiter(this, void 0, void 0, function* () {
522
+ let count = 0;
523
+ for (const act of activities) {
524
+ if (!(act === null || act === void 0 ? void 0 : act.id))
525
+ continue;
526
+ const isDeleted = yield deleteActivity(act.id);
527
+ count++;
528
+ totalCount++;
529
+ console.log(`[${count}/${activities.length}/${totalCount}]\t${act.id} ${isDeleted ? symbol_done : symbol_fail}`);
530
+ // Avoiding rate-limit
531
+ yield sleep(rate_limit_time_ms);
532
+ }
533
+ return totalCount;
534
+ });
535
+ }
536
+ function getStatus(anidbStatus, episodesSeen) {
537
+ if (anidbStatus === 'complete') {
538
+ return AniListMediaStatus.COMPLETED;
539
+ }
540
+ else if (anidbStatus === 'incomplete' && Number(episodesSeen) > 0) {
541
+ return AniListMediaStatus.CURRENT;
542
+ }
543
+ else {
544
+ return AniListMediaStatus.PLANNING;
545
+ }
546
+ }
547
+ /**
548
+ * Maps a single AniDB entry to AniList and saves it.
549
+ * `nextCount` is the running success counter value to display if the save succeeds.
550
+ * Pushes unmapped entries into `missed`.
551
+ */
552
+ function processAnimeEntry(anime, nextCount, missed) {
553
+ return __awaiter(this, void 0, void 0, function* () {
554
+ var _a, _b;
555
+ const anidbId = anime.id;
556
+ const released = anime.broadcastDate; // DD-MM-YYYY (eg: "23.07.2016")
557
+ const status = anime.status;
558
+ // const type = anime.type
559
+ const totalEpisodes = anime.totalEpisodes;
560
+ const ownEpisodes = anime.ownEpisodes;
561
+ const romanjiName = anime.romanjiName;
562
+ const englishName = anime.englishName;
563
+ const anilistId = yield anidbToanilistMapper(romanjiName, Number(released.split('.')[2]), englishName);
564
+ if (!anilistId) {
565
+ missed.push({
566
+ anidbId: anidbId,
567
+ englishTitle: englishName,
568
+ romajiTitle: romanjiName,
569
+ });
570
+ return 'missed';
571
+ }
572
+ try {
573
+ const saveResponse = yield fetcher(saveAnimeWithProgressMutation, {
574
+ mediaId: anilistId,
575
+ progress: Number(ownEpisodes) - 2,
576
+ status: getStatus(status, ownEpisodes),
577
+ hiddenFromStatusLists: false,
578
+ private: false,
579
+ });
580
+ const entryId = (_b = (_a = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _a === void 0 ? void 0 : _a.SaveMediaListEntry) === null || _b === void 0 ? void 0 : _b.id;
581
+ if (!entryId)
582
+ return 'skipped';
583
+ responsiveOutput(`[${nextCount}]\t${entryId} ✅\t${anidbId}\t${anilistId}\t(${ownEpisodes}/${totalEpisodes})\t${status}–>${getStatus(status, ownEpisodes)}`);
584
+ return 'saved';
585
+ }
586
+ catch (error) {
587
+ console.error(`Error processing AniDB ID ${anidbId}: ${error.message}`);
588
+ return 'skipped';
589
+ }
590
+ });
591
+ }
592
+ /**
593
+ * Processes the whole anime list, prints the summary,
594
+ * and exports unmapped entries to JSON.
595
+ */
596
+ export function processAnimeList(animeList) {
597
+ return __awaiter(this, void 0, void 0, function* () {
598
+ let count = 0;
599
+ let iteration = 0;
600
+ const missed = [];
601
+ for (const anime of animeList) {
602
+ iteration++;
603
+ const result = yield processAnimeEntry(anime, count + 1, missed);
604
+ if (result === 'saved')
605
+ count++;
606
+ }
607
+ responsiveOutput(`\nAccuracy: ${(((animeList.length - missed.length) / animeList.length) * 100).toFixed(2)}%\tTotal Processed: ${iteration}\tMissed: ${missed.length}`);
608
+ if (missed.length > 0) {
609
+ responsiveOutput(`Exporting missed entries to JSON file, Please add them manually.`);
610
+ yield saveJSONasJSON(missed, 'anidb-missed');
611
+ }
612
+ });
613
+ }
479
614
  export { activityBy, anidbToanilistMapper, aniListEndpoint, createAnimeListXML, createAnimeXML, createMangaListXML, createMangaXML, formatDateObject, getCurrentPackageVersion, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, handleRateLimitRetry, logUserDetails, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, saveJSONasXML, saveToPath, selectFile, simpleDateFormat, sleep, timestampToTimeAgo, };
package/bin/index.js CHANGED
@@ -12,30 +12,8 @@ import { Command } from 'commander';
12
12
  import process from 'process';
13
13
  import { Auth, Social } from './helpers/auth.js';
14
14
  import { AniList } from './helpers/lists.js';
15
- import { getCurrentPackageVersion } from './helpers/workers.js';
15
+ import { dispatchOneOf, getCurrentPackageVersion } from './helpers/workers.js';
16
16
  const cli = new Command();
17
- /**
18
- * Dispatch to exactly one handler out of a set of mutually-exclusive options
19
- * (eg: --anime/--manga, --follow/--unfollow/--inactive), optionally requiring login.
20
- */
21
- function dispatchOneOf(options_1) {
22
- return __awaiter(this, arguments, void 0, function* (options, { requireLogin = false } = {}) {
23
- const selected = options.filter(({ flag }) => flag);
24
- if (selected.length !== 1) {
25
- const names = options.map(({ name }) => `--${name}`);
26
- const optionList = names.length <= 2
27
- ? names.join(' or ')
28
- : `${names.slice(0, -1).join(', ')} or ${names[names.length - 1]}`;
29
- console.error(`\nMust select an option, either ${optionList}`);
30
- return;
31
- }
32
- if (requireLogin && !(yield Auth.isLoggedIn())) {
33
- console.error(`\nPlease login to use this feature.`);
34
- return;
35
- }
36
- yield selected[0].handler();
37
- });
38
- }
39
17
  cli
40
18
  .name('anilist')
41
19
  .description('Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts.')
@@ -210,8 +188,10 @@ cli
210
188
  .command('autolike')
211
189
  .alias('al')
212
190
  .description('Autolike following or global activities.')
213
- .action(() => __awaiter(void 0, void 0, void 0, function* () {
214
- yield Auth.AutoLike();
191
+ .option('-o, --option <number>', 'Option number in asc order', '0')
192
+ .option('-c, --count <number>', 'How many likes to give', '0')
193
+ .action((_a) => __awaiter(void 0, [_a], void 0, function* ({ option, count }) {
194
+ yield Auth.AutoLike(Number(option), Number(count));
215
195
  }));
216
196
  cli
217
197
  .command('social')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@irfanshadikrishad/anilist",
3
3
  "description": "Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts",
4
- "version": "3.0.0-forbidden.0",
4
+ "version": "3.1.0-forbidden.0",
5
5
  "author": "Irfan Shadik Rishad",
6
6
  "license": "MPL-2.0",
7
7
  "scripts": {
@@ -56,23 +56,28 @@
56
56
  "bin": {
57
57
  "anilist": "./bin/index.js"
58
58
  },
59
+ "allowScripts": {
60
+ "@parcel/watcher@2.6.0": true
61
+ },
59
62
  "prettier": "@irfanshadikrishad/prettier",
60
63
  "dependencies": {
61
64
  "@irfanshadikrishad/cipher": "^1.7.2",
62
- "chalk": "^5.6.2",
63
- "cli-truncate": "^4.0.0",
65
+ "@irfanshadikrishad/logger": "^1.0.0",
66
+ "chalk": "^6.0.1",
67
+ "cli-table3": "^0.6.5",
68
+ "cli-truncate": "^6.2.0",
64
69
  "commander": "^14.0.3",
65
70
  "fast-xml-parser": "^5.12.1",
66
71
  "inquirer": "^12.11.1",
67
72
  "jsonrepair": "^3.15.0",
68
73
  "node-fetch": "^3.3.2",
69
- "open": "^10.2.0",
74
+ "open": "^11.0.4",
70
75
  "papaparse": "^5.7.1",
71
76
  "tiny-spinner": "^2.0.5",
72
77
  "xml2js": "^0.6.2"
73
78
  },
74
79
  "devDependencies": {
75
- "@babel/preset-env": "^7.29.14",
80
+ "@babel/preset-env": "^7.29.17",
76
81
  "@eslint/js": "^9.39.5",
77
82
  "@irfanshadikrishad/prettier": "^1.3.9",
78
83
  "@types/jest": "^30.0.0",
@@ -81,11 +86,11 @@
81
86
  "@types/xml2js": "^0.4.14",
82
87
  "@typescript-eslint/eslint-plugin": "^8.74.0",
83
88
  "eslint": "^9.39.5",
84
- "globals": "^16.5.0",
89
+ "globals": "^17.15.0",
85
90
  "husky": "^9.1.7",
86
91
  "jest": "^30.5.2",
87
- "lint-staged": "^17.6.2",
88
- "prettier": "^3.10.1",
92
+ "lint-staged": "^17.6.3",
93
+ "prettier": "^3.10.2",
89
94
  "prettier-plugin-organize-imports": "^4.3.0",
90
95
  "ts-jest": "^29.4.15",
91
96
  "ts-node": "^10.9.2",
@@ -1,3 +0,0 @@
1
- {
2
- "outputStyle": "default"
3
- }