@irfanshadikrishad/anilist 1.9.6 → 1.9.8
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/.husky/pre-commit +3 -0
- package/README.md +17 -6
- package/bin/helpers/auth.d.ts +4 -4
- package/bin/helpers/auth.js +82 -45
- package/bin/helpers/fetcher.d.ts +2 -2
- package/bin/helpers/fetcher.js +6 -7
- package/bin/helpers/lists.js +53 -49
- package/bin/helpers/validation.d.ts +4 -4
- package/bin/helpers/validation.js +50 -53
- package/bin/helpers/workers.d.ts +5 -5
- package/bin/helpers/workers.js +5 -5
- package/bin/index.js +4 -4
- package/package.json +24 -24
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ anilist login -i <client-id> -s <client-secret>
|
|
|
60
60
|
| `anime` | `<anime-id>` | Get anime details by Anime Id |
|
|
61
61
|
| `manga` | `<manga-id>` | Get manga details by Manga ID |
|
|
62
62
|
| `search` <br> _(alias:`srch`/`find`)_ | `<query>` <br> `-a, --anime` <br> `-m, --manga` <br> `-c (default: 10)` | Get anime/manga search results |
|
|
63
|
-
| `status` <br> _(alias: `write`/`post`)_ | `<status>` | Write a status
|
|
63
|
+
| `status` <br> _(alias: `write`/`post`)_ | `<status>` | Write a status (text/markdown/html) |
|
|
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` | Follow users who follows you or Unfollow who doesn't follow you back with a simple command |
|
|
@@ -165,14 +165,14 @@ anilist ls -a
|
|
|
165
165
|
#### `delete` _(alias: `del`)_:
|
|
166
166
|
|
|
167
167
|
```bash
|
|
168
|
-
anilist del -s
|
|
168
|
+
anilist del -s
|
|
169
169
|
```
|
|
170
170
|
|
|
171
171
|
- Options:
|
|
172
172
|
- `-a, --anime`: Delete your specific anime collection that you want.
|
|
173
173
|
- `-m, --manga`: Delete your specific manga collection that you want.
|
|
174
|
-
- `-s
|
|
175
|
-
- Description: Delete the entire anime or manga collection from the logged-in user's profile.
|
|
174
|
+
- `-s, --activity`: Delete all or any type of activities you want.
|
|
175
|
+
- Description: Delete the entire anime or manga collection, or activities from the logged-in user's profile.
|
|
176
176
|
|
|
177
177
|
#### `anime`
|
|
178
178
|
|
|
@@ -191,7 +191,7 @@ anilist manga <manga-id>
|
|
|
191
191
|
```
|
|
192
192
|
|
|
193
193
|
- Options
|
|
194
|
-
- `<
|
|
194
|
+
- `<manga-id>` _(eg: 30013)_ : Id of the manga you want to get details of.
|
|
195
195
|
- Description: Get manga details by manga Id.
|
|
196
196
|
|
|
197
197
|
#### `search` _(alias: `srch`/`find`)_:
|
|
@@ -215,7 +215,7 @@ anilist write <status>
|
|
|
215
215
|
|
|
216
216
|
- Options:
|
|
217
217
|
- `<status>` : This is what you want to write, It can be HTML, Markdown and/or Text. But wrap it with quotation mark (") else it might get cut-off.
|
|
218
|
-
- Description:
|
|
218
|
+
- Description: Write a status to your AniList activity feed.
|
|
219
219
|
|
|
220
220
|
#### `export` _(alias: `exp`)_:
|
|
221
221
|
|
|
@@ -256,6 +256,17 @@ anilist sol -f
|
|
|
256
256
|
- `-u, --unfollow`: To unfollow users who doesn't follow you back.
|
|
257
257
|
- Description: It follows users who follows you or unfollow users who doesn't follow you back at ease.
|
|
258
258
|
|
|
259
|
+
#### `move` _(alias: `mv`)_:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
anilist mv -a
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
- Options:
|
|
266
|
+
- `-a, --anime`: To move anime entries between lists.
|
|
267
|
+
- `-m, --manga`: To move manga entries between lists.
|
|
268
|
+
- Description: Move all entries from one list to another (e.g. from Watching to Completed).
|
|
269
|
+
|
|
259
270
|
#### Security
|
|
260
271
|
|
|
261
272
|
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.
|
package/bin/helpers/auth.d.ts
CHANGED
|
@@ -5,13 +5,13 @@ declare class Auth {
|
|
|
5
5
|
*/
|
|
6
6
|
static GetAccessToken(): Promise<string | null>;
|
|
7
7
|
static StoreAccessToken(token: string): Promise<void>;
|
|
8
|
-
static
|
|
8
|
+
static RetrieveAccessToken(): Promise<string | null>;
|
|
9
9
|
static Login(clientId: number, clientSecret: string): Promise<void>;
|
|
10
|
-
static Myself(): Promise<User>;
|
|
10
|
+
static Myself(): Promise<User | null | undefined>;
|
|
11
11
|
static isLoggedIn(): Promise<boolean>;
|
|
12
12
|
static Logout(): Promise<void>;
|
|
13
|
-
static MyUserId(): Promise<number>;
|
|
14
|
-
static MyUserName(): Promise<string>;
|
|
13
|
+
static MyUserId(): Promise<number | null>;
|
|
14
|
+
static MyUserName(): Promise<string | null>;
|
|
15
15
|
static DeleteMyActivities(): Promise<void>;
|
|
16
16
|
static DeleteMyAnimeList(): Promise<void>;
|
|
17
17
|
static DeleteAnimeById(id: number, title?: MediaTitle): Promise<void>;
|
package/bin/helpers/auth.js
CHANGED
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { Cipher } from '@irfanshadikrishad/cipher';
|
|
11
11
|
import fs from 'fs';
|
|
12
12
|
import inquirer from 'inquirer';
|
|
13
|
-
import fetch from 'node-fetch';
|
|
14
13
|
import open from 'open';
|
|
15
14
|
import os from 'os';
|
|
16
15
|
import path from 'path';
|
|
@@ -66,7 +65,7 @@ class Auth {
|
|
|
66
65
|
}
|
|
67
66
|
});
|
|
68
67
|
}
|
|
69
|
-
static
|
|
68
|
+
static RetrieveAccessToken() {
|
|
70
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
70
|
try {
|
|
72
71
|
if (fs.existsSync(save_path)) {
|
|
@@ -77,7 +76,7 @@ class Auth {
|
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
catch (error) {
|
|
80
|
-
console.error(`\nError
|
|
79
|
+
console.error(`\nError retrieving access token. ${error.message}`);
|
|
81
80
|
return null;
|
|
82
81
|
}
|
|
83
82
|
});
|
|
@@ -125,12 +124,12 @@ class Auth {
|
|
|
125
124
|
}
|
|
126
125
|
static Myself() {
|
|
127
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
-
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;
|
|
127
|
+
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, _3, _4, _5;
|
|
129
128
|
try {
|
|
130
129
|
if (yield Auth.isLoggedIn()) {
|
|
131
130
|
const headers = {
|
|
132
131
|
'Content-Type': 'application/json',
|
|
133
|
-
'Authorization': `Bearer ${yield Auth.
|
|
132
|
+
'Authorization': `Bearer ${yield Auth.RetrieveAccessToken()}`,
|
|
134
133
|
};
|
|
135
134
|
const request = yield fetch(aniListEndpoint, {
|
|
136
135
|
method: 'POST',
|
|
@@ -165,34 +164,34 @@ activityMergeTime: ${(_l = user === null || user === void 0 ? void 0 : user
|
|
|
165
164
|
donatorTier: ${user === null || user === void 0 ? void 0 : user.donatorTier}
|
|
166
165
|
donatorBadge: ${user === null || user === void 0 ? void 0 : user.donatorBadge}
|
|
167
166
|
unreadNotificationCount:${user === null || user === void 0 ? void 0 : user.unreadNotificationCount}
|
|
168
|
-
Account Created: ${new Date((user === null || user === void 0 ? void 0 : user.createdAt) * 1000).toUTCString()}
|
|
169
|
-
Account Updated: ${new Date((user === null || user === void 0 ? void 0 : user.updatedAt) * 1000).toUTCString()}
|
|
167
|
+
Account Created: ${new Date(((_m = user === null || user === void 0 ? void 0 : user.createdAt) !== null && _m !== void 0 ? _m : 0) * 1000).toUTCString()}
|
|
168
|
+
Account Updated: ${new Date(((_o = user === null || user === void 0 ? void 0 : user.updatedAt) !== null && _o !== void 0 ? _o : 0) * 1000).toUTCString()}
|
|
170
169
|
|
|
171
170
|
Followers: ${followersCount}
|
|
172
171
|
Following: ${followingCount}
|
|
173
172
|
|
|
174
173
|
Statistics (Anime):
|
|
175
|
-
Count: ${(
|
|
176
|
-
Mean Score: ${(
|
|
177
|
-
Minutes Watched: ${(
|
|
178
|
-
Episodes Watched: ${(
|
|
174
|
+
Count: ${(_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.count}
|
|
175
|
+
Mean Score: ${(_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.meanScore}
|
|
176
|
+
Minutes 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.minutesWatched}
|
|
177
|
+
Episodes Watched: ${(_w = (_v = user === null || user === void 0 ? void 0 : user.statistics) === null || _v === void 0 ? void 0 : _v.anime) === null || _w === void 0 ? void 0 : _w.episodesWatched}
|
|
179
178
|
|
|
180
179
|
Statistics (Manga):
|
|
181
|
-
Count: ${(
|
|
182
|
-
Mean Score: ${(
|
|
183
|
-
Chapters Read: ${(
|
|
184
|
-
Volumes Read: ${(
|
|
180
|
+
Count: ${(_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.count}
|
|
181
|
+
Mean Score: ${(_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.meanScore}
|
|
182
|
+
Chapters 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.chaptersRead}
|
|
183
|
+
Volumes Read: ${(_4 = (_3 = user === null || user === void 0 ? void 0 : user.statistics) === null || _3 === void 0 ? void 0 : _3.manga) === null || _4 === void 0 ? void 0 : _4.volumesRead}
|
|
185
184
|
`);
|
|
186
185
|
console.log(`\nRecent Activities:`);
|
|
187
|
-
if (activities
|
|
188
|
-
activities.map(({ status, progress, media, createdAt }) => {
|
|
186
|
+
if (activities === null || activities === void 0 ? void 0 : activities.length) {
|
|
187
|
+
activities === null || activities === void 0 ? void 0 : activities.map(({ status, progress, media, createdAt }) => {
|
|
189
188
|
responsiveOutput(`${timestampToTimeAgo(createdAt)}\t${status} ${progress ? `${progress} of ` : ''}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
|
|
190
189
|
});
|
|
191
190
|
}
|
|
192
191
|
return user;
|
|
193
192
|
}
|
|
194
193
|
else {
|
|
195
|
-
console.error(`\nSomething went wrong. Please log in again. ${errors[0].message}`);
|
|
194
|
+
console.error(`\nSomething went wrong. Please log in again. ${(_5 = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _5 === void 0 ? void 0 : _5.message}`);
|
|
196
195
|
return null;
|
|
197
196
|
}
|
|
198
197
|
}
|
|
@@ -209,7 +208,7 @@ Statistics (Manga):
|
|
|
209
208
|
static isLoggedIn() {
|
|
210
209
|
return __awaiter(this, void 0, void 0, function* () {
|
|
211
210
|
try {
|
|
212
|
-
const token = yield Auth.
|
|
211
|
+
const token = yield Auth.RetrieveAccessToken();
|
|
213
212
|
return token !== null;
|
|
214
213
|
}
|
|
215
214
|
catch (error) {
|
|
@@ -242,24 +241,24 @@ Statistics (Manga):
|
|
|
242
241
|
}
|
|
243
242
|
static MyUserId() {
|
|
244
243
|
return __awaiter(this, void 0, void 0, function* () {
|
|
245
|
-
var _a, _b;
|
|
244
|
+
var _a, _b, _c;
|
|
246
245
|
if (!(yield Auth.isLoggedIn())) {
|
|
247
246
|
console.warn(`\nUser not logged in.`);
|
|
248
247
|
return null;
|
|
249
248
|
}
|
|
250
|
-
const
|
|
251
|
-
return (_b = (_a =
|
|
249
|
+
const response = yield fetcher(currentUserQuery, {});
|
|
250
|
+
return (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.Viewer) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : null;
|
|
252
251
|
});
|
|
253
252
|
}
|
|
254
253
|
static MyUserName() {
|
|
255
254
|
return __awaiter(this, void 0, void 0, function* () {
|
|
256
|
-
var _a, _b;
|
|
255
|
+
var _a, _b, _c;
|
|
257
256
|
if (!(yield Auth.isLoggedIn())) {
|
|
258
257
|
console.log(`\nUser not logged in.`);
|
|
259
258
|
return null;
|
|
260
259
|
}
|
|
261
|
-
const
|
|
262
|
-
return (_b = (_a =
|
|
260
|
+
const response = yield fetcher(currentUserQuery, {});
|
|
261
|
+
return (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.Viewer) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : null;
|
|
263
262
|
});
|
|
264
263
|
}
|
|
265
264
|
static DeleteMyActivities() {
|
|
@@ -285,6 +284,18 @@ Statistics (Manga):
|
|
|
285
284
|
],
|
|
286
285
|
},
|
|
287
286
|
]);
|
|
287
|
+
const { confirmed } = yield inquirer.prompt([
|
|
288
|
+
{
|
|
289
|
+
type: 'confirm',
|
|
290
|
+
name: 'confirmed',
|
|
291
|
+
message: `Delete all activities of this type? This cannot be undone.`,
|
|
292
|
+
default: false,
|
|
293
|
+
},
|
|
294
|
+
]);
|
|
295
|
+
if (!confirmed) {
|
|
296
|
+
console.log(`\nAborted.`);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
288
299
|
const queryMap = {
|
|
289
300
|
0: activityAllQuery,
|
|
290
301
|
1: activityTextQuery,
|
|
@@ -344,13 +355,14 @@ Statistics (Manga):
|
|
|
344
355
|
console.error(`\nPlease log in first to delete your lists.`);
|
|
345
356
|
return;
|
|
346
357
|
}
|
|
347
|
-
|
|
358
|
+
const userId = yield Auth.MyUserId();
|
|
359
|
+
if (!userId) {
|
|
348
360
|
console.log(`\nFailed getting current user Id.`);
|
|
349
361
|
return;
|
|
350
362
|
}
|
|
351
|
-
const response = yield fetcher(currentUserAnimeList, { id:
|
|
363
|
+
const response = yield fetcher(currentUserAnimeList, { id: userId });
|
|
352
364
|
if (response !== null) {
|
|
353
|
-
const lists = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists;
|
|
365
|
+
const lists = (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists) !== null && _c !== void 0 ? _c : [];
|
|
354
366
|
if (lists.length > 0) {
|
|
355
367
|
const { selectedList } = yield inquirer.prompt([
|
|
356
368
|
{
|
|
@@ -363,10 +375,22 @@ Statistics (Manga):
|
|
|
363
375
|
]);
|
|
364
376
|
const selectedEntries = lists.find((list) => list.name === selectedList);
|
|
365
377
|
if (selectedEntries) {
|
|
378
|
+
const { confirmed } = yield inquirer.prompt([
|
|
379
|
+
{
|
|
380
|
+
type: 'confirm',
|
|
381
|
+
name: 'confirmed',
|
|
382
|
+
message: `Delete all ${selectedEntries.entries.length} entries from '${selectedEntries.name}'? This cannot be undone.`,
|
|
383
|
+
default: false,
|
|
384
|
+
},
|
|
385
|
+
]);
|
|
386
|
+
if (!confirmed) {
|
|
387
|
+
console.log(`\nAborted.`);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
366
390
|
console.log(`\nDeleting entries of '${selectedEntries.name}':`);
|
|
367
391
|
for (const [, entry] of selectedEntries.entries.entries()) {
|
|
368
392
|
if (entry === null || entry === void 0 ? void 0 : entry.id) {
|
|
369
|
-
yield Auth.DeleteAnimeById(entry === null || entry === void 0 ? void 0 : entry.id, (
|
|
393
|
+
yield Auth.DeleteAnimeById(entry === null || entry === void 0 ? void 0 : entry.id, (_d = entry === null || entry === void 0 ? void 0 : entry.media) === null || _d === void 0 ? void 0 : _d.title);
|
|
370
394
|
yield new Promise((resolve) => setTimeout(resolve, 1100));
|
|
371
395
|
}
|
|
372
396
|
else {
|
|
@@ -384,13 +408,13 @@ Statistics (Manga):
|
|
|
384
408
|
}
|
|
385
409
|
}
|
|
386
410
|
else {
|
|
387
|
-
console.log(`\nSomething went wrong
|
|
411
|
+
console.log(`\nSomething went wrong fetching anime list.`);
|
|
388
412
|
}
|
|
389
413
|
});
|
|
390
414
|
}
|
|
391
415
|
static DeleteAnimeById(id, title) {
|
|
392
416
|
return __awaiter(this, void 0, void 0, function* () {
|
|
393
|
-
var _a, _b, _c;
|
|
417
|
+
var _a, _b, _c, _d;
|
|
394
418
|
try {
|
|
395
419
|
const response = yield fetcher(deleteMediaEntryMutation, { id: id });
|
|
396
420
|
if (response === null || response === void 0 ? void 0 : response.data) {
|
|
@@ -398,7 +422,7 @@ Statistics (Manga):
|
|
|
398
422
|
console.log(`del ${title ? getTitle(title) : ''} ${deleted ? '✔' : '✘'}`);
|
|
399
423
|
}
|
|
400
424
|
else {
|
|
401
|
-
console.log(`\nError deleting anime. ${(_c = response === null || response === void 0 ? void 0 : response.errors[0]) === null ||
|
|
425
|
+
console.log(`\nError deleting anime. ${(_d = (_c = response === null || response === void 0 ? void 0 : response.errors) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.message}`);
|
|
402
426
|
console.log(response);
|
|
403
427
|
}
|
|
404
428
|
}
|
|
@@ -409,22 +433,23 @@ Statistics (Manga):
|
|
|
409
433
|
}
|
|
410
434
|
static DeleteMyMangaList() {
|
|
411
435
|
return __awaiter(this, void 0, void 0, function* () {
|
|
412
|
-
var _a, _b, _c, _d;
|
|
436
|
+
var _a, _b, _c, _d, _e, _f;
|
|
413
437
|
try {
|
|
414
438
|
if (!(yield Auth.isLoggedIn())) {
|
|
415
439
|
console.error(`\nPlease log in first to delete your lists.`);
|
|
416
440
|
return;
|
|
417
441
|
}
|
|
418
|
-
|
|
442
|
+
const userId = yield Auth.MyUserId();
|
|
443
|
+
if (!userId) {
|
|
419
444
|
console.error(`\nFailed getting current user Id.`);
|
|
420
445
|
return;
|
|
421
446
|
}
|
|
422
|
-
const response = yield fetcher(currentUserMangaList, { id:
|
|
447
|
+
const response = yield fetcher(currentUserMangaList, { id: userId });
|
|
423
448
|
if (!(response === null || response === void 0 ? void 0 : response.data)) {
|
|
424
|
-
console.error(`\nSomething went wrong. ${(_a = response === null || response === void 0 ? void 0 : response.errors[0]) === null ||
|
|
449
|
+
console.error(`\nSomething went wrong. ${(_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}`);
|
|
425
450
|
return;
|
|
426
451
|
}
|
|
427
|
-
const lists = (
|
|
452
|
+
const lists = (_e = (_d = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.MediaListCollection) === null || _d === void 0 ? void 0 : _d.lists) !== null && _e !== void 0 ? _e : [];
|
|
428
453
|
if (lists.length > 0) {
|
|
429
454
|
const { selectedList } = yield inquirer.prompt([
|
|
430
455
|
{
|
|
@@ -437,10 +462,22 @@ Statistics (Manga):
|
|
|
437
462
|
]);
|
|
438
463
|
const selectedEntries = lists.find((list) => list.name === selectedList);
|
|
439
464
|
if (selectedEntries) {
|
|
465
|
+
const { confirmed } = yield inquirer.prompt([
|
|
466
|
+
{
|
|
467
|
+
type: 'confirm',
|
|
468
|
+
name: 'confirmed',
|
|
469
|
+
message: `Delete all ${selectedEntries.entries.length} entries from '${selectedEntries.name}'? This cannot be undone.`,
|
|
470
|
+
default: false,
|
|
471
|
+
},
|
|
472
|
+
]);
|
|
473
|
+
if (!confirmed) {
|
|
474
|
+
console.log(`\nAborted.`);
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
440
477
|
console.log(`\nDeleting entries of '${selectedEntries.name}':`);
|
|
441
478
|
for (const [, entry] of selectedEntries.entries.entries()) {
|
|
442
479
|
if (entry === null || entry === void 0 ? void 0 : entry.id) {
|
|
443
|
-
yield Auth.DeleteMangaById(entry === null || entry === void 0 ? void 0 : entry.id, (
|
|
480
|
+
yield Auth.DeleteMangaById(entry === null || entry === void 0 ? void 0 : entry.id, (_f = entry === null || entry === void 0 ? void 0 : entry.media) === null || _f === void 0 ? void 0 : _f.title);
|
|
444
481
|
yield new Promise((resolve) => setTimeout(resolve, 1100));
|
|
445
482
|
}
|
|
446
483
|
else {
|
|
@@ -488,15 +525,15 @@ Statistics (Manga):
|
|
|
488
525
|
console.error(`\nPlease login to use this feature.`);
|
|
489
526
|
return;
|
|
490
527
|
}
|
|
491
|
-
const
|
|
528
|
+
const response = yield fetcher(saveTextActivityMutation, {
|
|
492
529
|
status: status,
|
|
493
530
|
});
|
|
494
|
-
if (!data) {
|
|
495
|
-
console.error(`\nSomething went wrong
|
|
531
|
+
if (!(response === null || response === void 0 ? void 0 : response.data)) {
|
|
532
|
+
console.error(`\nSomething went wrong.`);
|
|
496
533
|
return;
|
|
497
534
|
}
|
|
498
|
-
if (data.SaveTextActivity.id) {
|
|
499
|
-
console.log(`\n[${data.SaveTextActivity.id}] status saved successfully!`);
|
|
535
|
+
if (response.data.SaveTextActivity.id) {
|
|
536
|
+
console.log(`\n[${response.data.SaveTextActivity.id}] status saved successfully!`);
|
|
500
537
|
}
|
|
501
538
|
}
|
|
502
539
|
catch (error) {
|
|
@@ -602,7 +639,7 @@ class Social {
|
|
|
602
639
|
// Filter users that do no follow me
|
|
603
640
|
const notFollowing = allFollowerUsers
|
|
604
641
|
.filter(({ isFollowing }) => !isFollowing)
|
|
605
|
-
.map(({ id, name }) => ({ id: id, name: name }));
|
|
642
|
+
.map(({ id, name }) => ({ id: id, name: name !== null && name !== void 0 ? name : '' }));
|
|
606
643
|
console.log(`\nTotal follower ${allFollowerUsers.length}.\nNot followed back ${notFollowing.length}\n`);
|
|
607
644
|
if (notFollowing.length <= 0) {
|
|
608
645
|
console.log(`Probably followed back all the users.`);
|
|
@@ -661,7 +698,7 @@ class Social {
|
|
|
661
698
|
// Filter users that do no follow me
|
|
662
699
|
const notFollowingMe = allFollowingUsers
|
|
663
700
|
.filter((user) => !user.isFollower)
|
|
664
|
-
.map((u3r) => ({ id: u3r.id, name: u3r.name }));
|
|
701
|
+
.map((u3r) => { var _a; return ({ id: u3r.id, name: (_a = u3r.name) !== null && _a !== void 0 ? _a : '' }); });
|
|
665
702
|
if (notFollowingMe.length <= 0) {
|
|
666
703
|
spinner.stop(`No users to unfollow. Exiting operation...`);
|
|
667
704
|
return;
|
package/bin/helpers/fetcher.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @param {string} query - The AniList GraphQL query to be executed.
|
|
9
9
|
* @param {object} variables - An object containing the variables for the query.
|
|
10
|
-
* @returns {Promise<
|
|
10
|
+
* @returns {Promise<T|null>} The response from the API as a JSON object if successful; otherwise, null.
|
|
11
11
|
*/
|
|
12
|
-
declare function fetcher(query: string, variables: object): Promise<
|
|
12
|
+
declare function fetcher<T extends object = object>(query: string, variables: object, retryCount?: number): Promise<T | null>;
|
|
13
13
|
export { fetcher };
|
package/bin/helpers/fetcher.js
CHANGED
|
@@ -7,7 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import fetch from 'node-fetch';
|
|
11
10
|
import { Auth } from './auth.js';
|
|
12
11
|
import { aniListEndpoint, handleRateLimitRetry } from './workers.js';
|
|
13
12
|
/**
|
|
@@ -19,17 +18,17 @@ import { aniListEndpoint, handleRateLimitRetry } from './workers.js';
|
|
|
19
18
|
*
|
|
20
19
|
* @param {string} query - The AniList GraphQL query to be executed.
|
|
21
20
|
* @param {object} variables - An object containing the variables for the query.
|
|
22
|
-
* @returns {Promise<
|
|
21
|
+
* @returns {Promise<T|null>} The response from the API as a JSON object if successful; otherwise, null.
|
|
23
22
|
*/
|
|
24
|
-
function fetcher(
|
|
25
|
-
return __awaiter(this,
|
|
23
|
+
function fetcher(query_1, variables_1) {
|
|
24
|
+
return __awaiter(this, arguments, void 0, function* (query, variables, retryCount = 0) {
|
|
26
25
|
var _a, _b;
|
|
27
26
|
try {
|
|
28
27
|
const headers = {
|
|
29
28
|
'content-type': 'application/json',
|
|
30
29
|
};
|
|
31
30
|
const token = (yield Auth.isLoggedIn())
|
|
32
|
-
? yield Auth.
|
|
31
|
+
? yield Auth.RetrieveAccessToken()
|
|
33
32
|
: null;
|
|
34
33
|
if (token)
|
|
35
34
|
headers['Authorization'] = `Bearer ${token}`;
|
|
@@ -43,8 +42,8 @@ function fetcher(query, variables) {
|
|
|
43
42
|
return response;
|
|
44
43
|
}
|
|
45
44
|
else if (request.status === 429) {
|
|
46
|
-
yield handleRateLimitRetry(
|
|
47
|
-
return yield fetcher(query, variables);
|
|
45
|
+
yield handleRateLimitRetry(retryCount);
|
|
46
|
+
return yield fetcher(query, variables, retryCount + 1);
|
|
48
47
|
}
|
|
49
48
|
else {
|
|
50
49
|
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'}.`);
|
package/bin/helpers/lists.js
CHANGED
|
@@ -147,14 +147,14 @@ class AniList {
|
|
|
147
147
|
if (animeList) {
|
|
148
148
|
const lists = (_c = (_b = (_a = animeList === null || animeList === void 0 ? void 0 : animeList.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists) !== null && _c !== void 0 ? _c : [];
|
|
149
149
|
const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => {
|
|
150
|
-
var _a, _b, _c, _d;
|
|
150
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
151
151
|
return ({
|
|
152
152
|
id: (_a = entry === null || entry === void 0 ? void 0 : entry.media) === null || _a === void 0 ? void 0 : _a.id,
|
|
153
|
-
title: (_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.title,
|
|
154
|
-
episodes: (
|
|
155
|
-
siteUrl: (
|
|
156
|
-
progress: entry.progress,
|
|
157
|
-
status: entry === null || entry === void 0 ? void 0 : entry.status,
|
|
153
|
+
title: (_c = (_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : {},
|
|
154
|
+
episodes: (_d = entry === null || entry === void 0 ? void 0 : entry.media) === null || _d === void 0 ? void 0 : _d.episodes,
|
|
155
|
+
siteUrl: (_e = entry === null || entry === void 0 ? void 0 : entry.media) === null || _e === void 0 ? void 0 : _e.siteUrl,
|
|
156
|
+
progress: (_f = entry.progress) !== null && _f !== void 0 ? _f : 0,
|
|
157
|
+
status: (_g = entry === null || entry === void 0 ? void 0 : entry.status) !== null && _g !== void 0 ? _g : '',
|
|
158
158
|
hiddenFromStatusLists: entry.hiddenFromStatusLists,
|
|
159
159
|
});
|
|
160
160
|
}));
|
|
@@ -208,14 +208,14 @@ class AniList {
|
|
|
208
208
|
},
|
|
209
209
|
]);
|
|
210
210
|
const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => {
|
|
211
|
-
var _a, _b;
|
|
211
|
+
var _a, _b, _c, _d, _e;
|
|
212
212
|
return ({
|
|
213
213
|
id: (_a = entry === null || entry === void 0 ? void 0 : entry.media) === null || _a === void 0 ? void 0 : _a.id,
|
|
214
|
-
title: (_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.title,
|
|
214
|
+
title: (_c = (_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : {},
|
|
215
215
|
private: entry.private,
|
|
216
216
|
chapters: entry.media.chapters,
|
|
217
|
-
progress: entry.progress,
|
|
218
|
-
status: entry === null || entry === void 0 ? void 0 : entry.status,
|
|
217
|
+
progress: (_d = entry.progress) !== null && _d !== void 0 ? _d : 0,
|
|
218
|
+
status: (_e = entry === null || entry === void 0 ? void 0 : entry.status) !== null && _e !== void 0 ? _e : '',
|
|
219
219
|
hiddenFromStatusLists: entry.hiddenFromStatusLists,
|
|
220
220
|
});
|
|
221
221
|
}));
|
|
@@ -246,10 +246,11 @@ class AniList {
|
|
|
246
246
|
if (!(yield Auth.isLoggedIn())) {
|
|
247
247
|
return console.error(`\nPlease log in first to access your lists.`);
|
|
248
248
|
}
|
|
249
|
-
|
|
249
|
+
const userId = yield Auth.MyUserId();
|
|
250
|
+
if (!userId) {
|
|
250
251
|
return console.log(`\nFailed getting current user Id.`);
|
|
251
252
|
}
|
|
252
|
-
const data = yield fetcher(currentUserAnimeList, { id:
|
|
253
|
+
const data = yield fetcher(currentUserAnimeList, { id: userId });
|
|
253
254
|
if (data === null || data === void 0 ? void 0 : data.errors) {
|
|
254
255
|
return console.log(`\nSomething went wrong. ${(_b = (_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message}`);
|
|
255
256
|
}
|
|
@@ -715,7 +716,7 @@ class AniList {
|
|
|
715
716
|
});
|
|
716
717
|
if (searchResults) {
|
|
717
718
|
const results = (_b = (_a = searchResults === null || searchResults === void 0 ? void 0 : searchResults.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.media;
|
|
718
|
-
if (results.length > 0) {
|
|
719
|
+
if (results && results.length > 0) {
|
|
719
720
|
const { selectedAnime } = yield inquirer.prompt([
|
|
720
721
|
{
|
|
721
722
|
type: 'select',
|
|
@@ -782,7 +783,7 @@ class AniList {
|
|
|
782
783
|
type: 'select',
|
|
783
784
|
name: 'selectedMangaId',
|
|
784
785
|
message: 'Select manga to add to your list:',
|
|
785
|
-
choices: results.map((res, idx) => ({
|
|
786
|
+
choices: (results !== null && results !== void 0 ? results : []).map((res, idx) => ({
|
|
786
787
|
name: `[${idx + 1}] ${getTitle(res === null || res === void 0 ? void 0 : res.title)}`,
|
|
787
788
|
value: res === null || res === void 0 ? void 0 : res.id,
|
|
788
789
|
})),
|
|
@@ -971,26 +972,26 @@ class MyAnimeList {
|
|
|
971
972
|
}
|
|
972
973
|
static exportAnime() {
|
|
973
974
|
return __awaiter(this, void 0, void 0, function* () {
|
|
974
|
-
var _a, _b, _c, _d;
|
|
975
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
975
976
|
try {
|
|
976
977
|
if (yield Auth.isLoggedIn()) {
|
|
977
978
|
const animeList = yield fetcher(currentUserAnimeList, {
|
|
978
979
|
id: yield Auth.MyUserId(),
|
|
979
980
|
});
|
|
980
|
-
if (((_b = (_a = animeList === null || animeList === void 0 ? void 0 : animeList.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists.length) > 0) {
|
|
981
|
-
const lists = (
|
|
981
|
+
if (((_d = (_c = (_b = (_a = animeList === null || animeList === void 0 ? void 0 : animeList.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0) {
|
|
982
|
+
const lists = (_g = (_f = (_e = animeList === null || animeList === void 0 ? void 0 : animeList.data) === null || _e === void 0 ? void 0 : _e.MediaListCollection) === null || _f === void 0 ? void 0 : _f.lists) !== null && _g !== void 0 ? _g : [];
|
|
982
983
|
const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => {
|
|
983
|
-
var _a, _b, _c, _d, _e, _f;
|
|
984
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
984
985
|
return ({
|
|
985
986
|
id: (_a = entry === null || entry === void 0 ? void 0 : entry.media) === null || _a === void 0 ? void 0 : _a.id,
|
|
986
987
|
malId: (_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.idMal,
|
|
987
|
-
title: (_c = entry === null || entry === void 0 ? void 0 : entry.media) === null || _c === void 0 ? void 0 : _c.title,
|
|
988
|
-
episodes: (
|
|
989
|
-
siteUrl: (
|
|
990
|
-
progress: entry.progress,
|
|
991
|
-
status: entry === null || entry === void 0 ? void 0 : entry.status,
|
|
988
|
+
title: (_d = (_c = entry === null || entry === void 0 ? void 0 : entry.media) === null || _c === void 0 ? void 0 : _c.title) !== null && _d !== void 0 ? _d : {},
|
|
989
|
+
episodes: (_e = entry === null || entry === void 0 ? void 0 : entry.media) === null || _e === void 0 ? void 0 : _e.episodes,
|
|
990
|
+
siteUrl: (_f = entry === null || entry === void 0 ? void 0 : entry.media) === null || _f === void 0 ? void 0 : _f.siteUrl,
|
|
991
|
+
progress: (_g = entry.progress) !== null && _g !== void 0 ? _g : 0,
|
|
992
|
+
status: (_h = entry === null || entry === void 0 ? void 0 : entry.status) !== null && _h !== void 0 ? _h : '',
|
|
992
993
|
hiddenFromStatusLists: false,
|
|
993
|
-
format: (
|
|
994
|
+
format: (_j = entry === null || entry === void 0 ? void 0 : entry.media) === null || _j === void 0 ? void 0 : _j.format,
|
|
994
995
|
});
|
|
995
996
|
}));
|
|
996
997
|
yield saveJSONasXML(mediaWithProgress, 0);
|
|
@@ -1007,7 +1008,7 @@ class MyAnimeList {
|
|
|
1007
1008
|
}
|
|
1008
1009
|
static exportManga() {
|
|
1009
1010
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1010
|
-
var _a, _b, _c, _d;
|
|
1011
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1011
1012
|
try {
|
|
1012
1013
|
if (!(yield Auth.isLoggedIn())) {
|
|
1013
1014
|
console.log(`\nPlease login to use this feature.`);
|
|
@@ -1016,18 +1017,21 @@ class MyAnimeList {
|
|
|
1016
1017
|
const mangaList = yield fetcher(currentUserMangaList, {
|
|
1017
1018
|
id: yield Auth.MyUserId(),
|
|
1018
1019
|
});
|
|
1019
|
-
if (
|
|
1020
|
-
const lists = (
|
|
1021
|
-
const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) =>
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1020
|
+
if (((_d = (_c = (_b = (_a = mangaList === null || mangaList === void 0 ? void 0 : mangaList.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0) {
|
|
1021
|
+
const lists = (_g = (_f = (_e = mangaList === null || mangaList === void 0 ? void 0 : mangaList.data) === null || _e === void 0 ? void 0 : _e.MediaListCollection) === null || _f === void 0 ? void 0 : _f.lists) !== null && _g !== void 0 ? _g : [];
|
|
1022
|
+
const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => {
|
|
1023
|
+
var _a, _b, _c;
|
|
1024
|
+
return ({
|
|
1025
|
+
id: entry.media.id,
|
|
1026
|
+
malId: entry.media.idMal,
|
|
1027
|
+
title: (_a = entry.media.title) !== null && _a !== void 0 ? _a : {},
|
|
1028
|
+
private: entry.private,
|
|
1029
|
+
chapters: entry.media.chapters,
|
|
1030
|
+
progress: (_b = entry.progress) !== null && _b !== void 0 ? _b : 0,
|
|
1031
|
+
status: (_c = entry.status) !== null && _c !== void 0 ? _c : '',
|
|
1032
|
+
hiddenFromStatusLists: entry.hiddenFromStatusLists,
|
|
1033
|
+
});
|
|
1034
|
+
}));
|
|
1031
1035
|
yield saveJSONasXML(mediaWithProgress, 1);
|
|
1032
1036
|
}
|
|
1033
1037
|
else {
|
|
@@ -1135,15 +1139,15 @@ class AniDB {
|
|
|
1135
1139
|
class MoveTo {
|
|
1136
1140
|
static AnimeList() {
|
|
1137
1141
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1138
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1142
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1139
1143
|
try {
|
|
1140
1144
|
spinner.start(`Fetching your anime list...`);
|
|
1141
1145
|
const animeList = yield fetcher(currentUserAnimeList, {
|
|
1142
1146
|
id: yield Auth.MyUserId(),
|
|
1143
1147
|
});
|
|
1144
|
-
if (((_b = (_a = animeList === null || animeList === void 0 ? void 0 : animeList.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists.length) > 0) {
|
|
1148
|
+
if (((_d = (_c = (_b = (_a = animeList === null || animeList === void 0 ? void 0 : animeList.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0) {
|
|
1145
1149
|
spinner.stop();
|
|
1146
|
-
const list = (
|
|
1150
|
+
const list = (_g = (_f = (_e = animeList === null || animeList === void 0 ? void 0 : animeList.data) === null || _e === void 0 ? void 0 : _e.MediaListCollection) === null || _f === void 0 ? void 0 : _f.lists) !== null && _g !== void 0 ? _g : [];
|
|
1147
1151
|
const { selectedList } = yield inquirer.prompt([
|
|
1148
1152
|
{
|
|
1149
1153
|
type: 'list',
|
|
@@ -1166,7 +1170,7 @@ class MoveTo {
|
|
|
1166
1170
|
]);
|
|
1167
1171
|
const entries = selectedEntries.entries;
|
|
1168
1172
|
for (const entry of entries) {
|
|
1169
|
-
const mediaId = (
|
|
1173
|
+
const mediaId = (_h = entry === null || entry === void 0 ? void 0 : entry.media) === null || _h === void 0 ? void 0 : _h.id;
|
|
1170
1174
|
const status = entry === null || entry === void 0 ? void 0 : entry.status;
|
|
1171
1175
|
// const progress = entry?.progress
|
|
1172
1176
|
// console.log(mediaId, status)
|
|
@@ -1176,11 +1180,11 @@ class MoveTo {
|
|
|
1176
1180
|
customList: toMoveList,
|
|
1177
1181
|
});
|
|
1178
1182
|
if (response === null || response === void 0 ? void 0 : response.data) {
|
|
1179
|
-
const moved = (
|
|
1183
|
+
const moved = (_j = response === null || response === void 0 ? void 0 : response.data) === null || _j === void 0 ? void 0 : _j.SaveMediaListEntry;
|
|
1180
1184
|
console.log(`✔ Entry ${moved === null || moved === void 0 ? void 0 : moved.id}. Moved from ${selectedList} to ${toMoveList}.`);
|
|
1181
1185
|
}
|
|
1182
1186
|
else {
|
|
1183
|
-
console.error(`\nFailed to move the anime. ${((
|
|
1187
|
+
console.error(`\nFailed to move the anime. ${((_l = (_k = response === null || response === void 0 ? void 0 : response.errors) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.message) || 'Unknown error'}`);
|
|
1184
1188
|
}
|
|
1185
1189
|
}
|
|
1186
1190
|
}
|
|
@@ -1195,15 +1199,15 @@ class MoveTo {
|
|
|
1195
1199
|
}
|
|
1196
1200
|
static MangaList() {
|
|
1197
1201
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1198
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1202
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1199
1203
|
try {
|
|
1200
1204
|
spinner.start(`Fetching your manga list...`);
|
|
1201
1205
|
const mangaList = yield fetcher(currentUserMangaList, {
|
|
1202
1206
|
id: yield Auth.MyUserId(),
|
|
1203
1207
|
});
|
|
1204
|
-
if (((_b = (_a = mangaList === null || mangaList === void 0 ? void 0 : mangaList.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists.length) > 0) {
|
|
1208
|
+
if (((_d = (_c = (_b = (_a = mangaList === null || mangaList === void 0 ? void 0 : mangaList.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0) {
|
|
1205
1209
|
spinner.stop();
|
|
1206
|
-
const list = (
|
|
1210
|
+
const list = (_g = (_f = (_e = mangaList === null || mangaList === void 0 ? void 0 : mangaList.data) === null || _e === void 0 ? void 0 : _e.MediaListCollection) === null || _f === void 0 ? void 0 : _f.lists) !== null && _g !== void 0 ? _g : [];
|
|
1207
1211
|
const { selectedList } = yield inquirer.prompt([
|
|
1208
1212
|
{
|
|
1209
1213
|
type: 'list',
|
|
@@ -1226,7 +1230,7 @@ class MoveTo {
|
|
|
1226
1230
|
]);
|
|
1227
1231
|
const entries = selectedEntries.entries;
|
|
1228
1232
|
for (const entry of entries) {
|
|
1229
|
-
const mediaId = (
|
|
1233
|
+
const mediaId = (_h = entry === null || entry === void 0 ? void 0 : entry.media) === null || _h === void 0 ? void 0 : _h.id;
|
|
1230
1234
|
const status = entry === null || entry === void 0 ? void 0 : entry.status;
|
|
1231
1235
|
// console.log(mediaId, status)
|
|
1232
1236
|
const response = yield fetcher(moveListMutation, {
|
|
@@ -1235,11 +1239,11 @@ class MoveTo {
|
|
|
1235
1239
|
customList: toMoveList,
|
|
1236
1240
|
});
|
|
1237
1241
|
if (response === null || response === void 0 ? void 0 : response.data) {
|
|
1238
|
-
const moved = (
|
|
1242
|
+
const moved = (_j = response === null || response === void 0 ? void 0 : response.data) === null || _j === void 0 ? void 0 : _j.SaveMediaListEntry;
|
|
1239
1243
|
console.log(`✅ Entry ${moved === null || moved === void 0 ? void 0 : moved.id}. Moved from ${selectedList} to ${toMoveList}.`);
|
|
1240
1244
|
}
|
|
1241
1245
|
else {
|
|
1242
|
-
console.error(`\nFailed to move the manga. ${((
|
|
1246
|
+
console.error(`\nFailed to move the manga. ${((_l = (_k = response === null || response === void 0 ? void 0 : response.errors) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.message) || 'Unknown error'}`);
|
|
1243
1247
|
}
|
|
1244
1248
|
}
|
|
1245
1249
|
}
|
|
@@ -10,15 +10,15 @@ declare class Validate {
|
|
|
10
10
|
/**
|
|
11
11
|
* Validate if MyAnimeList Anime XML file is valid or not
|
|
12
12
|
* @param {string} xmlData
|
|
13
|
-
* @returns {
|
|
13
|
+
* @returns {boolean}
|
|
14
14
|
*/
|
|
15
|
-
static Import_AnimeXML(xmlData: string):
|
|
15
|
+
static Import_AnimeXML(xmlData: string): boolean;
|
|
16
16
|
/**
|
|
17
|
-
* Validate if MyAnimeList
|
|
17
|
+
* Validate if MyAnimeList Manga XML file is valid or not
|
|
18
18
|
* @param xmlData string
|
|
19
19
|
* @returns boolean
|
|
20
20
|
*/
|
|
21
|
-
static Import_MangaXML(xmlData: string):
|
|
21
|
+
static Import_MangaXML(xmlData: string): boolean;
|
|
22
22
|
/**
|
|
23
23
|
* Validate AniDB json-large file
|
|
24
24
|
* @param file string of anidb json-large
|
|
@@ -7,7 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
10
|
+
import { XMLParser } from 'fast-xml-parser';
|
|
11
|
+
const parser = new XMLParser({ ignoreAttributes: false });
|
|
11
12
|
class Validate {
|
|
12
13
|
/**
|
|
13
14
|
* Validate importable JSON file
|
|
@@ -21,72 +22,68 @@ class Validate {
|
|
|
21
22
|
/**
|
|
22
23
|
* Validate if MyAnimeList Anime XML file is valid or not
|
|
23
24
|
* @param {string} xmlData
|
|
24
|
-
* @returns {
|
|
25
|
+
* @returns {boolean}
|
|
25
26
|
*/
|
|
26
27
|
static Import_AnimeXML(xmlData) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
const animeList = result.myanimelist.anime;
|
|
35
|
-
if (!animeList) {
|
|
36
|
-
console.error("Invalid XML structure: Missing 'anime' elements.");
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
const animeArray = Array.isArray(animeList) ? animeList : [animeList];
|
|
40
|
-
const isValid = animeArray.every((anime) => {
|
|
41
|
-
const isValidId = anime.series_animedb_id && !isNaN(Number(anime.series_animedb_id));
|
|
42
|
-
const hasRequiredFields = anime.series_title && anime.my_status;
|
|
43
|
-
return isValidId && hasRequiredFields;
|
|
44
|
-
});
|
|
45
|
-
if (!isValid) {
|
|
46
|
-
console.error('Validation failed: Some anime entries are missing required fields or have invalid IDs.');
|
|
47
|
-
}
|
|
48
|
-
return isValid;
|
|
28
|
+
try {
|
|
29
|
+
const result = parser.parse(xmlData);
|
|
30
|
+
if (!(result === null || result === void 0 ? void 0 : result.myanimelist)) {
|
|
31
|
+
console.error("Invalid XML structure: Missing 'myanimelist' root element.");
|
|
32
|
+
return false;
|
|
49
33
|
}
|
|
50
|
-
|
|
51
|
-
|
|
34
|
+
const animeList = result.myanimelist.anime;
|
|
35
|
+
if (!animeList) {
|
|
36
|
+
console.error("Invalid XML structure: Missing 'anime' elements.");
|
|
52
37
|
return false;
|
|
53
38
|
}
|
|
54
|
-
|
|
39
|
+
const animeArray = Array.isArray(animeList) ? animeList : [animeList];
|
|
40
|
+
const isValid = animeArray.every((anime) => {
|
|
41
|
+
const isValidId = anime.series_animedb_id && !isNaN(Number(anime.series_animedb_id));
|
|
42
|
+
const hasRequiredFields = anime.series_title && anime.my_status;
|
|
43
|
+
return isValidId && hasRequiredFields;
|
|
44
|
+
});
|
|
45
|
+
if (!isValid) {
|
|
46
|
+
console.error('Validation failed: Some anime entries are missing required fields or have invalid IDs.');
|
|
47
|
+
}
|
|
48
|
+
return isValid;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.error('Error parsing or validating XML:', error);
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
55
54
|
}
|
|
56
55
|
/**
|
|
57
|
-
* Validate if MyAnimeList
|
|
56
|
+
* Validate if MyAnimeList Manga XML file is valid or not
|
|
58
57
|
* @param xmlData string
|
|
59
58
|
* @returns boolean
|
|
60
59
|
*/
|
|
61
60
|
static Import_MangaXML(xmlData) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
const mangaList = result.myanimelist.manga;
|
|
70
|
-
if (!mangaList) {
|
|
71
|
-
console.error("Invalid XML structure: Missing 'manga' elements.");
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
const mangaArray = Array.isArray(mangaList) ? mangaList : [mangaList];
|
|
75
|
-
const isValid = mangaArray.every((manga) => {
|
|
76
|
-
const isValidId = manga.manga_mangadb_id && !isNaN(Number(manga.manga_mangadb_id));
|
|
77
|
-
const hasRequiredFields = manga.manga_title && manga.my_status;
|
|
78
|
-
return isValidId && hasRequiredFields;
|
|
79
|
-
});
|
|
80
|
-
if (!isValid) {
|
|
81
|
-
console.error('Validation failed: Some manga entries are missing required fields or have invalid IDs.');
|
|
82
|
-
}
|
|
83
|
-
return isValid;
|
|
61
|
+
try {
|
|
62
|
+
const result = parser.parse(xmlData);
|
|
63
|
+
if (!(result === null || result === void 0 ? void 0 : result.myanimelist)) {
|
|
64
|
+
console.error("Invalid XML structure: Missing 'myanimelist' root element.");
|
|
65
|
+
return false;
|
|
84
66
|
}
|
|
85
|
-
|
|
86
|
-
|
|
67
|
+
const mangaList = result.myanimelist.manga;
|
|
68
|
+
if (!mangaList) {
|
|
69
|
+
console.error("Invalid XML structure: Missing 'manga' elements.");
|
|
87
70
|
return false;
|
|
88
71
|
}
|
|
89
|
-
|
|
72
|
+
const mangaArray = Array.isArray(mangaList) ? mangaList : [mangaList];
|
|
73
|
+
const isValid = mangaArray.every((manga) => {
|
|
74
|
+
const isValidId = manga.manga_mangadb_id && !isNaN(Number(manga.manga_mangadb_id));
|
|
75
|
+
const hasRequiredFields = manga.manga_title && manga.my_status;
|
|
76
|
+
return isValidId && hasRequiredFields;
|
|
77
|
+
});
|
|
78
|
+
if (!isValid) {
|
|
79
|
+
console.error('Validation failed: Some manga entries are missing required fields or have invalid IDs.');
|
|
80
|
+
}
|
|
81
|
+
return isValid;
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
console.error('Error parsing or validating XML:', error);
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
90
87
|
}
|
|
91
88
|
/**
|
|
92
89
|
* Validate AniDB json-large file
|
package/bin/helpers/workers.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { DateMonthYear, MALAnimeStatus, MALMangaStatus, MediaWithProgress, 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
|
-
declare function getTitle(title
|
|
4
|
+
declare function getTitle(title?: {
|
|
5
5
|
english?: string;
|
|
6
6
|
romaji?: string;
|
|
7
7
|
}): string;
|
|
8
8
|
declare function formatDateObject(dateObj: {
|
|
9
|
-
day?: number;
|
|
10
|
-
month?: number;
|
|
11
|
-
year?: number;
|
|
9
|
+
day?: number | null;
|
|
10
|
+
month?: number | null;
|
|
11
|
+
year?: number | null;
|
|
12
12
|
} | null): string;
|
|
13
13
|
declare function getNextSeasonAndYear(): {
|
|
14
14
|
nextSeason: string;
|
|
@@ -30,7 +30,7 @@ declare function saveJSONasJSON(js0n: object, dataType: string): Promise<void>;
|
|
|
30
30
|
*/
|
|
31
31
|
declare function saveJSONasCSV(js0n: MediaWithProgress[], dataType: string): Promise<void>;
|
|
32
32
|
declare function saveJSONasXML(js0n: MediaWithProgress[], data_type: 0 | 1): Promise<void>;
|
|
33
|
-
declare function selectFile(fileType: string): Promise<string>;
|
|
33
|
+
declare function selectFile(fileType: string): Promise<string | null>;
|
|
34
34
|
declare function createAnimeXML(malId: number, progress: number, status: MALAnimeStatus, episodes: number, title: string, format: string): string;
|
|
35
35
|
declare function createMangaXML(malId: number, progress: number, status: MALMangaStatus, chapters: number, title: string): string;
|
|
36
36
|
declare function createAnimeListXML(mediaWithProgress: MediaWithProgress[]): Promise<string>;
|
package/bin/helpers/workers.js
CHANGED
|
@@ -47,8 +47,8 @@ function formatDateObject(dateObj) {
|
|
|
47
47
|
function getNextSeasonAndYear() {
|
|
48
48
|
const currentMonth = new Date().getMonth() + 1;
|
|
49
49
|
const currentYear = new Date().getFullYear();
|
|
50
|
-
let nextSeason;
|
|
51
|
-
let nextYear;
|
|
50
|
+
let nextSeason = '';
|
|
51
|
+
let nextYear = 0;
|
|
52
52
|
// Determine the current season
|
|
53
53
|
if (currentMonth >= 12 || currentMonth <= 2) {
|
|
54
54
|
nextSeason = 'SPRING';
|
|
@@ -267,7 +267,7 @@ function createAnimeListXML(mediaWithProgress) {
|
|
|
267
267
|
const title = getTitle(anime.title);
|
|
268
268
|
const status = statusMap[anime.status];
|
|
269
269
|
const format = anime.format ? anime.format : '';
|
|
270
|
-
return createAnimeXML(malId, progress, status, episodes, title, format);
|
|
270
|
+
return createAnimeXML(malId !== null && malId !== void 0 ? malId : 0, progress, status, episodes !== null && episodes !== void 0 ? episodes : 0, title, format);
|
|
271
271
|
});
|
|
272
272
|
return `<myanimelist>
|
|
273
273
|
<myinfo>
|
|
@@ -302,7 +302,7 @@ function createMangaListXML(mediaWithProgress) {
|
|
|
302
302
|
const chapters = manga.chapters;
|
|
303
303
|
const title = getTitle(manga.title);
|
|
304
304
|
const status = statusMap[manga.status];
|
|
305
|
-
return createMangaXML(malId, progress, status, chapters, title);
|
|
305
|
+
return createMangaXML(malId !== null && malId !== void 0 ? malId : 0, progress, status, chapters !== null && chapters !== void 0 ? chapters : 0, title);
|
|
306
306
|
});
|
|
307
307
|
return `<myanimelist>
|
|
308
308
|
<myinfo>
|
|
@@ -361,7 +361,7 @@ const anidbToanilistMapper = (romanjiName, year, englishName) => __awaiter(void
|
|
|
361
361
|
search,
|
|
362
362
|
perPage: 50,
|
|
363
363
|
});
|
|
364
|
-
return ((_a = response.data) === null || _a === void 0 ? void 0 : _a.Page.media) || [];
|
|
364
|
+
return ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.Page.media) || [];
|
|
365
365
|
}
|
|
366
366
|
catch (error) {
|
|
367
367
|
console.error('Error fetching AniList data:', error);
|
package/bin/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var _a;
|
|
11
12
|
import { Command } from 'commander';
|
|
12
13
|
import process from 'process';
|
|
13
14
|
import { Auth, Social } from './helpers/auth.js';
|
|
@@ -17,12 +18,12 @@ const cli = new Command();
|
|
|
17
18
|
cli
|
|
18
19
|
.name('anilist')
|
|
19
20
|
.description('Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts.')
|
|
20
|
-
.version(getCurrentPackageVersion());
|
|
21
|
+
.version((_a = getCurrentPackageVersion()) !== null && _a !== void 0 ? _a : '');
|
|
21
22
|
cli
|
|
22
23
|
.command('login')
|
|
23
24
|
.description('Login with AniList')
|
|
24
|
-
.requiredOption('-i, --id <number>',
|
|
25
|
-
.requiredOption('-s, --secret <string>',
|
|
25
|
+
.requiredOption('-i, --id <number>', '')
|
|
26
|
+
.requiredOption('-s, --secret <string>', '')
|
|
26
27
|
.action((_a) => __awaiter(void 0, [_a], void 0, function* ({ id, secret }) {
|
|
27
28
|
if (id && secret) {
|
|
28
29
|
yield Auth.Login(id, secret);
|
|
@@ -131,7 +132,6 @@ cli
|
|
|
131
132
|
cli
|
|
132
133
|
.command('manga <id>')
|
|
133
134
|
.description('Get manga details by their ID')
|
|
134
|
-
.option('-c, --count <number>', 'Number of items to get', '10')
|
|
135
135
|
.action((id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
136
|
yield AniList.getMangaDetailsByID(id);
|
|
137
137
|
}));
|
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": "1.9.
|
|
4
|
+
"version": "1.9.8",
|
|
5
5
|
"author": "Irfan Shadik Rishad",
|
|
6
6
|
"license": "MPL-2.0",
|
|
7
7
|
"scripts": {
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
"format:check": "prettier . --check",
|
|
13
13
|
"lint": "eslint ./dist",
|
|
14
14
|
"lint:fix": "eslint ./dist --fix",
|
|
15
|
-
"
|
|
15
|
+
"prepare": "husky",
|
|
16
|
+
"pretest": "npm run build",
|
|
17
|
+
"test": "NODE_OPTIONS='--experimental-vm-modules' jest ./tests --runInBand"
|
|
16
18
|
},
|
|
17
19
|
"keywords": [
|
|
18
20
|
"anilist",
|
|
@@ -52,37 +54,35 @@
|
|
|
52
54
|
},
|
|
53
55
|
"prettier": "@irfanshadikrishad/prettier",
|
|
54
56
|
"dependencies": {
|
|
55
|
-
"@irfanshadikrishad/cipher": "^1.
|
|
56
|
-
"chalk": "^
|
|
57
|
-
"cli-truncate": "^
|
|
57
|
+
"@irfanshadikrishad/cipher": "^1.7.1",
|
|
58
|
+
"chalk": "^6.0.0",
|
|
59
|
+
"cli-truncate": "^6.1.1",
|
|
58
60
|
"commander": "^14.0.3",
|
|
59
|
-
"fast-xml-parser": "^5.
|
|
60
|
-
"inquirer": "^13.
|
|
61
|
-
"jsonrepair": "^3.
|
|
62
|
-
"node-fetch": "^3.3.2",
|
|
61
|
+
"fast-xml-parser": "^5.10.1",
|
|
62
|
+
"inquirer": "^13.4.3",
|
|
63
|
+
"jsonrepair": "^3.15.0",
|
|
63
64
|
"open": "^11.0.0",
|
|
64
|
-
"papaparse": "^5.5.
|
|
65
|
-
"tiny-spinner": "^2.0.5"
|
|
66
|
-
"xml2js": "^0.6.2"
|
|
65
|
+
"papaparse": "^5.5.4",
|
|
66
|
+
"tiny-spinner": "^2.0.5"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@babel/preset-env": "^7.29.
|
|
69
|
+
"@babel/preset-env": "^7.29.7",
|
|
70
70
|
"@eslint/js": "^10.0.1",
|
|
71
|
-
"@irfanshadikrishad/prettier": "^1.3.
|
|
71
|
+
"@irfanshadikrishad/prettier": "^1.3.7",
|
|
72
72
|
"@types/jest": "^30.0.0",
|
|
73
|
-
"@types/node": "^25.
|
|
73
|
+
"@types/node": "^25.9.1",
|
|
74
74
|
"@types/papaparse": "^5.5.2",
|
|
75
|
-
"@
|
|
76
|
-
"@typescript-eslint/
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"jest": "^30.2
|
|
81
|
-
"prettier": "^3.
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^8.66.0",
|
|
76
|
+
"@typescript-eslint/parser": "^8.66.0",
|
|
77
|
+
"eslint": "^10.8.0",
|
|
78
|
+
"globals": "^17.9.0",
|
|
79
|
+
"husky": "^9.1.7",
|
|
80
|
+
"jest": "^30.4.2",
|
|
81
|
+
"prettier": "^3.9.6",
|
|
82
82
|
"prettier-plugin-organize-imports": "^4.3.0",
|
|
83
|
-
"ts-jest": "^29.4.
|
|
83
|
+
"ts-jest": "^29.4.12",
|
|
84
84
|
"ts-node": "^10.9.2",
|
|
85
|
-
"typescript": "^
|
|
85
|
+
"typescript": "^6.0.3"
|
|
86
86
|
},
|
|
87
87
|
"engines": {
|
|
88
88
|
"node": ">=24.0.0",
|