@irfanshadikrishad/anilist 1.7.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,31 +7,31 @@ 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 "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 Spinner from "tiny-spinner";
16
- import { Auth } from "./auth.js";
17
- import { fetcher } from "./fetcher.js";
18
- import { addAnimeToListMutation, addMangaToListMutation, moveListMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, } from "./mutations.js";
19
- import { animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, malIdToAnilistAnimeId, malIdToAnilistMangaId, mangaDetailsQuery, mangaSearchQuery, popularQuery, trendingQuery, upcomingAnimesQuery, userActivityQuery, userFollowersQuery, userFollowingQuery, userQuery, } from "./queries.js";
20
- import { responsiveOutput } from "./truncate.js";
21
- import { AniListMediaStatus, } from "./types.js";
22
- import { Validate } from "./validation.js";
23
- import { anidbToanilistMapper, formatDateObject, getDownloadFolderPath, getNextSeasonAndYear, getTitle, logUserDetails, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, saveJSONasXML, selectFile, simpleDateFormat, timestampToTimeAgo, } from "./workers.js";
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 Spinner from 'tiny-spinner';
16
+ import { Auth } from './auth.js';
17
+ import { fetcher } from './fetcher.js';
18
+ import { addAnimeToListMutation, addMangaToListMutation, moveListMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, } from './mutations.js';
19
+ import { animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, malIdToAnilistAnimeId, malIdToAnilistMangaId, mangaDetailsQuery, mangaSearchQuery, popularQuery, trendingQuery, upcomingAnimesQuery, userActivityQuery, userFollowersQuery, userFollowingQuery, userQuery, } from './queries.js';
20
+ import { responsiveOutput } from './truncate.js';
21
+ import { AniListMediaStatus, } from './types.js';
22
+ import { Validate } from './validation.js';
23
+ import { anidbToanilistMapper, formatDateObject, getDownloadFolderPath, getNextSeasonAndYear, getTitle, logUserDetails, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, saveJSONasXML, selectFile, simpleDateFormat, timestampToTimeAgo, } from './workers.js';
24
24
  const spinner = new Spinner();
25
25
  class AniList {
26
26
  static importAnime() {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
28
  try {
29
- const filename = yield selectFile(".json");
29
+ const filename = yield selectFile('.json');
30
30
  if (!filename) {
31
31
  return;
32
32
  }
33
33
  const filePath = join(getDownloadFolderPath(), filename);
34
- const fileContent = yield readFile(filePath, "utf8");
34
+ const fileContent = yield readFile(filePath, 'utf8');
35
35
  const importedData = JSON.parse(fileContent);
36
36
  if (!Validate.Import_JSON(importedData)) {
37
37
  console.error(`\nInvalid JSON file.`);
@@ -55,7 +55,7 @@ class AniList {
55
55
  if (save) {
56
56
  const id = (_b = (_a = save === null || save === void 0 ? void 0 : save.data) === null || _a === void 0 ? void 0 : _a.SaveMediaListEntry) === null || _b === void 0 ? void 0 : _b.id;
57
57
  count++;
58
- console.log(`[${count}]\t${id}\t${anime === null || anime === void 0 ? void 0 : anime.id} ✅`);
58
+ console.log(`[${count}]\t${id}\t${anime === null || anime === void 0 ? void 0 : anime.id} ✔`);
59
59
  }
60
60
  else {
61
61
  console.error(`\nError saving ${anime === null || anime === void 0 ? void 0 : anime.id}`);
@@ -76,12 +76,12 @@ class AniList {
76
76
  static importManga() {
77
77
  return __awaiter(this, void 0, void 0, function* () {
78
78
  try {
79
- const filename = yield selectFile(".json");
79
+ const filename = yield selectFile('.json');
80
80
  if (!filename) {
81
81
  return;
82
82
  }
83
83
  const filePath = join(getDownloadFolderPath(), filename);
84
- const fileContent = yield readFile(filePath, "utf8");
84
+ const fileContent = yield readFile(filePath, 'utf8');
85
85
  const importedData = JSON.parse(fileContent);
86
86
  if (!Validate.Import_JSON(importedData)) {
87
87
  console.error(`\nInvalid JSON file.`);
@@ -130,13 +130,13 @@ class AniList {
130
130
  }
131
131
  const { exportType } = yield inquirer.prompt([
132
132
  {
133
- type: "list",
134
- name: "exportType",
135
- message: "Choose export type:",
133
+ type: 'list',
134
+ name: 'exportType',
135
+ message: 'Choose export type:',
136
136
  choices: [
137
- { name: "CSV", value: 1 },
138
- { name: "JSON", value: 2 },
139
- { name: "XML (MyAnimeList/AniDB)", value: 3 },
137
+ { name: 'CSV', value: 1 },
138
+ { name: 'JSON', value: 2 },
139
+ { name: 'XML (MyAnimeList/AniDB)', value: 3 },
140
140
  ],
141
141
  pageSize: 10,
142
142
  },
@@ -160,10 +160,10 @@ class AniList {
160
160
  }));
161
161
  switch (exportType) {
162
162
  case 1:
163
- yield saveJSONasCSV(mediaWithProgress, "anime");
163
+ yield saveJSONasCSV(mediaWithProgress, 'anime');
164
164
  break;
165
165
  case 2:
166
- yield saveJSONasJSON(mediaWithProgress, "anime");
166
+ yield saveJSONasJSON(mediaWithProgress, 'anime');
167
167
  break;
168
168
  case 3:
169
169
  yield MyAnimeList.exportAnime();
@@ -196,13 +196,13 @@ class AniList {
196
196
  if (lists.length > 0) {
197
197
  const { exportType } = yield inquirer.prompt([
198
198
  {
199
- type: "list",
200
- name: "exportType",
201
- message: "Choose export type:",
199
+ type: 'list',
200
+ name: 'exportType',
201
+ message: 'Choose export type:',
202
202
  choices: [
203
- { name: "CSV", value: 1 },
204
- { name: "JSON", value: 2 },
205
- { name: "XML (MyAnimeList)", value: 3 },
203
+ { name: 'CSV', value: 1 },
204
+ { name: 'JSON', value: 2 },
205
+ { name: 'XML (MyAnimeList)', value: 3 },
206
206
  ],
207
207
  pageSize: 10,
208
208
  },
@@ -221,10 +221,10 @@ class AniList {
221
221
  }));
222
222
  switch (exportType) {
223
223
  case 1:
224
- yield saveJSONasCSV(mediaWithProgress, "manga");
224
+ yield saveJSONasCSV(mediaWithProgress, 'manga');
225
225
  break;
226
226
  case 2:
227
- yield saveJSONasJSON(mediaWithProgress, "manga");
227
+ yield saveJSONasJSON(mediaWithProgress, 'manga');
228
228
  break;
229
229
  case 3:
230
230
  yield MyAnimeList.exportManga();
@@ -259,9 +259,9 @@ class AniList {
259
259
  }
260
260
  const { selectedList } = yield inquirer.prompt([
261
261
  {
262
- type: "list",
263
- name: "selectedList",
264
- message: "Select an anime list:",
262
+ type: 'list',
263
+ name: 'selectedList',
264
+ message: 'Select an anime list:',
265
265
  choices: lists.map((list) => list.name),
266
266
  },
267
267
  ]);
@@ -272,9 +272,9 @@ class AniList {
272
272
  console.log(`\nEntries for '${selectedEntries.name}':`);
273
273
  const { selectedAnime } = yield inquirer.prompt([
274
274
  {
275
- type: "list",
276
- name: "selectedAnime",
277
- message: "Select anime to add to the list:",
275
+ type: 'list',
276
+ name: 'selectedAnime',
277
+ message: 'Select anime to add to the list:',
278
278
  choices: selectedEntries.entries.map((entry, idx) => ({
279
279
  name: `[${idx + 1}] ${getTitle(entry.media.title)}`,
280
280
  value: entry.media.id,
@@ -284,15 +284,15 @@ class AniList {
284
284
  ]);
285
285
  const { selectedListType } = yield inquirer.prompt([
286
286
  {
287
- type: "list",
288
- name: "selectedListType",
289
- message: "Select the list where you want to save this anime:",
287
+ type: 'list',
288
+ name: 'selectedListType',
289
+ message: 'Select the list where you want to save this anime:',
290
290
  choices: [
291
- { name: "Planning", value: "PLANNING" },
292
- { name: "Watching", value: "CURRENT" },
293
- { name: "Completed", value: "COMPLETED" },
294
- { name: "Paused", value: "PAUSED" },
295
- { name: "Dropped", value: "DROPPED" },
291
+ { name: 'Planning', value: 'PLANNING' },
292
+ { name: 'Watching', value: 'CURRENT' },
293
+ { name: 'Completed', value: 'COMPLETED' },
294
+ { name: 'Paused', value: 'PAUSED' },
295
+ { name: 'Dropped', value: 'DROPPED' },
296
296
  ],
297
297
  },
298
298
  ]);
@@ -326,7 +326,7 @@ class AniList {
326
326
  }
327
327
  const response = yield fetcher(currentUserMangaList, { id: userId });
328
328
  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) || "Unknown error"}`);
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) || 'Unknown error'}`);
330
330
  }
331
331
  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
332
  if (!lists || lists.length === 0) {
@@ -334,22 +334,22 @@ class AniList {
334
334
  }
335
335
  const { selectedList } = yield inquirer.prompt([
336
336
  {
337
- type: "list",
338
- name: "selectedList",
339
- message: "Select a manga list:",
337
+ type: 'list',
338
+ name: 'selectedList',
339
+ message: 'Select a manga list:',
340
340
  choices: lists.map((list) => list.name),
341
341
  },
342
342
  ]);
343
343
  const selectedEntries = lists.find((list) => list.name === selectedList);
344
344
  if (!selectedEntries || selectedEntries.entries.length === 0) {
345
- return console.log("\nNo manga entries found in the selected list.");
345
+ return console.log('\nNo manga entries found in the selected list.');
346
346
  }
347
347
  console.log(`\nEntries for '${selectedEntries.name}':`);
348
348
  const { selectedManga } = yield inquirer.prompt([
349
349
  {
350
- type: "list",
351
- name: "selectedManga",
352
- message: "Select a manga to add to the list:",
350
+ type: 'list',
351
+ name: 'selectedManga',
352
+ message: 'Select a manga to add to the list:',
353
353
  choices: selectedEntries.entries.map((entry, idx) => {
354
354
  var _a;
355
355
  return ({
@@ -362,15 +362,15 @@ class AniList {
362
362
  ]);
363
363
  const { selectedListType } = yield inquirer.prompt([
364
364
  {
365
- type: "list",
366
- name: "selectedListType",
367
- message: "Select the list where you want to save this manga:",
365
+ type: 'list',
366
+ name: 'selectedListType',
367
+ message: 'Select the list where you want to save this manga:',
368
368
  choices: [
369
- { name: "Planning", value: "PLANNING" },
370
- { name: "Reading", value: "CURRENT" },
371
- { name: "Completed", value: "COMPLETED" },
372
- { name: "Paused", value: "PAUSED" },
373
- { name: "Dropped", value: "DROPPED" },
369
+ { name: 'Planning', value: 'PLANNING' },
370
+ { name: 'Reading', value: 'CURRENT' },
371
+ { name: 'Completed', value: 'COMPLETED' },
372
+ { name: 'Paused', value: 'PAUSED' },
373
+ { name: 'Dropped', value: 'DROPPED' },
374
374
  ],
375
375
  },
376
376
  ]);
@@ -383,7 +383,7 @@ class AniList {
383
383
  console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
384
384
  }
385
385
  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) || "Unknown error"}`);
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) || 'Unknown error'}`);
387
387
  }
388
388
  }
389
389
  catch (error) {
@@ -400,7 +400,7 @@ class AniList {
400
400
  while (true) {
401
401
  const response = yield fetcher(trendingQuery, { page, perPage: count });
402
402
  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) || "Unknown error"}`);
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) || 'Unknown error'}`);
404
404
  return;
405
405
  }
406
406
  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 +413,32 @@ class AniList {
413
413
  name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
414
414
  value: String(anime === null || anime === void 0 ? void 0 : anime.id),
415
415
  }));
416
- choices.push({ name: "See more", value: "see_more" });
416
+ choices.push({ name: 'See more', value: 'see_more' });
417
417
  const { selectedAnime } = yield inquirer.prompt([
418
418
  {
419
- type: "list",
420
- name: "selectedAnime",
421
- message: "Select anime to add to the list:",
419
+ type: 'list',
420
+ name: 'selectedAnime',
421
+ message: 'Select anime to add to the list:',
422
422
  choices,
423
423
  pageSize: choices.length + 1,
424
424
  },
425
425
  ]);
426
- if (selectedAnime === "see_more") {
426
+ if (selectedAnime === 'see_more') {
427
427
  page++;
428
428
  continue;
429
429
  }
430
430
  else {
431
431
  const { selectedListType } = yield inquirer.prompt([
432
432
  {
433
- type: "list",
434
- name: "selectedListType",
435
- message: "Select the list where you want to save this anime:",
433
+ type: 'list',
434
+ name: 'selectedListType',
435
+ message: 'Select the list where you want to save this anime:',
436
436
  choices: [
437
- { name: "Planning", value: "PLANNING" },
438
- { name: "Watching", value: "CURRENT" },
439
- { name: "Completed", value: "COMPLETED" },
440
- { name: "Paused", value: "PAUSED" },
441
- { name: "Dropped", value: "DROPPED" },
437
+ { name: 'Planning', value: 'PLANNING' },
438
+ { name: 'Watching', value: 'CURRENT' },
439
+ { name: 'Completed', value: 'COMPLETED' },
440
+ { name: 'Paused', value: 'PAUSED' },
441
+ { name: 'Dropped', value: 'DROPPED' },
442
442
  ],
443
443
  },
444
444
  ]);
@@ -453,7 +453,7 @@ class AniList {
453
453
  console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
454
454
  }
455
455
  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) || "Unknown error"}`);
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) || 'Unknown error'}`);
457
457
  }
458
458
  break;
459
459
  }
@@ -473,7 +473,7 @@ class AniList {
473
473
  while (true) {
474
474
  const response = yield fetcher(popularQuery, { page, perPage: count });
475
475
  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) || "Unknown error"}`);
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) || 'Unknown error'}`);
477
477
  return;
478
478
  }
479
479
  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 +486,32 @@ class AniList {
486
486
  name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
487
487
  value: String(anime === null || anime === void 0 ? void 0 : anime.id),
488
488
  }));
489
- choices.push({ name: "See more", value: "see_more" });
489
+ choices.push({ name: 'See more', value: 'see_more' });
490
490
  const { selectedAnime } = yield inquirer.prompt([
491
491
  {
492
- type: "list",
493
- name: "selectedAnime",
494
- message: "Select anime to add to the list:",
492
+ type: 'list',
493
+ name: 'selectedAnime',
494
+ message: 'Select anime to add to the list:',
495
495
  choices,
496
496
  pageSize: choices.length,
497
497
  },
498
498
  ]);
499
- if (selectedAnime === "see_more") {
499
+ if (selectedAnime === 'see_more') {
500
500
  page++;
501
501
  continue;
502
502
  }
503
503
  else {
504
504
  const { selectedListType } = yield inquirer.prompt([
505
505
  {
506
- type: "list",
507
- name: "selectedListType",
508
- message: "Select the list where you want to save this anime:",
506
+ type: 'list',
507
+ name: 'selectedListType',
508
+ message: 'Select the list where you want to save this anime:',
509
509
  choices: [
510
- { name: "Planning", value: "PLANNING" },
511
- { name: "Watching", value: "CURRENT" },
512
- { name: "Completed", value: "COMPLETED" },
513
- { name: "Paused", value: "PAUSED" },
514
- { name: "Dropped", value: "DROPPED" },
510
+ { name: 'Planning', value: 'PLANNING' },
511
+ { name: 'Watching', value: 'CURRENT' },
512
+ { name: 'Completed', value: 'COMPLETED' },
513
+ { name: 'Paused', value: 'PAUSED' },
514
+ { name: 'Dropped', value: 'DROPPED' },
515
515
  ],
516
516
  },
517
517
  ]);
@@ -525,7 +525,7 @@ class AniList {
525
525
  console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
526
526
  }
527
527
  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) || "Unknown error"}`);
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) || 'Unknown error'}`);
529
529
  }
530
530
  break;
531
531
  }
@@ -551,7 +551,7 @@ class AniList {
551
551
  perPage: count,
552
552
  });
553
553
  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) || "Unknown error"}`);
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) || 'Unknown error'}`);
555
555
  return;
556
556
  }
557
557
  const newUpcoming = (_c = request.data.Page.media) !== null && _c !== void 0 ? _c : [];
@@ -564,32 +564,32 @@ class AniList {
564
564
  name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
565
565
  value: String(anime === null || anime === void 0 ? void 0 : anime.id),
566
566
  }));
567
- choices.push({ name: "See more", value: "see_more" });
567
+ choices.push({ name: 'See more', value: 'see_more' });
568
568
  const { selectedAnime } = yield inquirer.prompt([
569
569
  {
570
- type: "list",
571
- name: "selectedAnime",
572
- message: "Select anime to add to the list:",
570
+ type: 'list',
571
+ name: 'selectedAnime',
572
+ message: 'Select anime to add to the list:',
573
573
  choices,
574
574
  pageSize: choices.length + 2,
575
575
  },
576
576
  ]);
577
- if (selectedAnime === "see_more") {
577
+ if (selectedAnime === 'see_more') {
578
578
  page++;
579
579
  continue;
580
580
  }
581
581
  else {
582
582
  const { selectedListType } = yield inquirer.prompt([
583
583
  {
584
- type: "list",
585
- name: "selectedListType",
586
- message: "Select the list where you want to save this anime:",
584
+ type: 'list',
585
+ name: 'selectedListType',
586
+ message: 'Select the list where you want to save this anime:',
587
587
  choices: [
588
- { name: "Planning", value: "PLANNING" },
589
- { name: "Watching", value: "CURRENT" },
590
- { name: "Completed", value: "COMPLETED" },
591
- { name: "Paused", value: "PAUSED" },
592
- { name: "Dropped", value: "DROPPED" },
588
+ { name: 'Planning', value: 'PLANNING' },
589
+ { name: 'Watching', value: 'CURRENT' },
590
+ { name: 'Completed', value: 'COMPLETED' },
591
+ { name: 'Paused', value: 'PAUSED' },
592
+ { name: 'Dropped', value: 'DROPPED' },
593
593
  ],
594
594
  },
595
595
  ]);
@@ -603,7 +603,7 @@ class AniList {
603
603
  console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
604
604
  }
605
605
  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) || "Unknown error"}`);
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) || 'Unknown error'}`);
607
607
  }
608
608
  break;
609
609
  }
@@ -620,7 +620,7 @@ class AniList {
620
620
  try {
621
621
  const response = yield fetcher(userQuery, { username });
622
622
  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) || "Unknown error"}`);
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) || 'Unknown error'}`);
624
624
  }
625
625
  const user = response.data.User;
626
626
  const userActivityResponse = yield fetcher(userActivityQuery, {
@@ -642,11 +642,11 @@ class AniList {
642
642
  if (activities.length > 0) {
643
643
  console.log(`\nRecent Activities:`);
644
644
  activities.forEach(({ status, progress, media, createdAt }) => {
645
- responsiveOutput(`${timestampToTimeAgo(createdAt)}\t${status} ${progress ? `${progress} of ` : ""}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
645
+ responsiveOutput(`${timestampToTimeAgo(createdAt)}\t${status} ${progress ? `${progress} of ` : ''}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
646
646
  });
647
647
  }
648
648
  else {
649
- console.log("\nNo recent activities.");
649
+ console.log('\nNo recent activities.');
650
650
  }
651
651
  }
652
652
  catch (error) {
@@ -665,16 +665,16 @@ class AniList {
665
665
  console.log(`\nID: ${id}`);
666
666
  console.log(`Title: ${(title === null || title === void 0 ? void 0 : title.userPreferred) || getTitle(title)}`);
667
667
  console.log(`Description: ${removeHtmlAndMarkdown(description)}`);
668
- console.log(`Episode Duration: ${duration || "Unknown"} min`);
669
- console.log(`Origin: ${countryOfOrigin || "N/A"}`);
670
- console.log(`Status: ${status || "N/A"}`);
671
- console.log(`Format: ${format || "N/A"}`);
672
- console.log(`Genres: ${genres.length ? genres.join(", ") : "N/A"}`);
673
- console.log(`Season: ${season || "N/A"}`);
674
- console.log(`Url: ${siteUrl || "N/A"}`);
675
- console.log(`isAdult: ${isAdult ? "Yes" : "No"}`);
676
- console.log(`Released: ${formatDateObject(startDate) || "Unknown"}`);
677
- console.log(`Finished: ${formatDateObject(endDate) || "Ongoing"}`);
668
+ console.log(`Episode Duration: ${duration || 'Unknown'} min`);
669
+ console.log(`Origin: ${countryOfOrigin || 'N/A'}`);
670
+ console.log(`Status: ${status || 'N/A'}`);
671
+ console.log(`Format: ${format || 'N/A'}`);
672
+ console.log(`Genres: ${genres.length ? genres.join(', ') : 'N/A'}`);
673
+ console.log(`Season: ${season || 'N/A'}`);
674
+ console.log(`Url: ${siteUrl || 'N/A'}`);
675
+ console.log(`isAdult: ${isAdult ? 'Yes' : 'No'}`);
676
+ console.log(`Released: ${formatDateObject(startDate) || 'Unknown'}`);
677
+ console.log(`Finished: ${formatDateObject(endDate) || 'Ongoing'}`);
678
678
  }
679
679
  });
680
680
  }
@@ -695,7 +695,7 @@ class AniList {
695
695
  console.log(`${manga.description}`);
696
696
  console.log(`Chapters: ${manga.chapters}\t Volumes: ${manga.volumes}`);
697
697
  console.log(`Status:\t${manga.status}`);
698
- console.log(`Genres:\t${manga.genres.join(", ")}`);
698
+ console.log(`Genres:\t${manga.genres.join(', ')}`);
699
699
  console.log(`Start:\t${simpleDateFormat(manga.startDate)}`);
700
700
  console.log(`End:\t${simpleDateFormat(manga.endDate)}`);
701
701
  }
@@ -718,9 +718,9 @@ class AniList {
718
718
  if (results.length > 0) {
719
719
  const { selectedAnime } = yield inquirer.prompt([
720
720
  {
721
- type: "list",
722
- name: "selectedAnime",
723
- message: "Select anime to add to your list:",
721
+ type: 'list',
722
+ name: 'selectedAnime',
723
+ message: 'Select anime to add to your list:',
724
724
  choices: results.map((res, idx) => ({
725
725
  name: `[${idx + 1}] ${getTitle(res === null || res === void 0 ? void 0 : res.title)}`,
726
726
  value: res === null || res === void 0 ? void 0 : res.id,
@@ -730,15 +730,15 @@ class AniList {
730
730
  ]);
731
731
  const { selectedListType } = yield inquirer.prompt([
732
732
  {
733
- type: "list",
734
- name: "selectedListType",
735
- message: "Select the list where you want to save this anime:",
733
+ type: 'list',
734
+ name: 'selectedListType',
735
+ message: 'Select the list where you want to save this anime:',
736
736
  choices: [
737
- { name: "Planning", value: "PLANNING" },
738
- { name: "Watching", value: "CURRENT" },
739
- { name: "Completed", value: "COMPLETED" },
740
- { name: "Paused", value: "PAUSED" },
741
- { name: "Dropped", value: "DROPPED" },
737
+ { name: 'Planning', value: 'PLANNING' },
738
+ { name: 'Watching', value: 'CURRENT' },
739
+ { name: 'Completed', value: 'COMPLETED' },
740
+ { name: 'Paused', value: 'PAUSED' },
741
+ { name: 'Dropped', value: 'DROPPED' },
742
742
  ],
743
743
  },
744
744
  ]);
@@ -779,9 +779,9 @@ class AniList {
779
779
  // List of manga search results
780
780
  const { selectedMangaId } = yield inquirer.prompt([
781
781
  {
782
- type: "list",
783
- name: "selectedMangaId",
784
- message: "Select manga to add to your list:",
782
+ type: 'list',
783
+ name: 'selectedMangaId',
784
+ message: 'Select manga to add to your list:',
785
785
  choices: results.map((res, idx) => ({
786
786
  name: `[${idx + 1}] ${getTitle(res === null || res === void 0 ? void 0 : res.title)}`,
787
787
  value: res === null || res === void 0 ? void 0 : res.id,
@@ -792,15 +792,15 @@ class AniList {
792
792
  // Options to save to the list
793
793
  const { selectedListType } = yield inquirer.prompt([
794
794
  {
795
- type: "list",
796
- name: "selectedListType",
797
- message: "Select the list where you want to save this manga:",
795
+ type: 'list',
796
+ name: 'selectedListType',
797
+ message: 'Select the list where you want to save this manga:',
798
798
  choices: [
799
- { name: "Planning", value: "PLANNING" },
800
- { name: "Reading", value: "CURRENT" },
801
- { name: "Completed", value: "COMPLETED" },
802
- { name: "Paused", value: "PAUSED" },
803
- { name: "Dropped", value: "DROPPED" },
799
+ { name: 'Planning', value: 'PLANNING' },
800
+ { name: 'Reading', value: 'CURRENT' },
801
+ { name: 'Completed', value: 'COMPLETED' },
802
+ { name: 'Paused', value: 'PAUSED' },
803
+ { name: 'Dropped', value: 'DROPPED' },
804
804
  ],
805
805
  },
806
806
  ]);
@@ -830,12 +830,12 @@ class MyAnimeList {
830
830
  return __awaiter(this, void 0, void 0, function* () {
831
831
  var _a, _b, _c, _d, _e;
832
832
  try {
833
- const filename = yield selectFile(".xml");
833
+ const filename = yield selectFile('.xml');
834
834
  if (!filename) {
835
835
  return;
836
836
  }
837
837
  const filePath = join(getDownloadFolderPath(), filename);
838
- const fileContent = yield readFile(filePath, "utf8");
838
+ const fileContent = yield readFile(filePath, 'utf8');
839
839
  if (!(yield Validate.Import_AnimeXML(fileContent))) {
840
840
  console.error(`\nInvalid XML file.`);
841
841
  return;
@@ -847,11 +847,11 @@ class MyAnimeList {
847
847
  if ((animeList === null || animeList === void 0 ? void 0 : animeList.length) > 0) {
848
848
  let count = 0;
849
849
  const statusMap = {
850
- "On-Hold": AniListMediaStatus.PAUSED,
851
- "Dropped": AniListMediaStatus.DROPPED,
852
- "Completed": AniListMediaStatus.COMPLETED,
853
- "Watching": AniListMediaStatus.CURRENT,
854
- "Plan to Watch": AniListMediaStatus.PLANNING,
850
+ 'On-Hold': AniListMediaStatus.PAUSED,
851
+ 'Dropped': AniListMediaStatus.DROPPED,
852
+ 'Completed': AniListMediaStatus.COMPLETED,
853
+ 'Watching': AniListMediaStatus.CURRENT,
854
+ 'Plan to Watch': AniListMediaStatus.PLANNING,
855
855
  };
856
856
  for (const anime of animeList) {
857
857
  const malId = anime.series_animedb_id;
@@ -873,7 +873,7 @@ class MyAnimeList {
873
873
  const entryId = (_e = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _d === void 0 ? void 0 : _d.SaveMediaListEntry) === null || _e === void 0 ? void 0 : _e.id;
874
874
  if (entryId) {
875
875
  count++;
876
- console.log(`[${count}] ${entryId} ✅`);
876
+ console.log(`[${count}] ${entryId} ✔`);
877
877
  }
878
878
  }
879
879
  else {
@@ -900,12 +900,12 @@ class MyAnimeList {
900
900
  return __awaiter(this, void 0, void 0, function* () {
901
901
  var _a, _b, _c, _d, _e;
902
902
  try {
903
- const filename = yield selectFile(".xml");
903
+ const filename = yield selectFile('.xml');
904
904
  if (!filename) {
905
905
  return;
906
906
  }
907
907
  const filePath = join(getDownloadFolderPath(), filename);
908
- const fileContent = yield readFile(filePath, "utf8");
908
+ const fileContent = yield readFile(filePath, 'utf8');
909
909
  if (!(yield Validate.Import_MangaXML(fileContent))) {
910
910
  console.error(`\nInvalid XML file.`);
911
911
  return;
@@ -917,11 +917,11 @@ class MyAnimeList {
917
917
  if ((mangas === null || mangas === void 0 ? void 0 : mangas.length) > 0) {
918
918
  let count = 0;
919
919
  const statusMap = {
920
- "On-Hold": AniListMediaStatus.PAUSED,
921
- "Dropped": AniListMediaStatus.DROPPED,
922
- "Completed": AniListMediaStatus.COMPLETED,
923
- "Reading": AniListMediaStatus.CURRENT,
924
- "Plan to Read": AniListMediaStatus.PLANNING,
920
+ 'On-Hold': AniListMediaStatus.PAUSED,
921
+ 'Dropped': AniListMediaStatus.DROPPED,
922
+ 'Completed': AniListMediaStatus.COMPLETED,
923
+ 'Reading': AniListMediaStatus.CURRENT,
924
+ 'Plan to Read': AniListMediaStatus.PLANNING,
925
925
  };
926
926
  for (const manga of mangas) {
927
927
  const malId = manga.manga_mangadb_id;
@@ -943,7 +943,7 @@ class MyAnimeList {
943
943
  const entryId = (_e = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _d === void 0 ? void 0 : _d.SaveMediaListEntry) === null || _e === void 0 ? void 0 : _e.id;
944
944
  if (entryId) {
945
945
  count++;
946
- console.log(`[${count}] ${entryId} ✅`);
946
+ console.log(`[${count}] ${entryId} ✔`);
947
947
  }
948
948
  else {
949
949
  console.error(`Failed to save entry for ${malId}`);
@@ -1044,13 +1044,24 @@ class AniDB {
1044
1044
  static importAnime() {
1045
1045
  return __awaiter(this, void 0, void 0, function* () {
1046
1046
  var _a, _b;
1047
+ function getStatus(anidbStatus, episodesSeen) {
1048
+ if (anidbStatus === 'complete') {
1049
+ return AniListMediaStatus.COMPLETED;
1050
+ }
1051
+ else if (anidbStatus === 'incomplete' && Number(episodesSeen) > 0) {
1052
+ return AniListMediaStatus.CURRENT;
1053
+ }
1054
+ else {
1055
+ return AniListMediaStatus.PLANNING;
1056
+ }
1057
+ }
1047
1058
  try {
1048
- const filename = yield selectFile(".json");
1059
+ const filename = yield selectFile('.json');
1049
1060
  if (!filename) {
1050
1061
  return;
1051
1062
  }
1052
1063
  const filePath = join(getDownloadFolderPath(), filename);
1053
- const fileContent = yield readFile(filePath, "utf8");
1064
+ const fileContent = yield readFile(filePath, 'utf8');
1054
1065
  const js0n_repaired = jsonrepair(fileContent);
1055
1066
  if (!(yield Validate.Import_AniDBJSONLarge(js0n_repaired))) {
1056
1067
  console.error(`\nInvalid JSON Large file.`);
@@ -1073,19 +1084,7 @@ class AniDB {
1073
1084
  const ownEpisodes = anime.ownEpisodes;
1074
1085
  const romanjiName = anime.romanjiName;
1075
1086
  const englishName = anime.englishName;
1076
- function getStatus(anidbStatus, episodesSeen) {
1077
- if (anidbStatus === "complete") {
1078
- return AniListMediaStatus.COMPLETED;
1079
- }
1080
- else if (anidbStatus === "incomplete" &&
1081
- Number(episodesSeen) > 0) {
1082
- return AniListMediaStatus.CURRENT;
1083
- }
1084
- else {
1085
- return AniListMediaStatus.PLANNING;
1086
- }
1087
- }
1088
- let anilistId = yield anidbToanilistMapper(romanjiName, Number(released.split(".")[2]), englishName);
1087
+ const anilistId = yield anidbToanilistMapper(romanjiName, Number(released.split('.')[2]), englishName);
1089
1088
  if (anilistId) {
1090
1089
  try {
1091
1090
  const saveResponse = yield fetcher(saveAnimeWithProgressMutation, {
@@ -1098,7 +1097,7 @@ class AniDB {
1098
1097
  const entryId = (_b = (_a = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _a === void 0 ? void 0 : _a.SaveMediaListEntry) === null || _b === void 0 ? void 0 : _b.id;
1099
1098
  if (entryId) {
1100
1099
  count++;
1101
- responsiveOutput(`[${count}]\t${entryId} ✅\t${anidbId}\t${anilistId}\t(${ownEpisodes}/${totalEpisodes})\t${status}–>${getStatus(status, ownEpisodes)}`);
1100
+ responsiveOutput(`[${count}]\t${entryId} ✔\t${anidbId}\t${anilistId}\t(${ownEpisodes}/${totalEpisodes})\t${status}–>${getStatus(status, ownEpisodes)}`);
1102
1101
  }
1103
1102
  }
1104
1103
  catch (error) {
@@ -1116,7 +1115,7 @@ class AniDB {
1116
1115
  responsiveOutput(`\nAccuracy: ${(((animeList.length - missed.length) / animeList.length) * 100).toFixed(2)}%\tTotal Processed: ${iteration}\tMissed: ${missed.length}`);
1117
1116
  if (missed.length > 0) {
1118
1117
  responsiveOutput(`Exporting missed entries to JSON file, Please add them manually.`);
1119
- yield saveJSONasJSON(missed, "anidb-missed");
1118
+ yield saveJSONasJSON(missed, 'anidb-missed');
1120
1119
  }
1121
1120
  }
1122
1121
  else {
@@ -1147,21 +1146,21 @@ class MoveTo {
1147
1146
  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
1147
  const { selectedList } = yield inquirer.prompt([
1149
1148
  {
1150
- type: "list",
1151
- name: "selectedList",
1152
- message: "Select a list to move:",
1149
+ type: 'list',
1150
+ name: 'selectedList',
1151
+ message: 'Select a list to move:',
1153
1152
  choices: list.map((list) => list.name),
1154
1153
  },
1155
1154
  ]);
1156
1155
  const selectedEntries = list.find((list) => list.name === selectedList);
1157
1156
  if (!selectedEntries || selectedEntries.entries.length === 0) {
1158
- return console.log("\nNo anime entries found in the selected list.");
1157
+ return console.log('\nNo anime entries found in the selected list.');
1159
1158
  }
1160
1159
  const { toMoveList } = yield inquirer.prompt([
1161
1160
  {
1162
- type: "list",
1163
- name: "toMoveList",
1164
- message: "Select a list to move to:",
1161
+ type: 'list',
1162
+ name: 'toMoveList',
1163
+ message: 'Select a list to move to:',
1165
1164
  choices: list.map((list) => list.name),
1166
1165
  },
1167
1166
  ]);
@@ -1178,10 +1177,10 @@ class MoveTo {
1178
1177
  });
1179
1178
  if (response === null || response === void 0 ? void 0 : response.data) {
1180
1179
  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}.`);
1180
+ console.log(`✔ Entry ${moved === null || moved === void 0 ? void 0 : moved.id}. Moved from ${selectedList} to ${toMoveList}.`);
1182
1181
  }
1183
1182
  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"}`);
1183
+ 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
1184
  }
1186
1185
  }
1187
1186
  }
@@ -1207,21 +1206,21 @@ class MoveTo {
1207
1206
  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
1207
  const { selectedList } = yield inquirer.prompt([
1209
1208
  {
1210
- type: "list",
1211
- name: "selectedList",
1212
- message: "Select a list to move:",
1209
+ type: 'list',
1210
+ name: 'selectedList',
1211
+ message: 'Select a list to move:',
1213
1212
  choices: list.map((list) => list.name),
1214
1213
  },
1215
1214
  ]);
1216
1215
  const selectedEntries = list.find((list) => list.name === selectedList);
1217
1216
  if (!selectedEntries || selectedEntries.entries.length === 0) {
1218
- return console.log("\nNo manga entries found in the selected list.");
1217
+ return console.log('\nNo manga entries found in the selected list.');
1219
1218
  }
1220
1219
  const { toMoveList } = yield inquirer.prompt([
1221
1220
  {
1222
- type: "list",
1223
- name: "toMoveList",
1224
- message: "Select a list to move to:",
1221
+ type: 'list',
1222
+ name: 'toMoveList',
1223
+ message: 'Select a list to move to:',
1225
1224
  choices: list.map((list) => list.name),
1226
1225
  },
1227
1226
  ]);
@@ -1240,7 +1239,7 @@ class MoveTo {
1240
1239
  console.log(`✅ Entry ${moved === null || moved === void 0 ? void 0 : moved.id}. Moved from ${selectedList} to ${toMoveList}.`);
1241
1240
  }
1242
1241
  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"}`);
1242
+ 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
1243
  }
1245
1244
  }
1246
1245
  }