@irfanshadikrishad/anilist 1.0.7 → 1.0.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.
@@ -8,4 +8,104 @@ interface DeleteMangaResponse {
8
8
  message: string;
9
9
  }[];
10
10
  }
11
- export { DeleteMangaResponse };
11
+ declare enum AniListMediaStatus {
12
+ CURRENT = "CURRENT",
13
+ PLANNING = "PLANNING",
14
+ COMPLETED = "COMPLETED",
15
+ DROPPED = "DROPPED",
16
+ PAUSED = "PAUSED",
17
+ REPEATING = "REPEATING"
18
+ }
19
+ interface MALAnimeXML {
20
+ series_animedb_id: number;
21
+ series_title: string;
22
+ series_type: string;
23
+ series_episodes: number;
24
+ my_id: number;
25
+ my_watched_episodes: number;
26
+ my_start_date: string;
27
+ my_finish_date: string;
28
+ my_rated: string;
29
+ my_score: number;
30
+ my_storage: string;
31
+ my_storage_value: number;
32
+ my_status: string;
33
+ my_comments: string;
34
+ my_times_watched: number;
35
+ my_rewatch_value: string;
36
+ my_priority: string;
37
+ my_tags: string;
38
+ my_rewatching: number;
39
+ my_rewatching_ep: number;
40
+ my_discuss: number;
41
+ my_sns: string;
42
+ update_on_import: number;
43
+ }
44
+ interface MalIdToAnilistIdResponse {
45
+ data?: {
46
+ Media: {
47
+ id: number;
48
+ title: {
49
+ english?: string;
50
+ romaji?: string;
51
+ };
52
+ };
53
+ };
54
+ errors?: {
55
+ message: string;
56
+ }[];
57
+ }
58
+ interface saveAnimeWithProgressResponse {
59
+ data?: {
60
+ SaveMediaListEntry: {
61
+ id: number;
62
+ progress: number;
63
+ hiddenFromStatusLists: boolean;
64
+ };
65
+ };
66
+ errors?: {
67
+ message: string;
68
+ }[];
69
+ }
70
+ declare enum MALAnimeStatus {
71
+ ON_HOLD = "On-Hold",
72
+ DROPPED = "Dropped",
73
+ COMPLETED = "Completed",
74
+ WATCHING = "Watching",
75
+ PLAN_TO_WATCH = "Plan to Watch"
76
+ }
77
+ declare enum MALMangaStatus {
78
+ ON_HOLD = "On-Hold",
79
+ DROPPED = "Dropped",
80
+ COMPLETED = "Completed",
81
+ READING = "Reading",
82
+ PLAN_TO_READ = "Plan to Read"
83
+ }
84
+ interface AnimeList {
85
+ data?: {
86
+ MediaListCollection: {
87
+ lists: [{
88
+ name: string;
89
+ entries: {
90
+ id: number;
91
+ progress: number;
92
+ };
93
+ }];
94
+ };
95
+ };
96
+ errors?: {
97
+ message: string;
98
+ }[];
99
+ }
100
+ interface MediaWithProgress {
101
+ malId: number;
102
+ progress: number;
103
+ status: string;
104
+ episodes?: number;
105
+ chapters?: number;
106
+ title: {
107
+ english?: string;
108
+ romaji?: string;
109
+ };
110
+ }
111
+ export { AniListMediaStatus, AnimeList, DeleteMangaResponse, MALAnimeStatus, MALAnimeXML, MALMangaStatus, MalIdToAnilistIdResponse, MediaWithProgress, saveAnimeWithProgressResponse, };
@@ -1 +1,26 @@
1
- export {};
1
+ var AniListMediaStatus;
2
+ (function (AniListMediaStatus) {
3
+ AniListMediaStatus["CURRENT"] = "CURRENT";
4
+ AniListMediaStatus["PLANNING"] = "PLANNING";
5
+ AniListMediaStatus["COMPLETED"] = "COMPLETED";
6
+ AniListMediaStatus["DROPPED"] = "DROPPED";
7
+ AniListMediaStatus["PAUSED"] = "PAUSED";
8
+ AniListMediaStatus["REPEATING"] = "REPEATING";
9
+ })(AniListMediaStatus || (AniListMediaStatus = {}));
10
+ var MALAnimeStatus;
11
+ (function (MALAnimeStatus) {
12
+ MALAnimeStatus["ON_HOLD"] = "On-Hold";
13
+ MALAnimeStatus["DROPPED"] = "Dropped";
14
+ MALAnimeStatus["COMPLETED"] = "Completed";
15
+ MALAnimeStatus["WATCHING"] = "Watching";
16
+ MALAnimeStatus["PLAN_TO_WATCH"] = "Plan to Watch";
17
+ })(MALAnimeStatus || (MALAnimeStatus = {}));
18
+ var MALMangaStatus;
19
+ (function (MALMangaStatus) {
20
+ MALMangaStatus["ON_HOLD"] = "On-Hold";
21
+ MALMangaStatus["DROPPED"] = "Dropped";
22
+ MALMangaStatus["COMPLETED"] = "Completed";
23
+ MALMangaStatus["READING"] = "Reading";
24
+ MALMangaStatus["PLAN_TO_READ"] = "Plan to Read";
25
+ })(MALMangaStatus || (MALMangaStatus = {}));
26
+ export { AniListMediaStatus, MALAnimeStatus, MALMangaStatus, };
@@ -28,4 +28,12 @@ declare function saveJSONasJSON(js0n: object, dataType: string): Promise<void>;
28
28
  declare function saveJSONasCSV(js0n: object, dataType: string): Promise<void>;
29
29
  declare function importAnimeListFromExportedJSON(): Promise<void>;
30
30
  declare function importMangaListFromExportedJSON(): Promise<void>;
31
- export { aniListEndpoint, redirectUri, getTitle, getNextSeasonAndYear, formatDateObject, removeHtmlAndMarkdown, saveJSONasJSON, saveJSONasCSV, importAnimeListFromExportedJSON, importMangaListFromExportedJSON, };
31
+ declare class MALimport {
32
+ static Anime(): Promise<void>;
33
+ static Manga(): Promise<void>;
34
+ }
35
+ declare class MALexport {
36
+ static Anime(): Promise<void>;
37
+ static Manga(): Promise<void>;
38
+ }
39
+ export { aniListEndpoint, formatDateObject, getNextSeasonAndYear, getTitle, importAnimeListFromExportedJSON, importMangaListFromExportedJSON, MALexport, MALimport, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, };
@@ -7,16 +7,20 @@ 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 fs from "fs";
12
+ import { readdir, readFile, writeFile } from "fs/promises";
10
13
  import inquirer from "inquirer";
14
+ import { parse } from "json2csv";
11
15
  import open from "open";
12
- import { join } from "path";
13
16
  import { homedir } from "os";
17
+ import { join } from "path";
14
18
  import process from "process";
15
- import { parse } from "json2csv";
16
- import { writeFile, readdir, readFile } from "fs/promises";
17
- import { currentUsersName } from "./auth.js";
18
- import { saveAnimeWithProgressMutation, saveMangaWithProgressMutation, } from "./mutations.js";
19
+ import { currentUsersId, currentUsersName, isLoggedIn } from "./auth.js";
19
20
  import { fetcher } from "./fetcher.js";
21
+ import { saveAnimeWithProgressMutation, saveMangaWithProgressMutation, } from "./mutations.js";
22
+ import { currentUserAnimeList, currentUserMangaList, malIdToAnilistAnimeId, malIdToAnilistMangaId, } from "./queries.js";
23
+ import { AniListMediaStatus, MALAnimeStatus, MALMangaStatus, } from "./types.js";
20
24
  const aniListEndpoint = `https://graphql.anilist.co`;
21
25
  const redirectUri = "https://anilist.co/api/v2/oauth/pin";
22
26
  function getTitle(title) {
@@ -136,24 +140,29 @@ function listFilesInDownloadFolder() {
136
140
  return files;
137
141
  });
138
142
  }
139
- function selectFile() {
143
+ function selectFile(fileType) {
140
144
  return __awaiter(this, void 0, void 0, function* () {
141
145
  try {
142
146
  const files = yield listFilesInDownloadFolder();
143
- const onlyJSONfiles = files.filter((file) => file.endsWith(".json"));
144
- if (onlyJSONfiles.length > 0) {
147
+ // Filter to include only files, not directories, with the specified extension
148
+ const onlyFiles = files.filter((file) => {
149
+ const filePath = `./downloads/${file}`; // Adjust this to the correct path
150
+ const isFile = fs.lstatSync(filePath).isFile(); // Check if it's a file
151
+ return isFile && file.endsWith(fileType);
152
+ });
153
+ if (onlyFiles.length > 0) {
145
154
  const answers = yield inquirer.prompt([
146
155
  {
147
156
  type: "list",
148
157
  name: "fileName",
149
158
  message: "Select a file to import:",
150
- choices: onlyJSONfiles,
159
+ choices: onlyFiles,
151
160
  },
152
161
  ]);
153
162
  return answers.fileName;
154
163
  }
155
164
  else {
156
- throw new Error(`\nNo importable JSON file(s) found in download folder.`);
165
+ throw new Error(`\nNo importable ${fileType} file(s) found in download folder.`);
157
166
  }
158
167
  }
159
168
  catch (error) {
@@ -165,7 +174,7 @@ function selectFile() {
165
174
  function importAnimeListFromExportedJSON() {
166
175
  return __awaiter(this, void 0, void 0, function* () {
167
176
  try {
168
- const filename = yield selectFile();
177
+ const filename = yield selectFile(".json");
169
178
  const filePath = join(getDownloadFolderPath(), filename);
170
179
  const fileContent = yield readFile(filePath, "utf8");
171
180
  const importedData = JSON.parse(fileContent);
@@ -211,7 +220,7 @@ function importAnimeListFromExportedJSON() {
211
220
  function importMangaListFromExportedJSON() {
212
221
  return __awaiter(this, void 0, void 0, function* () {
213
222
  try {
214
- const filename = yield selectFile();
223
+ const filename = yield selectFile(".json");
215
224
  const filePath = join(getDownloadFolderPath(), filename);
216
225
  const fileContent = yield readFile(filePath, "utf8");
217
226
  const importedData = JSON.parse(fileContent);
@@ -253,4 +262,320 @@ function importMangaListFromExportedJSON() {
253
262
  }
254
263
  });
255
264
  }
256
- export { aniListEndpoint, redirectUri, getTitle, getNextSeasonAndYear, formatDateObject, removeHtmlAndMarkdown, saveJSONasJSON, saveJSONasCSV, importAnimeListFromExportedJSON, importMangaListFromExportedJSON, };
265
+ class MALimport {
266
+ static Anime() {
267
+ return __awaiter(this, void 0, void 0, function* () {
268
+ var _a, _b;
269
+ try {
270
+ const filename = yield selectFile(".xml");
271
+ const filePath = join(getDownloadFolderPath(), filename);
272
+ const fileContent = yield readFile(filePath, "utf8");
273
+ const parser = new XMLParser();
274
+ if (fileContent) {
275
+ const XMLObject = parser.parse(fileContent);
276
+ if (XMLObject.myanimelist.anime.length > 0) {
277
+ let count = 0;
278
+ const animes = XMLObject.myanimelist.anime;
279
+ for (let anime of animes) {
280
+ const malId = anime.series_animedb_id;
281
+ const progress = anime.my_watched_episodes;
282
+ const statusMap = {
283
+ "On-Hold": AniListMediaStatus.PAUSED,
284
+ "Dropped": AniListMediaStatus.DROPPED,
285
+ "Completed": AniListMediaStatus.COMPLETED,
286
+ "Watching": AniListMediaStatus.CURRENT,
287
+ "Plan to Watch": AniListMediaStatus.PLANNING,
288
+ };
289
+ const status = statusMap[anime.my_status];
290
+ const anilist = yield fetcher(malIdToAnilistAnimeId, { malId });
291
+ try {
292
+ if (anilist && anilist.data.Media.id) {
293
+ const id = anilist.data.Media.id;
294
+ const saveAnime = yield fetcher(saveAnimeWithProgressMutation, {
295
+ mediaId: id,
296
+ progress: progress,
297
+ status: status,
298
+ hiddenFromStatusLists: false,
299
+ private: false,
300
+ });
301
+ if (saveAnime) {
302
+ const entryId = (_b = (_a = saveAnime === null || saveAnime === void 0 ? void 0 : saveAnime.data) === null || _a === void 0 ? void 0 : _a.SaveMediaListEntry) === null || _b === void 0 ? void 0 : _b.id;
303
+ count++;
304
+ console.log(`[${count}] ${entryId} ✅`);
305
+ // rate-limit
306
+ yield new Promise((resolve) => {
307
+ setTimeout(resolve, 1100);
308
+ });
309
+ }
310
+ }
311
+ else {
312
+ console.error(`could not get anilistId for ${malId}`);
313
+ }
314
+ }
315
+ catch (error) {
316
+ console.error(`\nMALimport-200 ${error.message}`);
317
+ }
318
+ }
319
+ }
320
+ else {
321
+ console.log(`\nNo anime list seems to be found.`);
322
+ }
323
+ }
324
+ }
325
+ catch (error) {
326
+ console.error(`\nError from MALimport. ${error.message}`);
327
+ }
328
+ });
329
+ }
330
+ static Manga() {
331
+ return __awaiter(this, void 0, void 0, function* () {
332
+ var _a, _b, _c, _d;
333
+ try {
334
+ const filename = yield selectFile(".xml");
335
+ const filePath = join(getDownloadFolderPath(), filename);
336
+ const fileContent = yield readFile(filePath, "utf8");
337
+ const parser = new XMLParser();
338
+ if (fileContent) {
339
+ const XMLObject = parser.parse(fileContent);
340
+ if (XMLObject.myanimelist.manga.length > 0) {
341
+ let count = 0;
342
+ const mangas = XMLObject.myanimelist.manga;
343
+ for (let manga of mangas) {
344
+ const malId = manga.manga_mangadb_id;
345
+ const progress = manga.my_read_chapters;
346
+ const statusMap = {
347
+ "On-Hold": AniListMediaStatus.PAUSED,
348
+ "Dropped": AniListMediaStatus.DROPPED,
349
+ "Completed": AniListMediaStatus.COMPLETED,
350
+ "Reading": AniListMediaStatus.CURRENT,
351
+ "Plan to Read": AniListMediaStatus.PLANNING,
352
+ };
353
+ const status = statusMap[manga.my_status];
354
+ const anilist = yield fetcher(malIdToAnilistMangaId, {
355
+ malId: malId,
356
+ });
357
+ if ((_b = (_a = anilist === null || anilist === void 0 ? void 0 : anilist.data) === null || _a === void 0 ? void 0 : _a.Media) === null || _b === void 0 ? void 0 : _b.id) {
358
+ const anilistId = (_d = (_c = anilist === null || anilist === void 0 ? void 0 : anilist.data) === null || _c === void 0 ? void 0 : _c.Media) === null || _d === void 0 ? void 0 : _d.id;
359
+ if (anilistId) {
360
+ const saveManga = yield fetcher(saveMangaWithProgressMutation, {
361
+ mediaId: anilistId,
362
+ progress: progress,
363
+ status: status,
364
+ hiddenFromStatusLists: false,
365
+ private: false,
366
+ });
367
+ if (saveManga) {
368
+ const entryId = saveManga.data.SaveMediaListEntry.id;
369
+ count++;
370
+ console.log(`[${count}] ${entryId} ✅`);
371
+ }
372
+ }
373
+ }
374
+ }
375
+ }
376
+ else {
377
+ console.log(`\nNo manga list seems to be found.`);
378
+ }
379
+ }
380
+ }
381
+ catch (error) {
382
+ console.error(`\nError from MALimport. ${error.message}`);
383
+ }
384
+ });
385
+ }
386
+ }
387
+ class MALexport {
388
+ static Anime() {
389
+ return __awaiter(this, void 0, void 0, function* () {
390
+ var _a, _b, _c, _d;
391
+ try {
392
+ if (yield isLoggedIn()) {
393
+ const animeList = yield fetcher(currentUserAnimeList, {
394
+ id: yield currentUsersId(),
395
+ });
396
+ 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) {
397
+ const lists = (_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;
398
+ const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => {
399
+ var _a, _b, _c, _d, _e;
400
+ return ({
401
+ id: (_a = entry === null || entry === void 0 ? void 0 : entry.media) === null || _a === void 0 ? void 0 : _a.id,
402
+ malId: (_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.idMal,
403
+ title: (_c = entry === null || entry === void 0 ? void 0 : entry.media) === null || _c === void 0 ? void 0 : _c.title,
404
+ episodes: (_d = entry === null || entry === void 0 ? void 0 : entry.media) === null || _d === void 0 ? void 0 : _d.episodes,
405
+ siteUrl: (_e = entry === null || entry === void 0 ? void 0 : entry.media) === null || _e === void 0 ? void 0 : _e.siteUrl,
406
+ progress: entry.progress,
407
+ status: entry === null || entry === void 0 ? void 0 : entry.status,
408
+ hiddenFromStatusLists: false,
409
+ });
410
+ }));
411
+ const xmlContent = createAnimeListXML(mediaWithProgress);
412
+ const path = join(getDownloadFolderPath(), `${yield currentUsersName()}@irfanshadikrishad-anilist-myanimelist(anime)-${getFormattedDate()}.xml`);
413
+ yield writeFile(path, yield xmlContent, "utf8");
414
+ console.log(`Generated XML for MyAnimeList.`);
415
+ open(getDownloadFolderPath());
416
+ }
417
+ else {
418
+ console.log(`\nHey, ${yield currentUsersName()}. Your anime list seems to be empty.`);
419
+ }
420
+ }
421
+ }
422
+ catch (error) {
423
+ console.error(`\nError from MALexport. ${error.message}`);
424
+ }
425
+ });
426
+ }
427
+ static Manga() {
428
+ return __awaiter(this, void 0, void 0, function* () {
429
+ var _a, _b, _c, _d;
430
+ try {
431
+ if (!(yield isLoggedIn())) {
432
+ console.log(`\nPlease login to use this feature.`);
433
+ return;
434
+ }
435
+ const mangaList = yield fetcher(currentUserMangaList, {
436
+ id: yield currentUsersId(),
437
+ });
438
+ if (mangaList && ((_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) {
439
+ const lists = (_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;
440
+ const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => {
441
+ var _a, _b, _c;
442
+ return ({
443
+ id: (_a = entry === null || entry === void 0 ? void 0 : entry.media) === null || _a === void 0 ? void 0 : _a.id,
444
+ malId: (_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.idMal,
445
+ title: (_c = entry === null || entry === void 0 ? void 0 : entry.media) === null || _c === void 0 ? void 0 : _c.title,
446
+ private: entry.private,
447
+ chapters: entry.media.chapters,
448
+ progress: entry.progress,
449
+ status: entry === null || entry === void 0 ? void 0 : entry.status,
450
+ hiddenFromStatusLists: entry.hiddenFromStatusLists,
451
+ });
452
+ }));
453
+ const XMLContent = createMangaListXML(mediaWithProgress);
454
+ const path = join(getDownloadFolderPath(), `${yield currentUsersName()}@irfanshadikrishad-anilist-myanimelist(manga)-${getFormattedDate()}.xml`);
455
+ yield writeFile(path, yield XMLContent, "utf8");
456
+ console.log(`Generated XML for MyAnimeList.`);
457
+ open(getDownloadFolderPath());
458
+ }
459
+ else {
460
+ console.log(`\nHey, ${yield currentUsersName()}. Your anime list seems to be empty.`);
461
+ }
462
+ }
463
+ catch (error) {
464
+ console.error(`\nError from MALexport. ${error.message}`);
465
+ }
466
+ });
467
+ }
468
+ }
469
+ function createAnimeXML(malId, progress, status, episodes, title) {
470
+ return `
471
+ <anime>
472
+ <series_animedb_id>${malId}</series_animedb_id>
473
+ <series_title><![CDATA[${title}]]></series_title>
474
+ <series_type>""</series_type>
475
+ <series_episodes>${episodes}</series_episodes>
476
+ <my_id>0</my_id>
477
+ <my_watched_episodes>${progress}</my_watched_episodes>
478
+ <my_start_date>0000-00-00</my_start_date>
479
+ <my_finish_date>0000-00-00</my_finish_date>
480
+ <my_score>0</my_score>
481
+ <my_storage_value>0.00</my_storage_value>
482
+ <my_status>${status}</my_status>
483
+ <my_comments><![CDATA[]]></my_comments>
484
+ <my_times_watched>0</my_times_watched>
485
+ <my_rewatch_value></my_rewatch_value>
486
+ <my_priority>LOW</my_priority>
487
+ <my_tags><![CDATA[]]></my_tags>
488
+ <my_rewatching>0</my_rewatching>
489
+ <my_rewatching_ep>0</my_rewatching_ep>
490
+ <my_discuss>0</my_discuss>
491
+ <my_sns>default</my_sns>
492
+ <update_on_import>1</update_on_import>
493
+ </anime>`;
494
+ }
495
+ function createMangaXML(malId, progress, status, chapters, title) {
496
+ return `
497
+ <manga>
498
+ <manga_mangadb_id>${malId}</manga_mangadb_id>
499
+ <manga_title><![CDATA[${title ? title : "unknown"}]]></manga_title>
500
+ <manga_volumes>0</manga_volumes>
501
+ <manga_chapters>${chapters ? chapters : 0}</manga_chapters>
502
+ <my_id>0</my_id>
503
+ <my_read_chapters>${progress}</my_read_chapters>
504
+ <my_start_date>0000-00-00</my_start_date>
505
+ <my_finish_date>0000-00-00</my_finish_date>
506
+ <my_score>0</my_score>
507
+ <my_status>${status}</my_status>
508
+ <my_reread_value></my_reread_value>
509
+ <my_priority>LOW</my_priority>
510
+ <my_rereading>0</my_rereading>
511
+ <my_discuss>0</my_discuss>
512
+ <update_on_import>1</update_on_import>
513
+ </manga>`;
514
+ }
515
+ function createAnimeListXML(mediaWithProgress) {
516
+ return __awaiter(this, void 0, void 0, function* () {
517
+ const statusMap = {
518
+ PLANNING: MALAnimeStatus.PLAN_TO_WATCH,
519
+ COMPLETED: MALAnimeStatus.COMPLETED,
520
+ CURRENT: MALAnimeStatus.WATCHING,
521
+ PAUSED: MALAnimeStatus.ON_HOLD,
522
+ DROPPED: MALAnimeStatus.DROPPED,
523
+ };
524
+ const xmlEntries = mediaWithProgress.map((anime) => {
525
+ const malId = anime.malId;
526
+ const progress = anime.progress;
527
+ const episodes = anime.episodes;
528
+ const title = getTitle(anime.title);
529
+ const status = statusMap[anime.status];
530
+ return createAnimeXML(malId, progress, status, episodes, title);
531
+ });
532
+ return `<myanimelist>
533
+ <myinfo>
534
+ <user_id/>
535
+ <user_name>${yield currentUsersName()}</user_name>
536
+ <user_export_type>1</user_export_type>
537
+ <user_total_anime>0</user_total_anime>
538
+ <user_total_watching>0</user_total_watching>
539
+ <user_total_completed>0</user_total_completed>
540
+ <user_total_onhold>0</user_total_onhold>
541
+ <user_total_dropped>0</user_total_dropped>
542
+ <user_total_plantowatch>0</user_total_plantowatch>
543
+ </myinfo>
544
+ \n${xmlEntries.join("\n")}\n
545
+ </myanimelist>`;
546
+ });
547
+ }
548
+ function createMangaListXML(mediaWithProgress) {
549
+ return __awaiter(this, void 0, void 0, function* () {
550
+ const statusMap = {
551
+ PLANNING: MALMangaStatus.PLAN_TO_READ,
552
+ COMPLETED: MALMangaStatus.COMPLETED,
553
+ CURRENT: MALMangaStatus.READING,
554
+ PAUSED: MALMangaStatus.ON_HOLD,
555
+ DROPPED: MALMangaStatus.DROPPED,
556
+ };
557
+ const xmlEntries = mediaWithProgress.map((manga) => {
558
+ const malId = manga.malId;
559
+ const progress = manga.progress;
560
+ const chapters = manga.chapters;
561
+ const title = getTitle(manga.title);
562
+ const status = statusMap[manga.status];
563
+ return createMangaXML(malId, progress, status, chapters, title);
564
+ });
565
+ return `<myanimelist>
566
+ <myinfo>
567
+ <user_id/>
568
+ <user_name>${yield currentUsersName()}</user_name>
569
+ <user_export_type>2</user_export_type>
570
+ <user_total_manga>5</user_total_manga>
571
+ <user_total_reading>1</user_total_reading>
572
+ <user_total_completed>1</user_total_completed>
573
+ <user_total_onhold>1</user_total_onhold>
574
+ <user_total_dropped>1</user_total_dropped>
575
+ <user_total_plantoread>1</user_total_plantoread>
576
+ </myinfo>
577
+ \n${xmlEntries.join("\n")}\n
578
+ </myanimelist>`;
579
+ });
580
+ }
581
+ export { aniListEndpoint, formatDateObject, getNextSeasonAndYear, getTitle, importAnimeListFromExportedJSON, importMangaListFromExportedJSON, MALexport, MALimport, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, };
package/bin/index.js CHANGED
@@ -17,7 +17,7 @@ const cli = new Command();
17
17
  cli
18
18
  .name("anilist")
19
19
  .description("Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts.")
20
- .version("1.0.7");
20
+ .version("1.0.8");
21
21
  cli
22
22
  .command("login")
23
23
  .description("Login with AniList")
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@irfanshadikrishad/anilist",
3
3
  "description": "Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts",
4
4
  "author": "Irfan Shadik Rishad",
5
- "version": "1.0.7",
5
+ "version": "1.0.8",
6
6
  "main": "./bin/index.js",
7
7
  "type": "module",
8
8
  "types": "./bin/index.d.ts",
@@ -15,6 +15,7 @@
15
15
  "scripts": {
16
16
  "build": "rm -rf ./bin && tsc -w",
17
17
  "format": "prettier . --write",
18
+ "format:check": "prettier . --check",
18
19
  "lint": "eslint ./dist",
19
20
  "lint:fix": "eslint ./dist --fix"
20
21
  },
@@ -52,15 +53,17 @@
52
53
  "devDependencies": {
53
54
  "@eslint/js": "^9.13.0",
54
55
  "@types/json2csv": "^5.0.7",
55
- "@types/node": "^22.7.7",
56
+ "@types/node": "^22.7.9",
56
57
  "eslint": "^9.13.0",
57
58
  "globals": "^15.11.0",
58
59
  "prettier": "^3.3.3",
60
+ "prettier-plugin-organize-imports": "^4.1.0",
59
61
  "typescript": "^5.6.3",
60
62
  "typescript-eslint": "^8.11.0"
61
63
  },
62
64
  "dependencies": {
63
65
  "commander": "^12.1.0",
66
+ "fast-xml-parser": "^4.5.0",
64
67
  "inquirer": "^12.0.0",
65
68
  "json2csv": "^6.0.0-alpha.2",
66
69
  "node-fetch": "^3.3.2",
package/CHANGELOG.md DELETED
@@ -1,18 +0,0 @@
1
- #### Changelog
2
-
3
- #### v1.0.7
4
-
5
- - Optimization
6
- - Implemented linting
7
- - Implemented preetier
8
- - Implemented github-actions
9
- - No limit on delete command (previously only 50 could be deleted per-command)
10
-
11
- #### v1.0.6
12
-
13
- - Users can import/export the anime or manga list
14
-
15
- #### v1.0.4 - v1.0.5
16
-
17
- - Better error handling
18
- - Write command for writing status
@@ -1,43 +0,0 @@
1
- #### Contributor Covenant Code of Conduct
2
-
3
- #### Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- #### Our Standards
8
-
9
- Examples of behavior that contributes to creating a positive environment include:
10
-
11
- - Using welcoming and inclusive language
12
- - Being respectful of differing viewpoints and experiences
13
- - Gracefully accepting constructive criticism
14
- - Focusing on what is best for the community
15
- - Showing empathy towards other community members
16
-
17
- Examples of unacceptable behavior by participants include:
18
-
19
- - The use of sexualized language or imagery and unwelcome sexual attention or advances
20
- - Trolling, insulting/derogatory comments, and personal or political attacks
21
- - Public or private harassment
22
- - Publishing others' private information, such as a physical or electronic address, without explicit permission
23
- - Other conduct which could reasonably be considered inappropriate in a professional setting
24
-
25
- #### Our Responsibilities
26
-
27
- Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
-
29
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that do not align with this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project.
30
-
31
- #### Scope
32
-
33
- This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
34
-
35
- #### Enforcement
36
-
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [discord](https://discordid.netlify.app/?id=1119275731021725707). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances.
38
-
39
- The project team is obligated to maintain confidentiality with regard to the reporter of an incident.
40
-
41
- #### Attribution
42
-
43
- This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 1.4.