@irfanshadikrishad/anilist 1.0.8 → 1.1.0-forbidden.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,20 +7,16 @@ 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
10
  import fs from "fs";
12
- import { readdir, readFile, writeFile } from "fs/promises";
11
+ import { readdir, writeFile } from "fs/promises";
13
12
  import inquirer from "inquirer";
14
13
  import { parse } from "json2csv";
15
14
  import open from "open";
16
15
  import { homedir } from "os";
17
16
  import { join } from "path";
18
17
  import process from "process";
19
- import { currentUsersId, currentUsersName, isLoggedIn } from "./auth.js";
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";
18
+ import { Auth } from "./auth.js";
19
+ import { MALAnimeStatus, MALMangaStatus } from "./types.js";
24
20
  const aniListEndpoint = `https://graphql.anilist.co`;
25
21
  const redirectUri = "https://anilist.co/api/v2/oauth/pin";
26
22
  function getTitle(title) {
@@ -104,7 +100,7 @@ function saveJSONasJSON(js0n, dataType) {
104
100
  return __awaiter(this, void 0, void 0, function* () {
105
101
  try {
106
102
  const jsonData = JSON.stringify(js0n, null, 2);
107
- const path = join(getDownloadFolderPath(), `${yield currentUsersName()}@irfanshadikrishad-anilist-${dataType}-${getFormattedDate()}.json`);
103
+ const path = join(getDownloadFolderPath(), `${yield Auth.MyUserName()}@irfanshadikrishad-anilist-${dataType}-${getFormattedDate()}.json`);
108
104
  yield writeFile(path, jsonData, "utf8");
109
105
  console.log(`\nSaved as JSON successfully.`);
110
106
  open(getDownloadFolderPath());
@@ -123,7 +119,7 @@ function saveJSONasCSV(js0n, dataType) {
123
119
  return __awaiter(this, void 0, void 0, function* () {
124
120
  try {
125
121
  const csvData = parse(js0n);
126
- const path = join(getDownloadFolderPath(), `${yield currentUsersName()}@irfanshadikrishad-anilist-${dataType}-${getFormattedDate()}.csv`);
122
+ const path = join(getDownloadFolderPath(), `${yield Auth.MyUserName()}@irfanshadikrishad-anilist-${dataType}-${getFormattedDate()}.csv`);
127
123
  yield writeFile(path, csvData, "utf8");
128
124
  console.log(`\nSaved as CSV successfully.`);
129
125
  open(getDownloadFolderPath());
@@ -171,345 +167,50 @@ function selectFile(fileType) {
171
167
  }
172
168
  });
173
169
  }
174
- function importAnimeListFromExportedJSON() {
175
- return __awaiter(this, void 0, void 0, function* () {
176
- try {
177
- const filename = yield selectFile(".json");
178
- const filePath = join(getDownloadFolderPath(), filename);
179
- const fileContent = yield readFile(filePath, "utf8");
180
- const importedData = JSON.parse(fileContent);
181
- let count = 0;
182
- const batchSize = 1; // Number of requests in each batch
183
- const delay = 2000; // delay to avoid rate-limiting
184
- for (let i = 0; i < importedData.length; i += batchSize) {
185
- const batch = importedData.slice(i, i + batchSize);
186
- yield Promise.all(batch.map((anime) => __awaiter(this, void 0, void 0, function* () {
187
- var _a, _b;
188
- const query = saveAnimeWithProgressMutation;
189
- const variables = {
190
- mediaId: anime === null || anime === void 0 ? void 0 : anime.id,
191
- progress: anime === null || anime === void 0 ? void 0 : anime.progress,
192
- status: anime === null || anime === void 0 ? void 0 : anime.status,
193
- hiddenFromStatusLists: false,
194
- };
195
- try {
196
- const save = yield fetcher(query, variables);
197
- if (save) {
198
- 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;
199
- count++;
200
- console.log(`[${count}] ${anime === null || anime === void 0 ? void 0 : anime.id}-${id} ✅`);
201
- }
202
- else {
203
- console.error(`\nError saving ${anime === null || anime === void 0 ? void 0 : anime.id}`);
204
- }
205
- }
206
- catch (error) {
207
- console.error(`\nError saving ${anime === null || anime === void 0 ? void 0 : anime.id}: ${error.message}`);
208
- }
209
- })));
210
- // Avoid rate-limiting: Wait before sending the next batch
211
- yield new Promise((resolve) => setTimeout(resolve, delay));
212
- }
213
- console.log(`\nTotal ${count} anime(s) imported successfully.`);
214
- }
215
- catch (error) {
216
- console.error(`\n${error.message}`);
217
- }
218
- });
219
- }
220
- function importMangaListFromExportedJSON() {
221
- return __awaiter(this, void 0, void 0, function* () {
222
- try {
223
- const filename = yield selectFile(".json");
224
- const filePath = join(getDownloadFolderPath(), filename);
225
- const fileContent = yield readFile(filePath, "utf8");
226
- const importedData = JSON.parse(fileContent);
227
- let count = 0;
228
- const batchSize = 1; // Adjust batch size as per rate-limit constraints
229
- const delay = 2000; // 2 seconds delay to avoid rate-limit
230
- // Process in batches
231
- for (let i = 0; i < importedData.length; i += batchSize) {
232
- const batch = importedData.slice(i, i + batchSize);
233
- yield Promise.all(batch.map((manga) => __awaiter(this, void 0, void 0, function* () {
234
- var _a, _b;
235
- const query = saveMangaWithProgressMutation;
236
- const variables = {
237
- mediaId: manga === null || manga === void 0 ? void 0 : manga.id,
238
- progress: manga === null || manga === void 0 ? void 0 : manga.progress,
239
- status: manga === null || manga === void 0 ? void 0 : manga.status,
240
- hiddenFromStatusLists: false,
241
- private: manga === null || manga === void 0 ? void 0 : manga.private,
242
- };
243
- try {
244
- const save = yield fetcher(query, variables);
245
- if (save) {
246
- 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;
247
- count++;
248
- console.log(`[${count}] ${manga === null || manga === void 0 ? void 0 : manga.id}-${id} ✅`);
249
- }
250
- }
251
- catch (err) {
252
- console.error(`\nError saving ${manga === null || manga === void 0 ? void 0 : manga.id}: ${err.message}`);
253
- }
254
- })));
255
- // Avoid rate-limit by adding delay after processing each batch
256
- yield new Promise((resolve) => setTimeout(resolve, delay));
257
- }
258
- console.log(`\nTotal ${count} manga(s) imported successfully.`);
259
- }
260
- catch (error) {
261
- console.error(`\nError: ${error.message}`);
262
- }
263
- });
264
- }
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
170
  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>
171
+ return `
172
+ <anime>
173
+ <series_animedb_id>${malId}</series_animedb_id>
174
+ <series_title><![CDATA[${title}]]></series_title>
175
+ <series_type>""</series_type>
176
+ <series_episodes>${episodes}</series_episodes>
177
+ <my_id>0</my_id>
178
+ <my_watched_episodes>${progress}</my_watched_episodes>
179
+ <my_start_date>0000-00-00</my_start_date>
180
+ <my_finish_date>0000-00-00</my_finish_date>
181
+ <my_score>0</my_score>
182
+ <my_storage_value>0.00</my_storage_value>
183
+ <my_status>${status}</my_status>
184
+ <my_comments><![CDATA[]]></my_comments>
185
+ <my_times_watched>0</my_times_watched>
186
+ <my_rewatch_value></my_rewatch_value>
187
+ <my_priority>LOW</my_priority>
188
+ <my_tags><![CDATA[]]></my_tags>
189
+ <my_rewatching>0</my_rewatching>
190
+ <my_rewatching_ep>0</my_rewatching_ep>
191
+ <my_discuss>0</my_discuss>
192
+ <my_sns>default</my_sns>
193
+ <update_on_import>1</update_on_import>
493
194
  </anime>`;
494
195
  }
495
196
  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>
197
+ return `
198
+ <manga>
199
+ <manga_mangadb_id>${malId}</manga_mangadb_id>
200
+ <manga_title><![CDATA[${title ? title : "unknown"}]]></manga_title>
201
+ <manga_volumes>0</manga_volumes>
202
+ <manga_chapters>${chapters ? chapters : 0}</manga_chapters>
203
+ <my_id>0</my_id>
204
+ <my_read_chapters>${progress}</my_read_chapters>
205
+ <my_start_date>0000-00-00</my_start_date>
206
+ <my_finish_date>0000-00-00</my_finish_date>
207
+ <my_score>0</my_score>
208
+ <my_status>${status}</my_status>
209
+ <my_reread_value></my_reread_value>
210
+ <my_priority>LOW</my_priority>
211
+ <my_rereading>0</my_rereading>
212
+ <my_discuss>0</my_discuss>
213
+ <update_on_import>1</update_on_import>
513
214
  </manga>`;
514
215
  }
515
216
  function createAnimeListXML(mediaWithProgress) {
@@ -529,19 +230,19 @@ function createAnimeListXML(mediaWithProgress) {
529
230
  const status = statusMap[anime.status];
530
231
  return createAnimeXML(malId, progress, status, episodes, title);
531
232
  });
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
233
+ return `<myanimelist>
234
+ <myinfo>
235
+ <user_id/>
236
+ <user_name>${yield Auth.MyUserName()}</user_name>
237
+ <user_export_type>1</user_export_type>
238
+ <user_total_anime>0</user_total_anime>
239
+ <user_total_watching>0</user_total_watching>
240
+ <user_total_completed>0</user_total_completed>
241
+ <user_total_onhold>0</user_total_onhold>
242
+ <user_total_dropped>0</user_total_dropped>
243
+ <user_total_plantowatch>0</user_total_plantowatch>
244
+ </myinfo>
245
+ \n${xmlEntries.join("\n")}\n
545
246
  </myanimelist>`;
546
247
  });
547
248
  }
@@ -562,20 +263,20 @@ function createMangaListXML(mediaWithProgress) {
562
263
  const status = statusMap[manga.status];
563
264
  return createMangaXML(malId, progress, status, chapters, title);
564
265
  });
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
266
+ return `<myanimelist>
267
+ <myinfo>
268
+ <user_id/>
269
+ <user_name>${yield Auth.MyUserName()}</user_name>
270
+ <user_export_type>2</user_export_type>
271
+ <user_total_manga>5</user_total_manga>
272
+ <user_total_reading>1</user_total_reading>
273
+ <user_total_completed>1</user_total_completed>
274
+ <user_total_onhold>1</user_total_onhold>
275
+ <user_total_dropped>1</user_total_dropped>
276
+ <user_total_plantoread>1</user_total_plantoread>
277
+ </myinfo>
278
+ \n${xmlEntries.join("\n")}\n
578
279
  </myanimelist>`;
579
280
  });
580
281
  }
581
- export { aniListEndpoint, formatDateObject, getNextSeasonAndYear, getTitle, importAnimeListFromExportedJSON, importMangaListFromExportedJSON, MALexport, MALimport, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, };
282
+ export { aniListEndpoint, createAnimeListXML, createAnimeXML, createMangaListXML, createMangaXML, formatDateObject, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, selectFile, };
package/bin/index.js CHANGED
@@ -10,14 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  import { Command } from "commander";
12
12
  import process from "process";
13
- import { anilistUserLogin, currentUserInfo, isLoggedIn, logoutUser, } from "./helpers/auth.js";
14
- import { deleteAnimeCollection, deleteMangaCollection, getPopular, getTrending, getUpcomingAnimes, loggedInUsersAnimeLists, loggedInUsersMangaLists, } from "./helpers/lists.js";
15
- import { deleteUserActivities, exportAnimeList, exportMangaList, getAnimeDetailsByID, getAnimeSearchResults, getMangaSearchResults, getUserInfoByUsername, importAnimeList, importMangaList, writeTextActivity, } from "./helpers/more.js";
13
+ import { Auth } from "./helpers/auth.js";
14
+ import { AniList } from "./helpers/lists.js";
16
15
  const cli = new Command();
17
16
  cli
18
17
  .name("anilist")
19
18
  .description("Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts.")
20
- .version("1.0.8");
19
+ .version("1.0.0-forbidden.0");
21
20
  cli
22
21
  .command("login")
23
22
  .description("Login with AniList")
@@ -25,7 +24,7 @@ cli
25
24
  .requiredOption("-s, --secret <string>", null)
26
25
  .action((_a) => __awaiter(void 0, [_a], void 0, function* ({ id, secret }) {
27
26
  if (id && secret) {
28
- yield anilistUserLogin(id, secret);
27
+ yield Auth.Login(id, secret);
29
28
  }
30
29
  else {
31
30
  console.log("\nMust provide both ClientId and ClientSecret!");
@@ -35,7 +34,7 @@ cli
35
34
  .command("me")
36
35
  .description("Get details of the logged in user")
37
36
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
38
- yield currentUserInfo();
37
+ yield Auth.Myself();
39
38
  }));
40
39
  cli
41
40
  .command("trending")
@@ -43,7 +42,7 @@ cli
43
42
  .description("Get the trending list from AniList")
44
43
  .option("-c, --count <number>", "Number of list items to get", "10")
45
44
  .action((_a) => __awaiter(void 0, [_a], void 0, function* ({ count }) {
46
- yield getTrending(Number(count));
45
+ yield AniList.getTrendingAnime(Number(count));
47
46
  }));
48
47
  cli
49
48
  .command("popular")
@@ -51,19 +50,19 @@ cli
51
50
  .description("Get the popular list from AniList")
52
51
  .option("-c, --count <number>", "Number of list items to get", "10")
53
52
  .action((_a) => __awaiter(void 0, [_a], void 0, function* ({ count }) {
54
- yield getPopular(Number(count));
53
+ yield AniList.getPopularAnime(Number(count));
55
54
  }));
56
55
  cli
57
56
  .command("user <username>")
58
57
  .description("Get user information")
59
58
  .action((username) => __awaiter(void 0, void 0, void 0, function* () {
60
- yield getUserInfoByUsername(username);
59
+ yield AniList.getUserByUsername(username);
61
60
  }));
62
61
  cli
63
62
  .command("logout")
64
63
  .description("Log out the current user.")
65
64
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
66
- yield logoutUser();
65
+ yield Auth.Logout();
67
66
  }));
68
67
  cli
69
68
  .command("lists")
@@ -76,10 +75,10 @@ cli
76
75
  console.error(`\nMust select an option, either --anime or --manga`);
77
76
  }
78
77
  else if (anime) {
79
- yield loggedInUsersAnimeLists();
78
+ yield AniList.MyAnime();
80
79
  }
81
80
  else if (manga) {
82
- yield loggedInUsersMangaLists();
81
+ yield AniList.MyManga();
83
82
  }
84
83
  }));
85
84
  cli
@@ -100,13 +99,13 @@ cli
100
99
  process.exit(1);
101
100
  }
102
101
  if (anime) {
103
- yield deleteAnimeCollection();
102
+ yield Auth.DeleteMyAnimeList();
104
103
  }
105
104
  else if (manga) {
106
- yield deleteMangaCollection();
105
+ yield Auth.DeleteMyMangaList();
107
106
  }
108
107
  else if (activity) {
109
- yield deleteUserActivities();
108
+ yield Auth.DeleteMyActivities();
110
109
  }
111
110
  }));
112
111
  cli
@@ -115,14 +114,14 @@ cli
115
114
  .description("Anime that will be released in upcoming season")
116
115
  .option("-c, --count <number>", "Number of items to get", "10")
117
116
  .action((_a) => __awaiter(void 0, [_a], void 0, function* ({ count }) {
118
- yield getUpcomingAnimes(Number(count));
117
+ yield AniList.getUpcomingAnime(Number(count));
119
118
  }));
120
119
  cli
121
120
  .command("anime <id>")
122
121
  .description("Get anime details by their ID")
123
122
  .action((id) => __awaiter(void 0, void 0, void 0, function* () {
124
123
  if (id && !Number.isNaN(Number(id))) {
125
- yield getAnimeDetailsByID(Number(id));
124
+ yield AniList.getAnimeDetailsByID(Number(id));
126
125
  }
127
126
  else {
128
127
  console.error(`\nInvalid or missing ID (${id}). Please provide a valid numeric ID.`);
@@ -142,10 +141,10 @@ cli
142
141
  }
143
142
  else {
144
143
  if (anime) {
145
- yield getAnimeSearchResults(query, Number(count));
144
+ yield AniList.searchAnime(query, Number(count));
146
145
  }
147
146
  else if (manga) {
148
- yield getMangaSearchResults(query, Number(count));
147
+ yield AniList.searchManga(query, Number(count));
149
148
  }
150
149
  else {
151
150
  console.error(`\nMust select an option, either --anime or --manga`);
@@ -158,7 +157,7 @@ cli
158
157
  .alias("write")
159
158
  .description("Write a status...")
160
159
  .action((status) => __awaiter(void 0, void 0, void 0, function* () {
161
- yield writeTextActivity(status);
160
+ yield Auth.Write(status);
162
161
  }));
163
162
  cli
164
163
  .command("export")
@@ -172,10 +171,10 @@ cli
172
171
  }
173
172
  else {
174
173
  if (anime) {
175
- yield exportAnimeList();
174
+ yield AniList.exportAnime();
176
175
  }
177
176
  else if (manga) {
178
- yield exportMangaList();
177
+ yield AniList.exportManga();
179
178
  }
180
179
  }
181
180
  }));
@@ -190,12 +189,12 @@ cli
190
189
  console.error(`\nMust select an option, either --anime or --manga`);
191
190
  }
192
191
  else {
193
- if (yield isLoggedIn()) {
192
+ if (yield Auth.isLoggedIn()) {
194
193
  if (anime) {
195
- yield importAnimeList();
194
+ yield Auth.callAnimeImporter();
196
195
  }
197
196
  else if (manga) {
198
- yield importMangaList();
197
+ yield Auth.callMangaImporter();
199
198
  }
200
199
  }
201
200
  else {
@@ -203,4 +202,11 @@ cli
203
202
  }
204
203
  }
205
204
  }));
205
+ cli
206
+ .command("autolike")
207
+ .alias("al")
208
+ .description("Autolike following or global activities.")
209
+ .action(() => __awaiter(void 0, void 0, void 0, function* () {
210
+ yield Auth.AutoLike();
211
+ }));
206
212
  cli.parse(process.argv);