@irfanshadikrishad/anilist 1.0.11 → 1.1.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.
@@ -422,61 +422,78 @@ class AniList {
422
422
  return __awaiter(this, void 0, void 0, function* () {
423
423
  var _a, _b, _c, _d, _e;
424
424
  try {
425
- const request = yield fetch(aniListEndpoint, {
426
- method: "POST",
427
- headers: {
428
- "Content-Type": "application/json",
429
- },
430
- body: JSON.stringify({
431
- query: trendingQuery,
432
- variables: { page: 1, perPage: count },
433
- }),
434
- });
435
- const { data, errors } = yield request.json();
436
- if (request.status !== 200 || errors) {
437
- return console.log(`\nSomething went wrong. ${((_a = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _a === void 0 ? void 0 : _a.message) || "Unknown error"}`);
438
- }
439
- const media = (_b = data === null || data === void 0 ? void 0 : data.Page) === null || _b === void 0 ? void 0 : _b.media;
440
- if (!media || media.length === 0) {
441
- return console.log(`\nNo trending available at the moment.`);
442
- }
443
- const { selectedAnime } = yield inquirer.prompt([
444
- {
445
- type: "list",
446
- name: "selectedAnime",
447
- message: "Select anime to add to the list:",
448
- choices: media.map((anime, idx) => ({
449
- name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
450
- value: anime === null || anime === void 0 ? void 0 : anime.id,
451
- })),
452
- pageSize: 10,
453
- },
454
- ]);
455
- const { selectedListType } = yield inquirer.prompt([
456
- {
457
- type: "list",
458
- name: "selectedListType",
459
- message: "Select the list where you want to save this anime:",
460
- choices: [
461
- { name: "Planning", value: "PLANNING" },
462
- { name: "Watching", value: "CURRENT" },
463
- { name: "Completed", value: "COMPLETED" },
464
- { name: "Paused", value: "PAUSED" },
465
- { name: "Dropped", value: "DROPPED" },
466
- ],
467
- },
468
- ]);
469
- if (!(yield Auth.isLoggedIn())) {
470
- return console.error(`\nPlease log in first to use this feature.`);
471
- }
472
- const variables = { mediaId: selectedAnime, status: selectedListType };
473
- const saveResponse = yield fetcher(addAnimeToListMutation, variables);
474
- const saved = (_c = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
475
- if (saved) {
476
- console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
477
- }
478
- else {
479
- console.error(`\nFailed to save the anime. ${((_e = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.message) || "Unknown error"}`);
425
+ let page = 1;
426
+ let allTrending = [];
427
+ while (true) {
428
+ const request = yield fetch(aniListEndpoint, {
429
+ method: "POST",
430
+ headers: {
431
+ "Content-Type": "application/json",
432
+ },
433
+ body: JSON.stringify({
434
+ query: trendingQuery,
435
+ variables: { page, perPage: count },
436
+ }),
437
+ });
438
+ const { data, errors } = yield request.json();
439
+ if (request.status !== 200 || errors) {
440
+ console.error(`\nSomething went wrong. ${((_a = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _a === void 0 ? void 0 : _a.message) || "Unknown error"}`);
441
+ return;
442
+ }
443
+ const media = (_b = data === null || data === void 0 ? void 0 : data.Page) === null || _b === void 0 ? void 0 : _b.media;
444
+ if (!media || media.length === 0) {
445
+ console.log(`\nNo more trending anime available.`);
446
+ break;
447
+ }
448
+ allTrending = [...allTrending, ...media];
449
+ const choices = allTrending.map((anime, idx) => ({
450
+ name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
451
+ value: anime === null || anime === void 0 ? void 0 : anime.id,
452
+ }));
453
+ choices.push({ name: "See more", value: "see_more" });
454
+ const { selectedAnime } = yield inquirer.prompt([
455
+ {
456
+ type: "list",
457
+ name: "selectedAnime",
458
+ message: "Select anime to add to the list:",
459
+ choices,
460
+ pageSize: choices.length + 1,
461
+ },
462
+ ]);
463
+ if (selectedAnime === "see_more") {
464
+ page++;
465
+ continue;
466
+ }
467
+ else {
468
+ const { selectedListType } = yield inquirer.prompt([
469
+ {
470
+ type: "list",
471
+ name: "selectedListType",
472
+ message: "Select the list where you want to save this anime:",
473
+ choices: [
474
+ { name: "Planning", value: "PLANNING" },
475
+ { name: "Watching", value: "CURRENT" },
476
+ { name: "Completed", value: "COMPLETED" },
477
+ { name: "Paused", value: "PAUSED" },
478
+ { name: "Dropped", value: "DROPPED" },
479
+ ],
480
+ },
481
+ ]);
482
+ if (!(yield Auth.isLoggedIn())) {
483
+ console.error(`\nPlease log in first to use this feature.`);
484
+ return;
485
+ }
486
+ const variables = { mediaId: selectedAnime, status: selectedListType };
487
+ const saveResponse = yield fetcher(addAnimeToListMutation, variables);
488
+ const saved = (_c = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
489
+ if (saved) {
490
+ console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
491
+ }
492
+ else {
493
+ console.error(`\nFailed to save the anime. ${((_e = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.message) || "Unknown error"}`);
494
+ }
495
+ break;
496
+ }
480
497
  }
481
498
  }
482
499
  catch (error) {
@@ -488,61 +505,77 @@ class AniList {
488
505
  return __awaiter(this, void 0, void 0, function* () {
489
506
  var _a, _b, _c, _d, _e;
490
507
  try {
491
- const request = yield fetch(aniListEndpoint, {
492
- method: "POST",
493
- headers: {
494
- "Content-Type": "application/json",
495
- },
496
- body: JSON.stringify({
497
- query: popularQuery,
498
- variables: { page: 1, perPage: count },
499
- }),
500
- });
501
- const { data, errors } = yield request.json();
502
- if (request.status !== 200 || errors) {
503
- return console.log(`\nSomething went wrong. ${((_a = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _a === void 0 ? void 0 : _a.message) || "Unknown error"}`);
504
- }
505
- const media = (_b = data === null || data === void 0 ? void 0 : data.Page) === null || _b === void 0 ? void 0 : _b.media;
506
- if (!media || media.length === 0) {
507
- return console.log(`\nNo popular anime available at the moment.`);
508
- }
509
- const { selectedAnime } = yield inquirer.prompt([
510
- {
511
- type: "list",
512
- name: "selectedAnime",
513
- message: "Select anime to add to the list:",
514
- choices: media.map((anime, idx) => ({
515
- name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
516
- value: anime === null || anime === void 0 ? void 0 : anime.id,
517
- })),
518
- pageSize: 10,
519
- },
520
- ]);
521
- const { selectedListType } = yield inquirer.prompt([
522
- {
523
- type: "list",
524
- name: "selectedListType",
525
- message: "Select the list where you want to save this anime:",
526
- choices: [
527
- { name: "Planning", value: "PLANNING" },
528
- { name: "Watching", value: "CURRENT" },
529
- { name: "Completed", value: "COMPLETED" },
530
- { name: "Paused", value: "PAUSED" },
531
- { name: "Dropped", value: "DROPPED" },
532
- ],
533
- },
534
- ]);
535
- if (!(yield Auth.isLoggedIn())) {
536
- return console.error(`\nPlease log in first to use this feature.`);
537
- }
538
- const variables = { mediaId: selectedAnime, status: selectedListType };
539
- const saveResponse = yield fetcher(addAnimeToListMutation, variables);
540
- const saved = (_c = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
541
- if (saved) {
542
- console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
543
- }
544
- else {
545
- console.error(`\nFailed to save the anime. ${((_e = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.message) || "Unknown error"}`);
508
+ let page = 1;
509
+ let allMedia = [];
510
+ while (true) {
511
+ const request = yield fetch(aniListEndpoint, {
512
+ method: "POST",
513
+ headers: {
514
+ "Content-Type": "application/json",
515
+ },
516
+ body: JSON.stringify({
517
+ query: popularQuery,
518
+ variables: { page, perPage: count },
519
+ }),
520
+ });
521
+ const { data, errors } = yield request.json();
522
+ if (request.status !== 200 || errors) {
523
+ console.error(`\nSomething went wrong. ${((_a = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _a === void 0 ? void 0 : _a.message) || "Unknown error"}`);
524
+ return;
525
+ }
526
+ const newMedia = (_b = data === null || data === void 0 ? void 0 : data.Page) === null || _b === void 0 ? void 0 : _b.media;
527
+ if (!newMedia || newMedia.length === 0) {
528
+ console.log(`\nNo more popular anime available.`);
529
+ break;
530
+ }
531
+ allMedia = [...allMedia, ...newMedia];
532
+ const choices = allMedia.map((anime, idx) => ({
533
+ name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
534
+ value: anime === null || anime === void 0 ? void 0 : anime.id,
535
+ }));
536
+ choices.push({ name: "See more", value: "see_more" });
537
+ const { selectedAnime } = yield inquirer.prompt([
538
+ {
539
+ type: "list",
540
+ name: "selectedAnime",
541
+ message: "Select anime to add to the list:",
542
+ choices,
543
+ pageSize: choices.length,
544
+ },
545
+ ]);
546
+ if (selectedAnime === "see_more") {
547
+ page++;
548
+ continue;
549
+ }
550
+ else {
551
+ const { selectedListType } = yield inquirer.prompt([
552
+ {
553
+ type: "list",
554
+ name: "selectedListType",
555
+ message: "Select the list where you want to save this anime:",
556
+ choices: [
557
+ { name: "Planning", value: "PLANNING" },
558
+ { name: "Watching", value: "CURRENT" },
559
+ { name: "Completed", value: "COMPLETED" },
560
+ { name: "Paused", value: "PAUSED" },
561
+ { name: "Dropped", value: "DROPPED" },
562
+ ],
563
+ },
564
+ ]);
565
+ if (!(yield Auth.isLoggedIn())) {
566
+ return console.error(`\nPlease log in first to use this feature.`);
567
+ }
568
+ const variables = { mediaId: selectedAnime, status: selectedListType };
569
+ const saveResponse = yield fetcher(addAnimeToListMutation, variables);
570
+ const saved = (_c = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
571
+ if (saved) {
572
+ console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
573
+ }
574
+ else {
575
+ console.error(`\nFailed to save the anime. ${((_e = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.message) || "Unknown error"}`);
576
+ }
577
+ break;
578
+ }
546
579
  }
547
580
  }
548
581
  catch (error) {
@@ -555,55 +588,72 @@ class AniList {
555
588
  var _a, _b, _c, _d, _e, _f;
556
589
  try {
557
590
  const { nextSeason, nextYear } = getNextSeasonAndYear();
558
- const request = yield fetcher(upcomingAnimesQuery, {
559
- nextSeason,
560
- nextYear,
561
- perPage: count,
562
- });
563
- if (!request || !request.data) {
564
- return 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"}`);
565
- }
566
- const upcoming = (_c = request.data.Page.media) !== null && _c !== void 0 ? _c : [];
567
- if (upcoming.length === 0) {
568
- return console.log(`\nNo upcoming anime available.`);
569
- }
570
- const { selectedAnime } = yield inquirer.prompt([
571
- {
572
- type: "list",
573
- name: "selectedAnime",
574
- message: "Select anime to add to the list:",
575
- choices: upcoming.map((anime, idx) => ({
576
- name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
577
- value: anime === null || anime === void 0 ? void 0 : anime.id,
578
- })),
579
- pageSize: 10,
580
- },
581
- ]);
582
- const { selectedListType } = yield inquirer.prompt([
583
- {
584
- type: "list",
585
- name: "selectedListType",
586
- message: "Select the list where you want to save this anime:",
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" },
593
- ],
594
- },
595
- ]);
596
- if (!(yield Auth.isLoggedIn())) {
597
- return console.error(`\nPlease log in first to use this feature.`);
598
- }
599
- const variables = { mediaId: selectedAnime, status: selectedListType };
600
- const saveResponse = yield fetcher(addAnimeToListMutation, variables);
601
- const saved = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _d === void 0 ? void 0 : _d.SaveMediaListEntry;
602
- if (saved) {
603
- console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
604
- }
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"}`);
591
+ let page = 1;
592
+ let allUpcoming = [];
593
+ while (true) {
594
+ const request = yield fetcher(upcomingAnimesQuery, {
595
+ nextSeason,
596
+ nextYear,
597
+ page,
598
+ perPage: count,
599
+ });
600
+ if (!request || !request.data) {
601
+ 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"}`);
602
+ return;
603
+ }
604
+ const newUpcoming = (_c = request.data.Page.media) !== null && _c !== void 0 ? _c : [];
605
+ if (newUpcoming.length === 0) {
606
+ console.log(`\nNo more upcoming anime available.`);
607
+ break;
608
+ }
609
+ allUpcoming = [...allUpcoming, ...newUpcoming];
610
+ const choices = allUpcoming.map((anime, idx) => ({
611
+ name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
612
+ value: anime === null || anime === void 0 ? void 0 : anime.id,
613
+ }));
614
+ choices.push({ name: "See more", value: "see_more" });
615
+ const { selectedAnime } = yield inquirer.prompt([
616
+ {
617
+ type: "list",
618
+ name: "selectedAnime",
619
+ message: "Select anime to add to the list:",
620
+ choices,
621
+ pageSize: choices.length + 2,
622
+ },
623
+ ]);
624
+ if (selectedAnime === "see_more") {
625
+ page++;
626
+ continue;
627
+ }
628
+ else {
629
+ const { selectedListType } = yield inquirer.prompt([
630
+ {
631
+ type: "list",
632
+ name: "selectedListType",
633
+ message: "Select the list where you want to save this anime:",
634
+ choices: [
635
+ { name: "Planning", value: "PLANNING" },
636
+ { name: "Watching", value: "CURRENT" },
637
+ { name: "Completed", value: "COMPLETED" },
638
+ { name: "Paused", value: "PAUSED" },
639
+ { name: "Dropped", value: "DROPPED" },
640
+ ],
641
+ },
642
+ ]);
643
+ if (!(yield Auth.isLoggedIn())) {
644
+ return console.error(`\nPlease log in first to use this feature.`);
645
+ }
646
+ const variables = { mediaId: selectedAnime, status: selectedListType };
647
+ const saveResponse = yield fetcher(addAnimeToListMutation, variables);
648
+ const saved = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _d === void 0 ? void 0 : _d.SaveMediaListEntry;
649
+ if (saved) {
650
+ console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
651
+ }
652
+ else {
653
+ 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"}`);
654
+ }
655
+ break;
656
+ }
607
657
  }
608
658
  }
609
659
  catch (error) {
package/bin/index.js CHANGED
@@ -16,7 +16,7 @@ const cli = new Command();
16
16
  cli
17
17
  .name("anilist")
18
18
  .description("Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts.")
19
- .version("1.0.11");
19
+ .version("1.1.0");
20
20
  cli
21
21
  .command("login")
22
22
  .description("Login with AniList")
package/package.json CHANGED
@@ -1,73 +1,73 @@
1
- {
2
- "name": "@irfanshadikrishad/anilist",
3
- "description": "Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts",
4
- "author": "Irfan Shadik Rishad",
5
- "version": "1.0.11",
6
- "main": "./bin/index.js",
7
- "type": "module",
8
- "types": "./bin/index.d.ts",
9
- "bin": {
10
- "anilist": "./bin/index.js"
11
- },
12
- "publishConfig": {
13
- "access": "public"
14
- },
15
- "scripts": {
16
- "build": "rm -rf ./bin && tsc -w",
17
- "format": "prettier . --write",
18
- "format:check": "prettier . --check",
19
- "lint": "eslint ./dist",
20
- "lint:fix": "eslint ./dist --fix",
21
- "all": "npm run lint && npm run lint:fix && npm run format"
22
- },
23
- "keywords": [
24
- "anilist",
25
- "CLI",
26
- "anime",
27
- "manga",
28
- "anime list",
29
- "manga list",
30
- "anime tracker",
31
- "manga tracker",
32
- "anilist API",
33
- "anime progress",
34
- "manga progress",
35
- "media list",
36
- "export anime",
37
- "import anime",
38
- "export manga",
39
- "import manga",
40
- "status tracker",
41
- "watchlist",
42
- "reading list",
43
- "graphql"
44
- ],
45
- "repository": {
46
- "type": "git",
47
- "url": "https://github.com/irfanshadikrishad/anilist"
48
- },
49
- "homepage": "https://github.com/irfanshadikrishad/anilist",
50
- "bugs": {
51
- "url": "https://github.com/irfanshadikrishad/anilist/issues"
52
- },
53
- "license": "MPL-2.0",
54
- "devDependencies": {
55
- "@eslint/js": "^9.13.0",
56
- "@types/json2csv": "^5.0.7",
57
- "@types/node": "^22.8.6",
58
- "eslint": "^9.13.0",
59
- "globals": "^15.11.0",
60
- "prettier": "^3.3.3",
61
- "prettier-plugin-organize-imports": "^4.1.0",
62
- "typescript": "^5.6.3",
63
- "typescript-eslint": "^8.12.2"
64
- },
65
- "dependencies": {
66
- "commander": "^12.1.0",
67
- "fast-xml-parser": "^4.5.0",
68
- "inquirer": "^12.0.1",
69
- "json2csv": "^6.0.0-alpha.2",
70
- "node-fetch": "^3.3.2",
71
- "open": "^10.1.0"
72
- }
73
- }
1
+ {
2
+ "name": "@irfanshadikrishad/anilist",
3
+ "description": "Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts",
4
+ "author": "Irfan Shadik Rishad",
5
+ "version": "1.1.0",
6
+ "main": "./bin/index.js",
7
+ "type": "module",
8
+ "types": "./bin/index.d.ts",
9
+ "bin": {
10
+ "anilist": "./bin/index.js"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "scripts": {
16
+ "build": "rm -rf ./bin && tsc -w",
17
+ "format": "prettier . --write",
18
+ "format:check": "prettier . --check",
19
+ "lint": "eslint ./dist",
20
+ "lint:fix": "eslint ./dist --fix",
21
+ "all": "npm run lint && npm run lint:fix && npm run format"
22
+ },
23
+ "keywords": [
24
+ "anilist",
25
+ "CLI",
26
+ "anime",
27
+ "manga",
28
+ "anime list",
29
+ "manga list",
30
+ "anime tracker",
31
+ "manga tracker",
32
+ "anilist API",
33
+ "anime progress",
34
+ "manga progress",
35
+ "media list",
36
+ "export anime",
37
+ "import anime",
38
+ "export manga",
39
+ "import manga",
40
+ "status tracker",
41
+ "watchlist",
42
+ "reading list",
43
+ "graphql"
44
+ ],
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "https://github.com/irfanshadikrishad/anilist"
48
+ },
49
+ "homepage": "https://github.com/irfanshadikrishad/anilist",
50
+ "bugs": {
51
+ "url": "https://github.com/irfanshadikrishad/anilist/issues"
52
+ },
53
+ "license": "MPL-2.0",
54
+ "devDependencies": {
55
+ "@eslint/js": "^9.14.0",
56
+ "@types/json2csv": "^5.0.7",
57
+ "@types/node": "^22.9.0",
58
+ "eslint": "^9.14.0",
59
+ "globals": "^15.12.0",
60
+ "prettier": "^3.3.3",
61
+ "prettier-plugin-organize-imports": "^4.1.0",
62
+ "typescript": "^5.6.3",
63
+ "typescript-eslint": "^8.14.0"
64
+ },
65
+ "dependencies": {
66
+ "commander": "^12.1.0",
67
+ "fast-xml-parser": "^4.5.0",
68
+ "inquirer": "^12.1.0",
69
+ "json2csv": "^6.0.0-alpha.2",
70
+ "node-fetch": "^3.3.2",
71
+ "open": "^10.1.0"
72
+ }
73
+ }