@irfanshadikrishad/anilist 1.7.0 → 2.0.0-forbidden
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +382 -0
- package/README.md +0 -1
- package/bin/helpers/auth.d.ts +6 -1
- package/bin/helpers/auth.js +413 -78
- package/bin/helpers/fetcher.js +7 -7
- package/bin/helpers/lib/colorize.d.ts +8 -0
- package/bin/helpers/lib/colorize.js +19 -0
- package/bin/helpers/lists.d.ts +1 -5
- package/bin/helpers/lists.js +166 -289
- package/bin/helpers/mutations.d.ts +2 -2
- package/bin/helpers/mutations.js +6 -9
- package/bin/helpers/queries.d.ts +4 -1
- package/bin/helpers/queries.js +35 -1
- package/bin/helpers/truncate.js +2 -2
- package/bin/helpers/types.d.ts +53 -15
- package/bin/helpers/validation.js +8 -8
- package/bin/helpers/workers.d.ts +3 -2
- package/bin/helpers/workers.js +114 -94
- package/bin/index.js +79 -93
- package/package.json +87 -84
- package/CITATION.cff +0 -8
package/bin/helpers/lists.js
CHANGED
|
@@ -7,31 +7,29 @@ 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 { XMLParser } from
|
|
11
|
-
import { readFile } from
|
|
12
|
-
import inquirer from
|
|
13
|
-
import { jsonrepair } from
|
|
14
|
-
import { join } from
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import { anidbToanilistMapper, formatDateObject, getDownloadFolderPath, getNextSeasonAndYear, getTitle, logUserDetails, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, saveJSONasXML, selectFile, simpleDateFormat, timestampToTimeAgo, } from "./workers.js";
|
|
24
|
-
const spinner = new Spinner();
|
|
10
|
+
import { XMLParser } from 'fast-xml-parser';
|
|
11
|
+
import { readFile } from 'fs/promises';
|
|
12
|
+
import inquirer from 'inquirer';
|
|
13
|
+
import { jsonrepair } from 'jsonrepair';
|
|
14
|
+
import { join } from 'path';
|
|
15
|
+
import { Auth } from './auth.js';
|
|
16
|
+
import { fetcher } from './fetcher.js';
|
|
17
|
+
import { addAnimeToListMutation, addMangaToListMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, } from './mutations.js';
|
|
18
|
+
import { animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, malIdToAnilistAnimeId, malIdToAnilistMangaId, mangaDetailsQuery, mangaSearchQuery, popularQuery, trendingQuery, upcomingAnimesQuery, userActivityQuery, userFollowersQuery, userFollowingQuery, userQuery, } from './queries.js';
|
|
19
|
+
import { responsiveOutput } from './truncate.js';
|
|
20
|
+
import { AniListMediaStatus, } from './types.js';
|
|
21
|
+
import { Validate } from './validation.js';
|
|
22
|
+
import { anidbToanilistMapper, formatDateObject, getDownloadFolderPath, getNextSeasonAndYear, getTitle, logUserDetails, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, saveJSONasXML, selectFile, simpleDateFormat, timestampToTimeAgo, } from './workers.js';
|
|
25
23
|
class AniList {
|
|
26
24
|
static importAnime() {
|
|
27
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
26
|
try {
|
|
29
|
-
const filename = yield selectFile(
|
|
27
|
+
const filename = yield selectFile('.json');
|
|
30
28
|
if (!filename) {
|
|
31
29
|
return;
|
|
32
30
|
}
|
|
33
31
|
const filePath = join(getDownloadFolderPath(), filename);
|
|
34
|
-
const fileContent = yield readFile(filePath,
|
|
32
|
+
const fileContent = yield readFile(filePath, 'utf8');
|
|
35
33
|
const importedData = JSON.parse(fileContent);
|
|
36
34
|
if (!Validate.Import_JSON(importedData)) {
|
|
37
35
|
console.error(`\nInvalid JSON file.`);
|
|
@@ -76,12 +74,12 @@ class AniList {
|
|
|
76
74
|
static importManga() {
|
|
77
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
76
|
try {
|
|
79
|
-
const filename = yield selectFile(
|
|
77
|
+
const filename = yield selectFile('.json');
|
|
80
78
|
if (!filename) {
|
|
81
79
|
return;
|
|
82
80
|
}
|
|
83
81
|
const filePath = join(getDownloadFolderPath(), filename);
|
|
84
|
-
const fileContent = yield readFile(filePath,
|
|
82
|
+
const fileContent = yield readFile(filePath, 'utf8');
|
|
85
83
|
const importedData = JSON.parse(fileContent);
|
|
86
84
|
if (!Validate.Import_JSON(importedData)) {
|
|
87
85
|
console.error(`\nInvalid JSON file.`);
|
|
@@ -130,13 +128,13 @@ class AniList {
|
|
|
130
128
|
}
|
|
131
129
|
const { exportType } = yield inquirer.prompt([
|
|
132
130
|
{
|
|
133
|
-
type:
|
|
134
|
-
name:
|
|
135
|
-
message:
|
|
131
|
+
type: 'list',
|
|
132
|
+
name: 'exportType',
|
|
133
|
+
message: 'Choose export type:',
|
|
136
134
|
choices: [
|
|
137
|
-
{ name:
|
|
138
|
-
{ name:
|
|
139
|
-
{ name:
|
|
135
|
+
{ name: 'CSV', value: 1 },
|
|
136
|
+
{ name: 'JSON', value: 2 },
|
|
137
|
+
{ name: 'XML (MyAnimeList/AniDB)', value: 3 },
|
|
140
138
|
],
|
|
141
139
|
pageSize: 10,
|
|
142
140
|
},
|
|
@@ -160,10 +158,10 @@ class AniList {
|
|
|
160
158
|
}));
|
|
161
159
|
switch (exportType) {
|
|
162
160
|
case 1:
|
|
163
|
-
yield saveJSONasCSV(mediaWithProgress,
|
|
161
|
+
yield saveJSONasCSV(mediaWithProgress, 'anime');
|
|
164
162
|
break;
|
|
165
163
|
case 2:
|
|
166
|
-
yield saveJSONasJSON(mediaWithProgress,
|
|
164
|
+
yield saveJSONasJSON(mediaWithProgress, 'anime');
|
|
167
165
|
break;
|
|
168
166
|
case 3:
|
|
169
167
|
yield MyAnimeList.exportAnime();
|
|
@@ -196,13 +194,13 @@ class AniList {
|
|
|
196
194
|
if (lists.length > 0) {
|
|
197
195
|
const { exportType } = yield inquirer.prompt([
|
|
198
196
|
{
|
|
199
|
-
type:
|
|
200
|
-
name:
|
|
201
|
-
message:
|
|
197
|
+
type: 'list',
|
|
198
|
+
name: 'exportType',
|
|
199
|
+
message: 'Choose export type:',
|
|
202
200
|
choices: [
|
|
203
|
-
{ name:
|
|
204
|
-
{ name:
|
|
205
|
-
{ name:
|
|
201
|
+
{ name: 'CSV', value: 1 },
|
|
202
|
+
{ name: 'JSON', value: 2 },
|
|
203
|
+
{ name: 'XML (MyAnimeList)', value: 3 },
|
|
206
204
|
],
|
|
207
205
|
pageSize: 10,
|
|
208
206
|
},
|
|
@@ -221,10 +219,10 @@ class AniList {
|
|
|
221
219
|
}));
|
|
222
220
|
switch (exportType) {
|
|
223
221
|
case 1:
|
|
224
|
-
yield saveJSONasCSV(mediaWithProgress,
|
|
222
|
+
yield saveJSONasCSV(mediaWithProgress, 'manga');
|
|
225
223
|
break;
|
|
226
224
|
case 2:
|
|
227
|
-
yield saveJSONasJSON(mediaWithProgress,
|
|
225
|
+
yield saveJSONasJSON(mediaWithProgress, 'manga');
|
|
228
226
|
break;
|
|
229
227
|
case 3:
|
|
230
228
|
yield MyAnimeList.exportManga();
|
|
@@ -259,9 +257,9 @@ class AniList {
|
|
|
259
257
|
}
|
|
260
258
|
const { selectedList } = yield inquirer.prompt([
|
|
261
259
|
{
|
|
262
|
-
type:
|
|
263
|
-
name:
|
|
264
|
-
message:
|
|
260
|
+
type: 'list',
|
|
261
|
+
name: 'selectedList',
|
|
262
|
+
message: 'Select an anime list:',
|
|
265
263
|
choices: lists.map((list) => list.name),
|
|
266
264
|
},
|
|
267
265
|
]);
|
|
@@ -272,9 +270,9 @@ class AniList {
|
|
|
272
270
|
console.log(`\nEntries for '${selectedEntries.name}':`);
|
|
273
271
|
const { selectedAnime } = yield inquirer.prompt([
|
|
274
272
|
{
|
|
275
|
-
type:
|
|
276
|
-
name:
|
|
277
|
-
message:
|
|
273
|
+
type: 'list',
|
|
274
|
+
name: 'selectedAnime',
|
|
275
|
+
message: 'Select anime to add to the list:',
|
|
278
276
|
choices: selectedEntries.entries.map((entry, idx) => ({
|
|
279
277
|
name: `[${idx + 1}] ${getTitle(entry.media.title)}`,
|
|
280
278
|
value: entry.media.id,
|
|
@@ -284,15 +282,15 @@ class AniList {
|
|
|
284
282
|
]);
|
|
285
283
|
const { selectedListType } = yield inquirer.prompt([
|
|
286
284
|
{
|
|
287
|
-
type:
|
|
288
|
-
name:
|
|
289
|
-
message:
|
|
285
|
+
type: 'list',
|
|
286
|
+
name: 'selectedListType',
|
|
287
|
+
message: 'Select the list where you want to save this anime:',
|
|
290
288
|
choices: [
|
|
291
|
-
{ name:
|
|
292
|
-
{ name:
|
|
293
|
-
{ name:
|
|
294
|
-
{ name:
|
|
295
|
-
{ name:
|
|
289
|
+
{ name: 'Planning', value: 'PLANNING' },
|
|
290
|
+
{ name: 'Watching', value: 'CURRENT' },
|
|
291
|
+
{ name: 'Completed', value: 'COMPLETED' },
|
|
292
|
+
{ name: 'Paused', value: 'PAUSED' },
|
|
293
|
+
{ name: 'Dropped', value: 'DROPPED' },
|
|
296
294
|
],
|
|
297
295
|
},
|
|
298
296
|
]);
|
|
@@ -326,7 +324,7 @@ class AniList {
|
|
|
326
324
|
}
|
|
327
325
|
const response = yield fetcher(currentUserMangaList, { id: userId });
|
|
328
326
|
if (!(response === null || response === void 0 ? void 0 : response.data)) {
|
|
329
|
-
return console.error(`\nFailed to fetch manga lists. ${((_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) ||
|
|
327
|
+
return console.error(`\nFailed to fetch manga lists. ${((_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'}`);
|
|
330
328
|
}
|
|
331
329
|
const lists = (_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;
|
|
332
330
|
if (!lists || lists.length === 0) {
|
|
@@ -334,22 +332,22 @@ class AniList {
|
|
|
334
332
|
}
|
|
335
333
|
const { selectedList } = yield inquirer.prompt([
|
|
336
334
|
{
|
|
337
|
-
type:
|
|
338
|
-
name:
|
|
339
|
-
message:
|
|
335
|
+
type: 'list',
|
|
336
|
+
name: 'selectedList',
|
|
337
|
+
message: 'Select a manga list:',
|
|
340
338
|
choices: lists.map((list) => list.name),
|
|
341
339
|
},
|
|
342
340
|
]);
|
|
343
341
|
const selectedEntries = lists.find((list) => list.name === selectedList);
|
|
344
342
|
if (!selectedEntries || selectedEntries.entries.length === 0) {
|
|
345
|
-
return console.log(
|
|
343
|
+
return console.log('\nNo manga entries found in the selected list.');
|
|
346
344
|
}
|
|
347
345
|
console.log(`\nEntries for '${selectedEntries.name}':`);
|
|
348
346
|
const { selectedManga } = yield inquirer.prompt([
|
|
349
347
|
{
|
|
350
|
-
type:
|
|
351
|
-
name:
|
|
352
|
-
message:
|
|
348
|
+
type: 'list',
|
|
349
|
+
name: 'selectedManga',
|
|
350
|
+
message: 'Select a manga to add to the list:',
|
|
353
351
|
choices: selectedEntries.entries.map((entry, idx) => {
|
|
354
352
|
var _a;
|
|
355
353
|
return ({
|
|
@@ -362,15 +360,15 @@ class AniList {
|
|
|
362
360
|
]);
|
|
363
361
|
const { selectedListType } = yield inquirer.prompt([
|
|
364
362
|
{
|
|
365
|
-
type:
|
|
366
|
-
name:
|
|
367
|
-
message:
|
|
363
|
+
type: 'list',
|
|
364
|
+
name: 'selectedListType',
|
|
365
|
+
message: 'Select the list where you want to save this manga:',
|
|
368
366
|
choices: [
|
|
369
|
-
{ name:
|
|
370
|
-
{ name:
|
|
371
|
-
{ name:
|
|
372
|
-
{ name:
|
|
373
|
-
{ name:
|
|
367
|
+
{ name: 'Planning', value: 'PLANNING' },
|
|
368
|
+
{ name: 'Reading', value: 'CURRENT' },
|
|
369
|
+
{ name: 'Completed', value: 'COMPLETED' },
|
|
370
|
+
{ name: 'Paused', value: 'PAUSED' },
|
|
371
|
+
{ name: 'Dropped', value: 'DROPPED' },
|
|
374
372
|
],
|
|
375
373
|
},
|
|
376
374
|
]);
|
|
@@ -383,7 +381,7 @@ class AniList {
|
|
|
383
381
|
console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
|
|
384
382
|
}
|
|
385
383
|
else {
|
|
386
|
-
console.error(`\nFailed to save the manga. ${((_g = (_f = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.message) ||
|
|
384
|
+
console.error(`\nFailed to save the manga. ${((_g = (_f = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.message) || 'Unknown error'}`);
|
|
387
385
|
}
|
|
388
386
|
}
|
|
389
387
|
catch (error) {
|
|
@@ -400,7 +398,7 @@ class AniList {
|
|
|
400
398
|
while (true) {
|
|
401
399
|
const response = yield fetcher(trendingQuery, { page, perPage: count });
|
|
402
400
|
if (response === null || response === void 0 ? void 0 : response.errors) {
|
|
403
|
-
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) ||
|
|
401
|
+
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) || 'Unknown error'}`);
|
|
404
402
|
return;
|
|
405
403
|
}
|
|
406
404
|
const media = (_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.media;
|
|
@@ -413,32 +411,32 @@ class AniList {
|
|
|
413
411
|
name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
|
|
414
412
|
value: String(anime === null || anime === void 0 ? void 0 : anime.id),
|
|
415
413
|
}));
|
|
416
|
-
choices.push({ name:
|
|
414
|
+
choices.push({ name: 'See more', value: 'see_more' });
|
|
417
415
|
const { selectedAnime } = yield inquirer.prompt([
|
|
418
416
|
{
|
|
419
|
-
type:
|
|
420
|
-
name:
|
|
421
|
-
message:
|
|
417
|
+
type: 'list',
|
|
418
|
+
name: 'selectedAnime',
|
|
419
|
+
message: 'Select anime to add to the list:',
|
|
422
420
|
choices,
|
|
423
421
|
pageSize: choices.length + 1,
|
|
424
422
|
},
|
|
425
423
|
]);
|
|
426
|
-
if (selectedAnime ===
|
|
424
|
+
if (selectedAnime === 'see_more') {
|
|
427
425
|
page++;
|
|
428
426
|
continue;
|
|
429
427
|
}
|
|
430
428
|
else {
|
|
431
429
|
const { selectedListType } = yield inquirer.prompt([
|
|
432
430
|
{
|
|
433
|
-
type:
|
|
434
|
-
name:
|
|
435
|
-
message:
|
|
431
|
+
type: 'list',
|
|
432
|
+
name: 'selectedListType',
|
|
433
|
+
message: 'Select the list where you want to save this anime:',
|
|
436
434
|
choices: [
|
|
437
|
-
{ name:
|
|
438
|
-
{ name:
|
|
439
|
-
{ name:
|
|
440
|
-
{ name:
|
|
441
|
-
{ name:
|
|
435
|
+
{ name: 'Planning', value: 'PLANNING' },
|
|
436
|
+
{ name: 'Watching', value: 'CURRENT' },
|
|
437
|
+
{ name: 'Completed', value: 'COMPLETED' },
|
|
438
|
+
{ name: 'Paused', value: 'PAUSED' },
|
|
439
|
+
{ name: 'Dropped', value: 'DROPPED' },
|
|
442
440
|
],
|
|
443
441
|
},
|
|
444
442
|
]);
|
|
@@ -453,7 +451,7 @@ class AniList {
|
|
|
453
451
|
console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
|
|
454
452
|
}
|
|
455
453
|
else {
|
|
456
|
-
console.error(`\nFailed to save the anime. ${((_g = (_f = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.message) ||
|
|
454
|
+
console.error(`\nFailed to save the anime. ${((_g = (_f = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.message) || 'Unknown error'}`);
|
|
457
455
|
}
|
|
458
456
|
break;
|
|
459
457
|
}
|
|
@@ -473,7 +471,7 @@ class AniList {
|
|
|
473
471
|
while (true) {
|
|
474
472
|
const response = yield fetcher(popularQuery, { page, perPage: count });
|
|
475
473
|
if (!(response === null || response === void 0 ? void 0 : response.data)) {
|
|
476
|
-
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) ||
|
|
474
|
+
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) || 'Unknown error'}`);
|
|
477
475
|
return;
|
|
478
476
|
}
|
|
479
477
|
const newMedia = (_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.media;
|
|
@@ -486,32 +484,32 @@ class AniList {
|
|
|
486
484
|
name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
|
|
487
485
|
value: String(anime === null || anime === void 0 ? void 0 : anime.id),
|
|
488
486
|
}));
|
|
489
|
-
choices.push({ name:
|
|
487
|
+
choices.push({ name: 'See more', value: 'see_more' });
|
|
490
488
|
const { selectedAnime } = yield inquirer.prompt([
|
|
491
489
|
{
|
|
492
|
-
type:
|
|
493
|
-
name:
|
|
494
|
-
message:
|
|
490
|
+
type: 'list',
|
|
491
|
+
name: 'selectedAnime',
|
|
492
|
+
message: 'Select anime to add to the list:',
|
|
495
493
|
choices,
|
|
496
494
|
pageSize: choices.length,
|
|
497
495
|
},
|
|
498
496
|
]);
|
|
499
|
-
if (selectedAnime ===
|
|
497
|
+
if (selectedAnime === 'see_more') {
|
|
500
498
|
page++;
|
|
501
499
|
continue;
|
|
502
500
|
}
|
|
503
501
|
else {
|
|
504
502
|
const { selectedListType } = yield inquirer.prompt([
|
|
505
503
|
{
|
|
506
|
-
type:
|
|
507
|
-
name:
|
|
508
|
-
message:
|
|
504
|
+
type: 'list',
|
|
505
|
+
name: 'selectedListType',
|
|
506
|
+
message: 'Select the list where you want to save this anime:',
|
|
509
507
|
choices: [
|
|
510
|
-
{ name:
|
|
511
|
-
{ name:
|
|
512
|
-
{ name:
|
|
513
|
-
{ name:
|
|
514
|
-
{ name:
|
|
508
|
+
{ name: 'Planning', value: 'PLANNING' },
|
|
509
|
+
{ name: 'Watching', value: 'CURRENT' },
|
|
510
|
+
{ name: 'Completed', value: 'COMPLETED' },
|
|
511
|
+
{ name: 'Paused', value: 'PAUSED' },
|
|
512
|
+
{ name: 'Dropped', value: 'DROPPED' },
|
|
515
513
|
],
|
|
516
514
|
},
|
|
517
515
|
]);
|
|
@@ -525,7 +523,7 @@ class AniList {
|
|
|
525
523
|
console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
|
|
526
524
|
}
|
|
527
525
|
else {
|
|
528
|
-
console.error(`\nFailed to save the anime. ${((_g = (_f = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.message) ||
|
|
526
|
+
console.error(`\nFailed to save the anime. ${((_g = (_f = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.message) || 'Unknown error'}`);
|
|
529
527
|
}
|
|
530
528
|
break;
|
|
531
529
|
}
|
|
@@ -551,7 +549,7 @@ class AniList {
|
|
|
551
549
|
perPage: count,
|
|
552
550
|
});
|
|
553
551
|
if (!request || !request.data) {
|
|
554
|
-
console.error(`\nSomething went wrong. ${((_b = (_a = request === null || request === void 0 ? void 0 : request.errors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) ||
|
|
552
|
+
console.error(`\nSomething went wrong. ${((_b = (_a = request === null || request === void 0 ? void 0 : request.errors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) || 'Unknown error'}`);
|
|
555
553
|
return;
|
|
556
554
|
}
|
|
557
555
|
const newUpcoming = (_c = request.data.Page.media) !== null && _c !== void 0 ? _c : [];
|
|
@@ -564,32 +562,32 @@ class AniList {
|
|
|
564
562
|
name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
|
|
565
563
|
value: String(anime === null || anime === void 0 ? void 0 : anime.id),
|
|
566
564
|
}));
|
|
567
|
-
choices.push({ name:
|
|
565
|
+
choices.push({ name: 'See more', value: 'see_more' });
|
|
568
566
|
const { selectedAnime } = yield inquirer.prompt([
|
|
569
567
|
{
|
|
570
|
-
type:
|
|
571
|
-
name:
|
|
572
|
-
message:
|
|
568
|
+
type: 'list',
|
|
569
|
+
name: 'selectedAnime',
|
|
570
|
+
message: 'Select anime to add to the list:',
|
|
573
571
|
choices,
|
|
574
572
|
pageSize: choices.length + 2,
|
|
575
573
|
},
|
|
576
574
|
]);
|
|
577
|
-
if (selectedAnime ===
|
|
575
|
+
if (selectedAnime === 'see_more') {
|
|
578
576
|
page++;
|
|
579
577
|
continue;
|
|
580
578
|
}
|
|
581
579
|
else {
|
|
582
580
|
const { selectedListType } = yield inquirer.prompt([
|
|
583
581
|
{
|
|
584
|
-
type:
|
|
585
|
-
name:
|
|
586
|
-
message:
|
|
582
|
+
type: 'list',
|
|
583
|
+
name: 'selectedListType',
|
|
584
|
+
message: 'Select the list where you want to save this anime:',
|
|
587
585
|
choices: [
|
|
588
|
-
{ name:
|
|
589
|
-
{ name:
|
|
590
|
-
{ name:
|
|
591
|
-
{ name:
|
|
592
|
-
{ name:
|
|
586
|
+
{ name: 'Planning', value: 'PLANNING' },
|
|
587
|
+
{ name: 'Watching', value: 'CURRENT' },
|
|
588
|
+
{ name: 'Completed', value: 'COMPLETED' },
|
|
589
|
+
{ name: 'Paused', value: 'PAUSED' },
|
|
590
|
+
{ name: 'Dropped', value: 'DROPPED' },
|
|
593
591
|
],
|
|
594
592
|
},
|
|
595
593
|
]);
|
|
@@ -603,7 +601,7 @@ class AniList {
|
|
|
603
601
|
console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
|
|
604
602
|
}
|
|
605
603
|
else {
|
|
606
|
-
console.error(`\nFailed to save the anime. ${((_f = (_e = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.message) ||
|
|
604
|
+
console.error(`\nFailed to save the anime. ${((_f = (_e = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.message) || 'Unknown error'}`);
|
|
607
605
|
}
|
|
608
606
|
break;
|
|
609
607
|
}
|
|
@@ -620,7 +618,7 @@ class AniList {
|
|
|
620
618
|
try {
|
|
621
619
|
const response = yield fetcher(userQuery, { username });
|
|
622
620
|
if (!((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.User)) {
|
|
623
|
-
return console.error(`\n${((_c = (_b = response === null || response === void 0 ? void 0 : response.errors) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.message) ||
|
|
621
|
+
return console.error(`\n${((_c = (_b = response === null || response === void 0 ? void 0 : response.errors) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.message) || 'Unknown error'}`);
|
|
624
622
|
}
|
|
625
623
|
const user = response.data.User;
|
|
626
624
|
const userActivityResponse = yield fetcher(userActivityQuery, {
|
|
@@ -642,11 +640,11 @@ class AniList {
|
|
|
642
640
|
if (activities.length > 0) {
|
|
643
641
|
console.log(`\nRecent Activities:`);
|
|
644
642
|
activities.forEach(({ status, progress, media, createdAt }) => {
|
|
645
|
-
responsiveOutput(`${timestampToTimeAgo(createdAt)}\t${status} ${progress ? `${progress} of ` :
|
|
643
|
+
responsiveOutput(`${timestampToTimeAgo(createdAt)}\t${status} ${progress ? `${progress} of ` : ''}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
|
|
646
644
|
});
|
|
647
645
|
}
|
|
648
646
|
else {
|
|
649
|
-
console.log(
|
|
647
|
+
console.log('\nNo recent activities.');
|
|
650
648
|
}
|
|
651
649
|
}
|
|
652
650
|
catch (error) {
|
|
@@ -665,16 +663,16 @@ class AniList {
|
|
|
665
663
|
console.log(`\nID: ${id}`);
|
|
666
664
|
console.log(`Title: ${(title === null || title === void 0 ? void 0 : title.userPreferred) || getTitle(title)}`);
|
|
667
665
|
console.log(`Description: ${removeHtmlAndMarkdown(description)}`);
|
|
668
|
-
console.log(`Episode Duration: ${duration ||
|
|
669
|
-
console.log(`Origin: ${countryOfOrigin ||
|
|
670
|
-
console.log(`Status: ${status ||
|
|
671
|
-
console.log(`Format: ${format ||
|
|
672
|
-
console.log(`Genres: ${genres.length ? genres.join(
|
|
673
|
-
console.log(`Season: ${season ||
|
|
674
|
-
console.log(`Url: ${siteUrl ||
|
|
675
|
-
console.log(`isAdult: ${isAdult ?
|
|
676
|
-
console.log(`Released: ${formatDateObject(startDate) ||
|
|
677
|
-
console.log(`Finished: ${formatDateObject(endDate) ||
|
|
666
|
+
console.log(`Episode Duration: ${duration || 'Unknown'} min`);
|
|
667
|
+
console.log(`Origin: ${countryOfOrigin || 'N/A'}`);
|
|
668
|
+
console.log(`Status: ${status || 'N/A'}`);
|
|
669
|
+
console.log(`Format: ${format || 'N/A'}`);
|
|
670
|
+
console.log(`Genres: ${genres.length ? genres.join(', ') : 'N/A'}`);
|
|
671
|
+
console.log(`Season: ${season || 'N/A'}`);
|
|
672
|
+
console.log(`Url: ${siteUrl || 'N/A'}`);
|
|
673
|
+
console.log(`isAdult: ${isAdult ? 'Yes' : 'No'}`);
|
|
674
|
+
console.log(`Released: ${formatDateObject(startDate) || 'Unknown'}`);
|
|
675
|
+
console.log(`Finished: ${formatDateObject(endDate) || 'Ongoing'}`);
|
|
678
676
|
}
|
|
679
677
|
});
|
|
680
678
|
}
|
|
@@ -695,7 +693,7 @@ class AniList {
|
|
|
695
693
|
console.log(`${manga.description}`);
|
|
696
694
|
console.log(`Chapters: ${manga.chapters}\t Volumes: ${manga.volumes}`);
|
|
697
695
|
console.log(`Status:\t${manga.status}`);
|
|
698
|
-
console.log(`Genres:\t${manga.genres.join(
|
|
696
|
+
console.log(`Genres:\t${manga.genres.join(', ')}`);
|
|
699
697
|
console.log(`Start:\t${simpleDateFormat(manga.startDate)}`);
|
|
700
698
|
console.log(`End:\t${simpleDateFormat(manga.endDate)}`);
|
|
701
699
|
}
|
|
@@ -718,9 +716,9 @@ class AniList {
|
|
|
718
716
|
if (results.length > 0) {
|
|
719
717
|
const { selectedAnime } = yield inquirer.prompt([
|
|
720
718
|
{
|
|
721
|
-
type:
|
|
722
|
-
name:
|
|
723
|
-
message:
|
|
719
|
+
type: 'list',
|
|
720
|
+
name: 'selectedAnime',
|
|
721
|
+
message: 'Select anime to add to your list:',
|
|
724
722
|
choices: results.map((res, idx) => ({
|
|
725
723
|
name: `[${idx + 1}] ${getTitle(res === null || res === void 0 ? void 0 : res.title)}`,
|
|
726
724
|
value: res === null || res === void 0 ? void 0 : res.id,
|
|
@@ -730,15 +728,15 @@ class AniList {
|
|
|
730
728
|
]);
|
|
731
729
|
const { selectedListType } = yield inquirer.prompt([
|
|
732
730
|
{
|
|
733
|
-
type:
|
|
734
|
-
name:
|
|
735
|
-
message:
|
|
731
|
+
type: 'list',
|
|
732
|
+
name: 'selectedListType',
|
|
733
|
+
message: 'Select the list where you want to save this anime:',
|
|
736
734
|
choices: [
|
|
737
|
-
{ name:
|
|
738
|
-
{ name:
|
|
739
|
-
{ name:
|
|
740
|
-
{ name:
|
|
741
|
-
{ name:
|
|
735
|
+
{ name: 'Planning', value: 'PLANNING' },
|
|
736
|
+
{ name: 'Watching', value: 'CURRENT' },
|
|
737
|
+
{ name: 'Completed', value: 'COMPLETED' },
|
|
738
|
+
{ name: 'Paused', value: 'PAUSED' },
|
|
739
|
+
{ name: 'Dropped', value: 'DROPPED' },
|
|
742
740
|
],
|
|
743
741
|
},
|
|
744
742
|
]);
|
|
@@ -779,9 +777,9 @@ class AniList {
|
|
|
779
777
|
// List of manga search results
|
|
780
778
|
const { selectedMangaId } = yield inquirer.prompt([
|
|
781
779
|
{
|
|
782
|
-
type:
|
|
783
|
-
name:
|
|
784
|
-
message:
|
|
780
|
+
type: 'list',
|
|
781
|
+
name: 'selectedMangaId',
|
|
782
|
+
message: 'Select manga to add to your list:',
|
|
785
783
|
choices: results.map((res, idx) => ({
|
|
786
784
|
name: `[${idx + 1}] ${getTitle(res === null || res === void 0 ? void 0 : res.title)}`,
|
|
787
785
|
value: res === null || res === void 0 ? void 0 : res.id,
|
|
@@ -792,15 +790,15 @@ class AniList {
|
|
|
792
790
|
// Options to save to the list
|
|
793
791
|
const { selectedListType } = yield inquirer.prompt([
|
|
794
792
|
{
|
|
795
|
-
type:
|
|
796
|
-
name:
|
|
797
|
-
message:
|
|
793
|
+
type: 'list',
|
|
794
|
+
name: 'selectedListType',
|
|
795
|
+
message: 'Select the list where you want to save this manga:',
|
|
798
796
|
choices: [
|
|
799
|
-
{ name:
|
|
800
|
-
{ name:
|
|
801
|
-
{ name:
|
|
802
|
-
{ name:
|
|
803
|
-
{ name:
|
|
797
|
+
{ name: 'Planning', value: 'PLANNING' },
|
|
798
|
+
{ name: 'Reading', value: 'CURRENT' },
|
|
799
|
+
{ name: 'Completed', value: 'COMPLETED' },
|
|
800
|
+
{ name: 'Paused', value: 'PAUSED' },
|
|
801
|
+
{ name: 'Dropped', value: 'DROPPED' },
|
|
804
802
|
],
|
|
805
803
|
},
|
|
806
804
|
]);
|
|
@@ -830,12 +828,12 @@ class MyAnimeList {
|
|
|
830
828
|
return __awaiter(this, void 0, void 0, function* () {
|
|
831
829
|
var _a, _b, _c, _d, _e;
|
|
832
830
|
try {
|
|
833
|
-
const filename = yield selectFile(
|
|
831
|
+
const filename = yield selectFile('.xml');
|
|
834
832
|
if (!filename) {
|
|
835
833
|
return;
|
|
836
834
|
}
|
|
837
835
|
const filePath = join(getDownloadFolderPath(), filename);
|
|
838
|
-
const fileContent = yield readFile(filePath,
|
|
836
|
+
const fileContent = yield readFile(filePath, 'utf8');
|
|
839
837
|
if (!(yield Validate.Import_AnimeXML(fileContent))) {
|
|
840
838
|
console.error(`\nInvalid XML file.`);
|
|
841
839
|
return;
|
|
@@ -847,11 +845,11 @@ class MyAnimeList {
|
|
|
847
845
|
if ((animeList === null || animeList === void 0 ? void 0 : animeList.length) > 0) {
|
|
848
846
|
let count = 0;
|
|
849
847
|
const statusMap = {
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
848
|
+
'On-Hold': AniListMediaStatus.PAUSED,
|
|
849
|
+
'Dropped': AniListMediaStatus.DROPPED,
|
|
850
|
+
'Completed': AniListMediaStatus.COMPLETED,
|
|
851
|
+
'Watching': AniListMediaStatus.CURRENT,
|
|
852
|
+
'Plan to Watch': AniListMediaStatus.PLANNING,
|
|
855
853
|
};
|
|
856
854
|
for (const anime of animeList) {
|
|
857
855
|
const malId = anime.series_animedb_id;
|
|
@@ -900,12 +898,12 @@ class MyAnimeList {
|
|
|
900
898
|
return __awaiter(this, void 0, void 0, function* () {
|
|
901
899
|
var _a, _b, _c, _d, _e;
|
|
902
900
|
try {
|
|
903
|
-
const filename = yield selectFile(
|
|
901
|
+
const filename = yield selectFile('.xml');
|
|
904
902
|
if (!filename) {
|
|
905
903
|
return;
|
|
906
904
|
}
|
|
907
905
|
const filePath = join(getDownloadFolderPath(), filename);
|
|
908
|
-
const fileContent = yield readFile(filePath,
|
|
906
|
+
const fileContent = yield readFile(filePath, 'utf8');
|
|
909
907
|
if (!(yield Validate.Import_MangaXML(fileContent))) {
|
|
910
908
|
console.error(`\nInvalid XML file.`);
|
|
911
909
|
return;
|
|
@@ -917,11 +915,11 @@ class MyAnimeList {
|
|
|
917
915
|
if ((mangas === null || mangas === void 0 ? void 0 : mangas.length) > 0) {
|
|
918
916
|
let count = 0;
|
|
919
917
|
const statusMap = {
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
918
|
+
'On-Hold': AniListMediaStatus.PAUSED,
|
|
919
|
+
'Dropped': AniListMediaStatus.DROPPED,
|
|
920
|
+
'Completed': AniListMediaStatus.COMPLETED,
|
|
921
|
+
'Reading': AniListMediaStatus.CURRENT,
|
|
922
|
+
'Plan to Read': AniListMediaStatus.PLANNING,
|
|
925
923
|
};
|
|
926
924
|
for (const manga of mangas) {
|
|
927
925
|
const malId = manga.manga_mangadb_id;
|
|
@@ -1045,12 +1043,12 @@ class AniDB {
|
|
|
1045
1043
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1046
1044
|
var _a, _b;
|
|
1047
1045
|
try {
|
|
1048
|
-
const filename = yield selectFile(
|
|
1046
|
+
const filename = yield selectFile('.json');
|
|
1049
1047
|
if (!filename) {
|
|
1050
1048
|
return;
|
|
1051
1049
|
}
|
|
1052
1050
|
const filePath = join(getDownloadFolderPath(), filename);
|
|
1053
|
-
const fileContent = yield readFile(filePath,
|
|
1051
|
+
const fileContent = yield readFile(filePath, 'utf8');
|
|
1054
1052
|
const js0n_repaired = jsonrepair(fileContent);
|
|
1055
1053
|
if (!(yield Validate.Import_AniDBJSONLarge(js0n_repaired))) {
|
|
1056
1054
|
console.error(`\nInvalid JSON Large file.`);
|
|
@@ -1074,10 +1072,10 @@ class AniDB {
|
|
|
1074
1072
|
const romanjiName = anime.romanjiName;
|
|
1075
1073
|
const englishName = anime.englishName;
|
|
1076
1074
|
function getStatus(anidbStatus, episodesSeen) {
|
|
1077
|
-
if (anidbStatus ===
|
|
1075
|
+
if (anidbStatus === 'complete') {
|
|
1078
1076
|
return AniListMediaStatus.COMPLETED;
|
|
1079
1077
|
}
|
|
1080
|
-
else if (anidbStatus ===
|
|
1078
|
+
else if (anidbStatus === 'incomplete' &&
|
|
1081
1079
|
Number(episodesSeen) > 0) {
|
|
1082
1080
|
return AniListMediaStatus.CURRENT;
|
|
1083
1081
|
}
|
|
@@ -1085,7 +1083,7 @@ class AniDB {
|
|
|
1085
1083
|
return AniListMediaStatus.PLANNING;
|
|
1086
1084
|
}
|
|
1087
1085
|
}
|
|
1088
|
-
let anilistId = yield anidbToanilistMapper(romanjiName, Number(released.split(
|
|
1086
|
+
let anilistId = yield anidbToanilistMapper(romanjiName, Number(released.split('.')[2]), englishName);
|
|
1089
1087
|
if (anilistId) {
|
|
1090
1088
|
try {
|
|
1091
1089
|
const saveResponse = yield fetcher(saveAnimeWithProgressMutation, {
|
|
@@ -1116,7 +1114,7 @@ class AniDB {
|
|
|
1116
1114
|
responsiveOutput(`\nAccuracy: ${(((animeList.length - missed.length) / animeList.length) * 100).toFixed(2)}%\tTotal Processed: ${iteration}\tMissed: ${missed.length}`);
|
|
1117
1115
|
if (missed.length > 0) {
|
|
1118
1116
|
responsiveOutput(`Exporting missed entries to JSON file, Please add them manually.`);
|
|
1119
|
-
yield saveJSONasJSON(missed,
|
|
1117
|
+
yield saveJSONasJSON(missed, 'anidb-missed');
|
|
1120
1118
|
}
|
|
1121
1119
|
}
|
|
1122
1120
|
else {
|
|
@@ -1133,125 +1131,4 @@ class AniDB {
|
|
|
1133
1131
|
});
|
|
1134
1132
|
}
|
|
1135
1133
|
}
|
|
1136
|
-
|
|
1137
|
-
static AnimeList() {
|
|
1138
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1139
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1140
|
-
try {
|
|
1141
|
-
spinner.start(`Fetching your anime list...`);
|
|
1142
|
-
const animeList = yield fetcher(currentUserAnimeList, {
|
|
1143
|
-
id: yield Auth.MyUserId(),
|
|
1144
|
-
});
|
|
1145
|
-
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) {
|
|
1146
|
-
spinner.stop();
|
|
1147
|
-
const list = (_d = (_c = animeList === null || animeList === void 0 ? void 0 : animeList.data) === null || _c === void 0 ? void 0 : _c.MediaListCollection) === null || _d === void 0 ? void 0 : _d.lists;
|
|
1148
|
-
const { selectedList } = yield inquirer.prompt([
|
|
1149
|
-
{
|
|
1150
|
-
type: "list",
|
|
1151
|
-
name: "selectedList",
|
|
1152
|
-
message: "Select a list to move:",
|
|
1153
|
-
choices: list.map((list) => list.name),
|
|
1154
|
-
},
|
|
1155
|
-
]);
|
|
1156
|
-
const selectedEntries = list.find((list) => list.name === selectedList);
|
|
1157
|
-
if (!selectedEntries || selectedEntries.entries.length === 0) {
|
|
1158
|
-
return console.log("\nNo anime entries found in the selected list.");
|
|
1159
|
-
}
|
|
1160
|
-
const { toMoveList } = yield inquirer.prompt([
|
|
1161
|
-
{
|
|
1162
|
-
type: "list",
|
|
1163
|
-
name: "toMoveList",
|
|
1164
|
-
message: "Select a list to move to:",
|
|
1165
|
-
choices: list.map((list) => list.name),
|
|
1166
|
-
},
|
|
1167
|
-
]);
|
|
1168
|
-
const entries = selectedEntries.entries;
|
|
1169
|
-
for (const entry of entries) {
|
|
1170
|
-
const mediaId = (_e = entry === null || entry === void 0 ? void 0 : entry.media) === null || _e === void 0 ? void 0 : _e.id;
|
|
1171
|
-
const status = entry === null || entry === void 0 ? void 0 : entry.status;
|
|
1172
|
-
// const progress = entry?.progress
|
|
1173
|
-
// console.log(mediaId, status)
|
|
1174
|
-
const response = yield fetcher(moveListMutation, {
|
|
1175
|
-
mediaId,
|
|
1176
|
-
status,
|
|
1177
|
-
customList: toMoveList,
|
|
1178
|
-
});
|
|
1179
|
-
if (response === null || response === void 0 ? void 0 : response.data) {
|
|
1180
|
-
const moved = (_f = response === null || response === void 0 ? void 0 : response.data) === null || _f === void 0 ? void 0 : _f.SaveMediaListEntry;
|
|
1181
|
-
console.log(`✅ Entry ${moved === null || moved === void 0 ? void 0 : moved.id}. Moved from ${selectedList} to ${toMoveList}.`);
|
|
1182
|
-
}
|
|
1183
|
-
else {
|
|
1184
|
-
console.error(`\nFailed to move the anime. ${((_h = (_g = response === null || response === void 0 ? void 0 : response.errors) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.message) || "Unknown error"}`);
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
else {
|
|
1189
|
-
console.log(`\nHey, ${yield Auth.MyUserName()}. Your anime list seems to be empty.`);
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
catch (error) {
|
|
1193
|
-
console.error(`\nError from AnimeList. ${error.message}`);
|
|
1194
|
-
}
|
|
1195
|
-
});
|
|
1196
|
-
}
|
|
1197
|
-
static MangaList() {
|
|
1198
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1199
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1200
|
-
try {
|
|
1201
|
-
spinner.start(`Fetching your manga list...`);
|
|
1202
|
-
const mangaList = yield fetcher(currentUserMangaList, {
|
|
1203
|
-
id: yield Auth.MyUserId(),
|
|
1204
|
-
});
|
|
1205
|
-
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) {
|
|
1206
|
-
spinner.stop();
|
|
1207
|
-
const list = (_d = (_c = mangaList === null || mangaList === void 0 ? void 0 : mangaList.data) === null || _c === void 0 ? void 0 : _c.MediaListCollection) === null || _d === void 0 ? void 0 : _d.lists;
|
|
1208
|
-
const { selectedList } = yield inquirer.prompt([
|
|
1209
|
-
{
|
|
1210
|
-
type: "list",
|
|
1211
|
-
name: "selectedList",
|
|
1212
|
-
message: "Select a list to move:",
|
|
1213
|
-
choices: list.map((list) => list.name),
|
|
1214
|
-
},
|
|
1215
|
-
]);
|
|
1216
|
-
const selectedEntries = list.find((list) => list.name === selectedList);
|
|
1217
|
-
if (!selectedEntries || selectedEntries.entries.length === 0) {
|
|
1218
|
-
return console.log("\nNo manga entries found in the selected list.");
|
|
1219
|
-
}
|
|
1220
|
-
const { toMoveList } = yield inquirer.prompt([
|
|
1221
|
-
{
|
|
1222
|
-
type: "list",
|
|
1223
|
-
name: "toMoveList",
|
|
1224
|
-
message: "Select a list to move to:",
|
|
1225
|
-
choices: list.map((list) => list.name),
|
|
1226
|
-
},
|
|
1227
|
-
]);
|
|
1228
|
-
const entries = selectedEntries.entries;
|
|
1229
|
-
for (const entry of entries) {
|
|
1230
|
-
const mediaId = (_e = entry === null || entry === void 0 ? void 0 : entry.media) === null || _e === void 0 ? void 0 : _e.id;
|
|
1231
|
-
const status = entry === null || entry === void 0 ? void 0 : entry.status;
|
|
1232
|
-
// console.log(mediaId, status)
|
|
1233
|
-
const response = yield fetcher(moveListMutation, {
|
|
1234
|
-
mediaId,
|
|
1235
|
-
status,
|
|
1236
|
-
customList: toMoveList,
|
|
1237
|
-
});
|
|
1238
|
-
if (response === null || response === void 0 ? void 0 : response.data) {
|
|
1239
|
-
const moved = (_f = response === null || response === void 0 ? void 0 : response.data) === null || _f === void 0 ? void 0 : _f.SaveMediaListEntry;
|
|
1240
|
-
console.log(`✅ Entry ${moved === null || moved === void 0 ? void 0 : moved.id}. Moved from ${selectedList} to ${toMoveList}.`);
|
|
1241
|
-
}
|
|
1242
|
-
else {
|
|
1243
|
-
console.error(`\nFailed to move the manga. ${((_h = (_g = response === null || response === void 0 ? void 0 : response.errors) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.message) || "Unknown error"}`);
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
else {
|
|
1248
|
-
console.log(`\nHey, ${yield Auth.MyUserName()}. Your manga list seems to be empty.`);
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
catch (error) {
|
|
1252
|
-
console.error(`\nError from MangaList. ${error.message}`);
|
|
1253
|
-
}
|
|
1254
|
-
});
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
export { AniDB, AniList, MoveTo, MyAnimeList };
|
|
1134
|
+
export { AniDB, AniList, MyAnimeList };
|