@irfanshadikrishad/anilist 1.2.3 → 1.3.0-forbidden.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.
- package/README.md +2 -2
- package/bin/helpers/auth.d.ts +39 -6
- package/bin/helpers/auth.js +237 -49
- package/bin/helpers/fetcher.d.ts +1 -1
- package/bin/helpers/lists.d.ts +1 -1
- package/bin/helpers/lists.js +72 -134
- package/bin/helpers/mutations.d.ts +2 -1
- package/bin/helpers/mutations.js +6 -1
- package/bin/helpers/queries.d.ts +7 -4
- package/bin/helpers/queries.js +36 -7
- package/bin/helpers/types.d.ts +137 -8
- package/bin/helpers/workers.d.ts +4 -2
- package/bin/helpers/workers.js +49 -2
- package/bin/index.js +9 -2
- package/package.json +5 -5
- /package/{LICENSE → LICENSE.md} +0 -0
package/bin/helpers/lists.js
CHANGED
|
@@ -10,14 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { XMLParser } from "fast-xml-parser";
|
|
11
11
|
import { readFile, writeFile } from "fs/promises";
|
|
12
12
|
import inquirer from "inquirer";
|
|
13
|
-
import fetch from "node-fetch";
|
|
14
13
|
import { join } from "path";
|
|
15
14
|
import { Auth } from "./auth.js";
|
|
16
15
|
import { fetcher } from "./fetcher.js";
|
|
17
16
|
import { addAnimeToListMutation, addMangaToListMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, } from "./mutations.js";
|
|
18
17
|
import { animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, malIdToAnilistAnimeId, malIdToAnilistMangaId, mangaSearchQuery, popularQuery, trendingQuery, upcomingAnimesQuery, userActivityQuery, userQuery, } from "./queries.js";
|
|
19
18
|
import { AniListMediaStatus, } from "./types.js";
|
|
20
|
-
import {
|
|
19
|
+
import { createAnimeListXML, createMangaListXML, formatDateObject, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, selectFile, timestampToTimeAgo, } from "./workers.js";
|
|
21
20
|
class AniList {
|
|
22
21
|
static importAnime() {
|
|
23
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -237,7 +236,7 @@ class AniList {
|
|
|
237
236
|
}
|
|
238
237
|
static MyAnime() {
|
|
239
238
|
return __awaiter(this, void 0, void 0, function* () {
|
|
240
|
-
var _a, _b, _c;
|
|
239
|
+
var _a, _b, _c, _d, _e;
|
|
241
240
|
try {
|
|
242
241
|
if (!(yield Auth.isLoggedIn())) {
|
|
243
242
|
return console.error(`\nPlease log in first to access your lists.`);
|
|
@@ -246,22 +245,11 @@ class AniList {
|
|
|
246
245
|
if (!userId) {
|
|
247
246
|
return console.log(`\nFailed getting current user Id.`);
|
|
248
247
|
}
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
"content-type": "application/json",
|
|
253
|
-
"Authorization": `Bearer ${yield Auth.RetriveAccessToken()}`,
|
|
254
|
-
},
|
|
255
|
-
body: JSON.stringify({
|
|
256
|
-
query: currentUserAnimeList,
|
|
257
|
-
variables: { id: userId },
|
|
258
|
-
}),
|
|
259
|
-
});
|
|
260
|
-
const { data, errors } = yield request.json();
|
|
261
|
-
if (request.status !== 200 || errors) {
|
|
262
|
-
return console.log(`\nSomething went wrong. ${(_a = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
248
|
+
const data = yield fetcher(currentUserAnimeList, { id: userId });
|
|
249
|
+
if (data === null || data === void 0 ? void 0 : data.errors) {
|
|
250
|
+
return console.log(`\nSomething went wrong. ${(_b = (_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message}`);
|
|
263
251
|
}
|
|
264
|
-
const lists = (
|
|
252
|
+
const lists = (_d = (_c = data === null || data === void 0 ? void 0 : data.data) === null || _c === void 0 ? void 0 : _c.MediaListCollection) === null || _d === void 0 ? void 0 : _d.lists;
|
|
265
253
|
if (!lists || lists.length === 0) {
|
|
266
254
|
return console.log(`\nYou seem to have no anime(s) in your lists.`);
|
|
267
255
|
}
|
|
@@ -304,11 +292,12 @@ class AniList {
|
|
|
304
292
|
],
|
|
305
293
|
},
|
|
306
294
|
]);
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
295
|
+
const saveResponse = yield fetcher(addAnimeToListMutation, {
|
|
296
|
+
mediaId: selectedAnime,
|
|
297
|
+
status: selectedListType,
|
|
298
|
+
});
|
|
310
299
|
if (saveResponse) {
|
|
311
|
-
const savedEntry = (
|
|
300
|
+
const savedEntry = (_e = saveResponse.data) === null || _e === void 0 ? void 0 : _e.SaveMediaListEntry;
|
|
312
301
|
console.log(`\nEntry ${savedEntry === null || savedEntry === void 0 ? void 0 : savedEntry.id}. Saved as ${savedEntry === null || savedEntry === void 0 ? void 0 : savedEntry.status}.`);
|
|
313
302
|
}
|
|
314
303
|
else {
|
|
@@ -322,7 +311,7 @@ class AniList {
|
|
|
322
311
|
}
|
|
323
312
|
static MyManga() {
|
|
324
313
|
return __awaiter(this, void 0, void 0, function* () {
|
|
325
|
-
var _a, _b, _c, _d, _e;
|
|
314
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
326
315
|
try {
|
|
327
316
|
if (!(yield Auth.isLoggedIn())) {
|
|
328
317
|
return console.error(`\nPlease log in first to access your lists.`);
|
|
@@ -331,23 +320,11 @@ class AniList {
|
|
|
331
320
|
if (!userId) {
|
|
332
321
|
return console.error(`\nFailed to get the current user ID.`);
|
|
333
322
|
}
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
headers: {
|
|
338
|
-
"Content-Type": "application/json",
|
|
339
|
-
"Authorization": `Bearer ${token}`,
|
|
340
|
-
},
|
|
341
|
-
body: JSON.stringify({
|
|
342
|
-
query: currentUserMangaList,
|
|
343
|
-
variables: { id: userId },
|
|
344
|
-
}),
|
|
345
|
-
});
|
|
346
|
-
const { data, errors } = yield request.json();
|
|
347
|
-
if (request.status !== 200 || errors) {
|
|
348
|
-
return console.error(`\nFailed to fetch manga lists. ${((_a = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _a === void 0 ? void 0 : _a.message) || "Unknown error"}`);
|
|
323
|
+
const response = yield fetcher(currentUserMangaList, { id: userId });
|
|
324
|
+
if (!(response === null || response === void 0 ? void 0 : response.data)) {
|
|
325
|
+
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"}`);
|
|
349
326
|
}
|
|
350
|
-
const lists = (
|
|
327
|
+
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;
|
|
351
328
|
if (!lists || lists.length === 0) {
|
|
352
329
|
return console.log("\nYou don't seem to have any manga in your lists.");
|
|
353
330
|
}
|
|
@@ -393,24 +370,16 @@ class AniList {
|
|
|
393
370
|
],
|
|
394
371
|
},
|
|
395
372
|
]);
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
"Content-Type": "application/json",
|
|
400
|
-
"Authorization": `Bearer ${token}`,
|
|
401
|
-
},
|
|
402
|
-
body: JSON.stringify({
|
|
403
|
-
query: addMangaToListMutation,
|
|
404
|
-
variables: { mediaId: selectedManga, status: selectedListType },
|
|
405
|
-
}),
|
|
373
|
+
const saveResponse = yield fetcher(addMangaToListMutation, {
|
|
374
|
+
mediaId: selectedManga,
|
|
375
|
+
status: selectedListType,
|
|
406
376
|
});
|
|
407
|
-
const
|
|
408
|
-
const saved = (_c = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
|
|
377
|
+
const saved = (_e = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _e === void 0 ? void 0 : _e.SaveMediaListEntry;
|
|
409
378
|
if (saved) {
|
|
410
379
|
console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
|
|
411
380
|
}
|
|
412
381
|
else {
|
|
413
|
-
console.error(`\nFailed to save the manga. ${((
|
|
382
|
+
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"}`);
|
|
414
383
|
}
|
|
415
384
|
}
|
|
416
385
|
catch (error) {
|
|
@@ -420,27 +389,17 @@ class AniList {
|
|
|
420
389
|
}
|
|
421
390
|
static getTrendingAnime(count) {
|
|
422
391
|
return __awaiter(this, void 0, void 0, function* () {
|
|
423
|
-
var _a, _b, _c, _d, _e;
|
|
392
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
424
393
|
try {
|
|
425
394
|
let page = 1;
|
|
426
395
|
let allTrending = [];
|
|
427
396
|
while (true) {
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
|
|
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"}`);
|
|
397
|
+
const response = yield fetcher(trendingQuery, { page, perPage: count });
|
|
398
|
+
if (response === null || response === void 0 ? void 0 : response.errors) {
|
|
399
|
+
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"}`);
|
|
441
400
|
return;
|
|
442
401
|
}
|
|
443
|
-
const media = (
|
|
402
|
+
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;
|
|
444
403
|
if (!media || media.length === 0) {
|
|
445
404
|
console.log(`\nNo more trending anime available.`);
|
|
446
405
|
break;
|
|
@@ -448,7 +407,7 @@ class AniList {
|
|
|
448
407
|
allTrending = [...allTrending, ...media];
|
|
449
408
|
const choices = allTrending.map((anime, idx) => ({
|
|
450
409
|
name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
|
|
451
|
-
value: anime === null || anime === void 0 ? void 0 : anime.id,
|
|
410
|
+
value: String(anime === null || anime === void 0 ? void 0 : anime.id),
|
|
452
411
|
}));
|
|
453
412
|
choices.push({ name: "See more", value: "see_more" });
|
|
454
413
|
const { selectedAnime } = yield inquirer.prompt([
|
|
@@ -485,12 +444,12 @@ class AniList {
|
|
|
485
444
|
}
|
|
486
445
|
const variables = { mediaId: selectedAnime, status: selectedListType };
|
|
487
446
|
const saveResponse = yield fetcher(addAnimeToListMutation, variables);
|
|
488
|
-
const saved = (
|
|
447
|
+
const saved = (_e = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _e === void 0 ? void 0 : _e.SaveMediaListEntry;
|
|
489
448
|
if (saved) {
|
|
490
449
|
console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
|
|
491
450
|
}
|
|
492
451
|
else {
|
|
493
|
-
console.error(`\nFailed to save the anime. ${((
|
|
452
|
+
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"}`);
|
|
494
453
|
}
|
|
495
454
|
break;
|
|
496
455
|
}
|
|
@@ -503,27 +462,17 @@ class AniList {
|
|
|
503
462
|
}
|
|
504
463
|
static getPopularAnime(count) {
|
|
505
464
|
return __awaiter(this, void 0, void 0, function* () {
|
|
506
|
-
var _a, _b, _c, _d, _e;
|
|
465
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
507
466
|
try {
|
|
508
467
|
let page = 1;
|
|
509
468
|
let allMedia = [];
|
|
510
469
|
while (true) {
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
|
|
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"}`);
|
|
470
|
+
const response = yield fetcher(popularQuery, { page, perPage: count });
|
|
471
|
+
if (!(response === null || response === void 0 ? void 0 : response.data)) {
|
|
472
|
+
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"}`);
|
|
524
473
|
return;
|
|
525
474
|
}
|
|
526
|
-
const newMedia = (
|
|
475
|
+
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;
|
|
527
476
|
if (!newMedia || newMedia.length === 0) {
|
|
528
477
|
console.log(`\nNo more popular anime available.`);
|
|
529
478
|
break;
|
|
@@ -531,7 +480,7 @@ class AniList {
|
|
|
531
480
|
allMedia = [...allMedia, ...newMedia];
|
|
532
481
|
const choices = allMedia.map((anime, idx) => ({
|
|
533
482
|
name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
|
|
534
|
-
value: anime === null || anime === void 0 ? void 0 : anime.id,
|
|
483
|
+
value: String(anime === null || anime === void 0 ? void 0 : anime.id),
|
|
535
484
|
}));
|
|
536
485
|
choices.push({ name: "See more", value: "see_more" });
|
|
537
486
|
const { selectedAnime } = yield inquirer.prompt([
|
|
@@ -567,12 +516,12 @@ class AniList {
|
|
|
567
516
|
}
|
|
568
517
|
const variables = { mediaId: selectedAnime, status: selectedListType };
|
|
569
518
|
const saveResponse = yield fetcher(addAnimeToListMutation, variables);
|
|
570
|
-
const saved = (
|
|
519
|
+
const saved = (_e = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _e === void 0 ? void 0 : _e.SaveMediaListEntry;
|
|
571
520
|
if (saved) {
|
|
572
521
|
console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
|
|
573
522
|
}
|
|
574
523
|
else {
|
|
575
|
-
console.error(`\nFailed to save the anime. ${((
|
|
524
|
+
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"}`);
|
|
576
525
|
}
|
|
577
526
|
break;
|
|
578
527
|
}
|
|
@@ -609,7 +558,7 @@ class AniList {
|
|
|
609
558
|
allUpcoming = [...allUpcoming, ...newUpcoming];
|
|
610
559
|
const choices = allUpcoming.map((anime, idx) => ({
|
|
611
560
|
name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
|
|
612
|
-
value: anime === null || anime === void 0 ? void 0 : anime.id,
|
|
561
|
+
value: String(anime === null || anime === void 0 ? void 0 : anime.id),
|
|
613
562
|
}));
|
|
614
563
|
choices.push({ name: "See more", value: "see_more" });
|
|
615
564
|
const { selectedAnime } = yield inquirer.prompt([
|
|
@@ -665,20 +614,9 @@ class AniList {
|
|
|
665
614
|
return __awaiter(this, void 0, void 0, function* () {
|
|
666
615
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
667
616
|
try {
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
if (yield Auth.isLoggedIn()) {
|
|
672
|
-
headers["Authorization"] = `Bearer ${yield Auth.RetriveAccessToken()}`;
|
|
673
|
-
}
|
|
674
|
-
const request = yield fetch(aniListEndpoint, {
|
|
675
|
-
method: "POST",
|
|
676
|
-
headers,
|
|
677
|
-
body: JSON.stringify({ query: userQuery, variables: { username } }),
|
|
678
|
-
});
|
|
679
|
-
const response = yield request.json();
|
|
680
|
-
if (request.status !== 200 || !((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.User)) {
|
|
681
|
-
return console.error(`\n${request.status} ${((_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"}`);
|
|
617
|
+
const response = yield fetcher(userQuery, { username });
|
|
618
|
+
if (!((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.User)) {
|
|
619
|
+
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"}`);
|
|
682
620
|
}
|
|
683
621
|
const user = response.data.User;
|
|
684
622
|
const userActivityResponse = yield fetcher(userActivityQuery, {
|
|
@@ -703,8 +641,8 @@ class AniList {
|
|
|
703
641
|
console.log(`Statistics (Manga)\nCount: ${((_r = (_q = user.statistics) === null || _q === void 0 ? void 0 : _q.manga) === null || _r === void 0 ? void 0 : _r.count) || 0} Chapters Read: ${((_t = (_s = user.statistics) === null || _s === void 0 ? void 0 : _s.manga) === null || _t === void 0 ? void 0 : _t.chaptersRead) || 0} Volumes Read: ${((_v = (_u = user.statistics) === null || _u === void 0 ? void 0 : _u.manga) === null || _v === void 0 ? void 0 : _v.volumesRead) || 0}`);
|
|
704
642
|
if (activities.length > 0) {
|
|
705
643
|
console.log(`\nRecent Activities:`);
|
|
706
|
-
activities.forEach(({ status, progress, media }) => {
|
|
707
|
-
console.log(`${status} ${progress ? `${progress} of ` : ""}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
|
|
644
|
+
activities.forEach(({ status, progress, media, createdAt }) => {
|
|
645
|
+
console.log(`${timestampToTimeAgo(createdAt)}\t${status} ${progress ? `${progress} of ` : ""}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
|
|
708
646
|
});
|
|
709
647
|
}
|
|
710
648
|
else {
|
|
@@ -719,9 +657,9 @@ class AniList {
|
|
|
719
657
|
static getAnimeDetailsByID(anilistID) {
|
|
720
658
|
return __awaiter(this, void 0, void 0, function* () {
|
|
721
659
|
var _a;
|
|
722
|
-
const
|
|
723
|
-
|
|
724
|
-
|
|
660
|
+
const details = yield fetcher(animeDetailsQuery, {
|
|
661
|
+
id: anilistID,
|
|
662
|
+
});
|
|
725
663
|
if ((_a = details === null || details === void 0 ? void 0 : details.data) === null || _a === void 0 ? void 0 : _a.Media) {
|
|
726
664
|
const { id, title, description, duration, startDate, endDate, countryOfOrigin, isAdult, status, season, format, genres, siteUrl, } = details.data.Media;
|
|
727
665
|
console.log(`\nID: ${id}`);
|
|
@@ -743,9 +681,11 @@ class AniList {
|
|
|
743
681
|
static searchAnime(search, count) {
|
|
744
682
|
return __awaiter(this, void 0, void 0, function* () {
|
|
745
683
|
var _a, _b, _c;
|
|
746
|
-
const
|
|
747
|
-
|
|
748
|
-
|
|
684
|
+
const searchResults = yield fetcher(animeSearchQuery, {
|
|
685
|
+
search,
|
|
686
|
+
page: 1,
|
|
687
|
+
perPage: count,
|
|
688
|
+
});
|
|
749
689
|
if (searchResults) {
|
|
750
690
|
const results = (_b = (_a = searchResults === null || searchResults === void 0 ? void 0 : searchResults.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.media;
|
|
751
691
|
if (results.length > 0) {
|
|
@@ -777,12 +717,10 @@ class AniList {
|
|
|
777
717
|
]);
|
|
778
718
|
// Save selected anime to chosen list type
|
|
779
719
|
if (yield Auth.isLoggedIn()) {
|
|
780
|
-
const
|
|
781
|
-
const saveVariables = {
|
|
720
|
+
const response = yield fetcher(addAnimeToListMutation, {
|
|
782
721
|
mediaId: selectedAnime,
|
|
783
722
|
status: selectedListType,
|
|
784
|
-
};
|
|
785
|
-
const response = yield fetcher(saveQuery, saveVariables);
|
|
723
|
+
});
|
|
786
724
|
if (response) {
|
|
787
725
|
const saved = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
|
|
788
726
|
console.log(`\nEntry ${saved === null || saved === void 0 ? void 0 : saved.id}. Saved as ${saved === null || saved === void 0 ? void 0 : saved.status}.`);
|
|
@@ -804,9 +742,11 @@ class AniList {
|
|
|
804
742
|
static searchManga(search, count) {
|
|
805
743
|
return __awaiter(this, void 0, void 0, function* () {
|
|
806
744
|
var _a, _b, _c;
|
|
807
|
-
const
|
|
808
|
-
|
|
809
|
-
|
|
745
|
+
const mangaSearchResult = yield fetcher(mangaSearchQuery, {
|
|
746
|
+
search,
|
|
747
|
+
page: 1,
|
|
748
|
+
perPage: count,
|
|
749
|
+
});
|
|
810
750
|
if (mangaSearchResult) {
|
|
811
751
|
const results = (_b = (_a = mangaSearchResult === null || mangaSearchResult === void 0 ? void 0 : mangaSearchResult.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.media;
|
|
812
752
|
// List of manga search results
|
|
@@ -839,9 +779,10 @@ class AniList {
|
|
|
839
779
|
]);
|
|
840
780
|
// If logged in save to the list
|
|
841
781
|
if (yield Auth.isLoggedIn()) {
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
|
|
782
|
+
const response = yield fetcher(addMangaToListMutation, {
|
|
783
|
+
mediaId: selectedMangaId,
|
|
784
|
+
status: selectedListType,
|
|
785
|
+
});
|
|
845
786
|
if (response) {
|
|
846
787
|
const saved = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
|
|
847
788
|
console.log(`\nEntry ${saved === null || saved === void 0 ? void 0 : saved.id}. Saved as ${saved === null || saved === void 0 ? void 0 : saved.status}.`);
|
|
@@ -1041,19 +982,16 @@ class MyAnimeList {
|
|
|
1041
982
|
});
|
|
1042
983
|
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) {
|
|
1043
984
|
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;
|
|
1044
|
-
const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => {
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
hiddenFromStatusLists: entry.hiddenFromStatusLists,
|
|
1055
|
-
});
|
|
1056
|
-
}));
|
|
985
|
+
const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => ({
|
|
986
|
+
id: entry.media.id,
|
|
987
|
+
malId: entry.media.idMal,
|
|
988
|
+
title: entry.media.title,
|
|
989
|
+
private: entry.private,
|
|
990
|
+
chapters: entry.media.chapters,
|
|
991
|
+
progress: entry.progress,
|
|
992
|
+
status: entry.status,
|
|
993
|
+
hiddenFromStatusLists: entry.hiddenFromStatusLists,
|
|
994
|
+
})));
|
|
1057
995
|
const XMLContent = createMangaListXML(mediaWithProgress);
|
|
1058
996
|
const path = join(getDownloadFolderPath(), `${yield Auth.MyUserName()}@irfanshadikrishad-anilist-myanimelist(manga)-${getFormattedDate()}.xml`);
|
|
1059
997
|
yield writeFile(path, yield XMLContent, "utf8");
|
|
@@ -4,4 +4,5 @@ declare const deleteActivityMutation = "\nmutation($id: Int!) {\n DeleteActivit
|
|
|
4
4
|
declare const saveTextActivityMutation = "\nmutation SaveTextActivity($status: String!) {\n SaveTextActivity(text: $status) { id text userId createdAt }\n}\n";
|
|
5
5
|
declare const saveAnimeWithProgressMutation = "\nmutation ($mediaId: Int, $progress: Int, $status: MediaListStatus, $hiddenFromStatusLists: Boolean) {\n SaveMediaListEntry(mediaId: $mediaId, progress: $progress, status: $status, hiddenFromStatusLists: $hiddenFromStatusLists) {\n id progress hiddenFromStatusLists\n }\n}\n";
|
|
6
6
|
declare const saveMangaWithProgressMutation = "\nmutation ($mediaId: Int, $progress: Int, $status: MediaListStatus, $hiddenFromStatusLists: Boolean, $private: Boolean) {\n SaveMediaListEntry( mediaId: $mediaId, progress: $progress, status: $status, hiddenFromStatusLists: $hiddenFromStatusLists, private: $private\n ) { id progress hiddenFromStatusLists private }\n}\n";
|
|
7
|
-
|
|
7
|
+
declare const likeActivityMutation = "\nmutation($activityId: Int!) {\n ToggleLike(id: $activityId, type: ACTIVITY) { id }\n}\n";
|
|
8
|
+
export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, likeActivityMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, saveTextActivityMutation, };
|
package/bin/helpers/mutations.js
CHANGED
|
@@ -35,4 +35,9 @@ mutation ($mediaId: Int, $progress: Int, $status: MediaListStatus, $hiddenFromSt
|
|
|
35
35
|
) { id progress hiddenFromStatusLists private }
|
|
36
36
|
}
|
|
37
37
|
`;
|
|
38
|
-
|
|
38
|
+
const likeActivityMutation = `
|
|
39
|
+
mutation($activityId: Int!) {
|
|
40
|
+
ToggleLike(id: $activityId, type: ACTIVITY) { id }
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, likeActivityMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, saveTextActivityMutation, };
|
package/bin/helpers/queries.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const currentUserQuery = "{\n Viewer {\n id name about bans siteUrl options { profileColor timezone activityMergeTime }\n donatorTier donatorBadge createdAt updatedAt unreadNotificationCount previousNames { name createdAt updatedAt }\n moderatorRoles favourites { anime { nodes { id title { romaji english } } } manga { nodes { id title { romaji english } } } }\n statistics { anime { count meanScore minutesWatched } manga { count chaptersRead volumesRead } }\n mediaListOptions { scoreFormat rowOrder animeList { sectionOrder } mangaList { sectionOrder } }\n }\n}";
|
|
1
|
+
declare const currentUserQuery = "{\n Viewer {\n id name about bans siteUrl options { profileColor timezone activityMergeTime }\n donatorTier donatorBadge createdAt updatedAt unreadNotificationCount previousNames { name createdAt updatedAt }\n moderatorRoles favourites { anime { nodes { id title { romaji english } } } manga { nodes { id title { romaji english } } } }\n statistics { anime { count meanScore minutesWatched episodesWatched } manga { count chaptersRead volumesRead meanScore } }\n mediaListOptions { scoreFormat rowOrder animeList { sectionOrder } mangaList { sectionOrder } }\n }\n}";
|
|
2
2
|
declare const trendingQuery = "query ($page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n media(sort: TRENDING_DESC, type: ANIME) { id title { romaji english } }\n }\n}";
|
|
3
3
|
declare const popularQuery = "query ($page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n media(sort: POPULARITY_DESC, type: ANIME) { id title { romaji english } }\n }\n}";
|
|
4
4
|
declare const userQuery = "query ($username: String) {\n User(name: $username) {\n id name siteUrl donatorTier donatorBadge createdAt updatedAt previousNames { name createdAt updatedAt }\n isBlocked isFollower isFollowing options { profileColor timezone activityMergeTime }\n statistics { anime { count episodesWatched minutesWatched } manga { count chaptersRead volumesRead } }\n }\n}";
|
|
@@ -17,6 +17,9 @@ declare const activityMangaListQuery = "query ($userId: Int, $page: Int, $perPag
|
|
|
17
17
|
declare const activityMessageQuery = "query ($userId: Int, $page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(userId: $userId, type: MESSAGE, sort: ID_DESC) {\n ... on MessageActivity { id type message recipient { id name } createdAt }\n }\n }\n}";
|
|
18
18
|
declare const activityAllQuery = "query ($userId: Int, $page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(userId: $userId, sort: ID_DESC) {\n ... on TextActivity { id type text createdAt user { id name } }\n ... on ListActivity { id type status progress createdAt media { id title { romaji english native } } }\n ... on MessageActivity { id type message recipient { id name } createdAt }\n }\n }\n}";
|
|
19
19
|
declare const activityMediaList = "query ($userId: Int, $page: Int, $perPage: Int, $type: ActivityType) {\n Page(page: $page, perPage: $perPage) {\n pageInfo { total currentPage lastPage hasNextPage perPage }\n activities(userId: $userId, type: $type, sort: ID_DESC) {\n ... on ListActivity { id type status progress media { id title { romaji english native } format } createdAt }\n }\n }\n}";
|
|
20
|
-
declare const malIdToAnilistAnimeId = "query ($malId: Int) {\n Media(idMal: $malId, type: ANIME) {
|
|
21
|
-
declare const malIdToAnilistMangaId = "query ($malId: Int) {\n Media(idMal: $malId, type: MANGA) {
|
|
22
|
-
|
|
20
|
+
declare const malIdToAnilistAnimeId = "query ($malId: Int) {\n Media(idMal: $malId, type: ANIME) { id title { romaji english } } }\n";
|
|
21
|
+
declare const malIdToAnilistMangaId = "query ($malId: Int) {\n Media(idMal: $malId, type: MANGA) { id title { romaji english } } }\n";
|
|
22
|
+
declare const followingActivitiesQuery = "\nquery ($page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(isFollowing: true, sort: ID_DESC) {\n ... on TextActivity { id type isLiked createdAt user { id name } }\n ... on ListActivity { id type isLiked status progress media { title { userPreferred } } createdAt user { id name } }\n ... on MessageActivity { id type isLiked message createdAt recipient { id name } }\n }\n }\n}\n";
|
|
23
|
+
declare const globalActivitiesQuery = "\nquery ($page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(sort: ID_DESC) {\n ... on TextActivity { id type isLiked createdAt user { id name } }\n ... on ListActivity { id type isLiked status progress media { title { userPreferred } } createdAt user { id name } }\n ... on MessageActivity { id type isLiked message createdAt recipient { id name } }\n }\n }\n}\n";
|
|
24
|
+
declare const specificUserActivitiesQuery = "\nquery ($page: Int, $perPage: Int, $userId: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(userId: $userId, sort: ID_DESC) {\n ... on TextActivity { id type isLiked createdAt user { id name } }\n ... on ListActivity { id type isLiked status progress media { title { userPreferred } } createdAt user { id name } }\n ... on MessageActivity { messenger { name } id type isLiked message createdAt recipient { id name } }\n }\n }\n}\n";
|
|
25
|
+
export { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, followingActivitiesQuery, globalActivitiesQuery, malIdToAnilistAnimeId, malIdToAnilistMangaId, mangaSearchQuery, popularQuery, specificUserActivitiesQuery, trendingQuery, upcomingAnimesQuery, userActivityQuery, userQuery, };
|
package/bin/helpers/queries.js
CHANGED
|
@@ -3,7 +3,7 @@ const currentUserQuery = `{
|
|
|
3
3
|
id name about bans siteUrl options { profileColor timezone activityMergeTime }
|
|
4
4
|
donatorTier donatorBadge createdAt updatedAt unreadNotificationCount previousNames { name createdAt updatedAt }
|
|
5
5
|
moderatorRoles favourites { anime { nodes { id title { romaji english } } } manga { nodes { id title { romaji english } } } }
|
|
6
|
-
statistics { anime { count meanScore minutesWatched } manga { count chaptersRead volumesRead } }
|
|
6
|
+
statistics { anime { count meanScore minutesWatched episodesWatched } manga { count chaptersRead volumesRead meanScore } }
|
|
7
7
|
mediaListOptions { scoreFormat rowOrder animeList { sectionOrder } mangaList { sectionOrder } }
|
|
8
8
|
}
|
|
9
9
|
}`;
|
|
@@ -120,13 +120,42 @@ const activityMediaList = `query ($userId: Int, $page: Int, $perPage: Int, $type
|
|
|
120
120
|
}
|
|
121
121
|
}`;
|
|
122
122
|
const malIdToAnilistAnimeId = `query ($malId: Int) {
|
|
123
|
-
Media(idMal: $malId, type: ANIME) {
|
|
124
|
-
id title { romaji english } }
|
|
125
|
-
}
|
|
123
|
+
Media(idMal: $malId, type: ANIME) { id title { romaji english } } }
|
|
126
124
|
`;
|
|
127
125
|
const malIdToAnilistMangaId = `query ($malId: Int) {
|
|
128
|
-
Media(idMal: $malId, type: MANGA) {
|
|
129
|
-
|
|
126
|
+
Media(idMal: $malId, type: MANGA) { id title { romaji english } } }
|
|
127
|
+
`;
|
|
128
|
+
const followingActivitiesQuery = `
|
|
129
|
+
query ($page: Int, $perPage: Int) {
|
|
130
|
+
Page(page: $page, perPage: $perPage) {
|
|
131
|
+
activities(isFollowing: true, sort: ID_DESC) {
|
|
132
|
+
... on TextActivity { id type isLiked createdAt user { id name } }
|
|
133
|
+
... on ListActivity { id type isLiked status progress media { title { userPreferred } } createdAt user { id name } }
|
|
134
|
+
... on MessageActivity { id type isLiked message createdAt recipient { id name } }
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
`;
|
|
139
|
+
const globalActivitiesQuery = `
|
|
140
|
+
query ($page: Int, $perPage: Int) {
|
|
141
|
+
Page(page: $page, perPage: $perPage) {
|
|
142
|
+
activities(sort: ID_DESC) {
|
|
143
|
+
... on TextActivity { id type isLiked createdAt user { id name } }
|
|
144
|
+
... on ListActivity { id type isLiked status progress media { title { userPreferred } } createdAt user { id name } }
|
|
145
|
+
... on MessageActivity { id type isLiked message createdAt recipient { id name } }
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
`;
|
|
150
|
+
const specificUserActivitiesQuery = `
|
|
151
|
+
query ($page: Int, $perPage: Int, $userId: Int) {
|
|
152
|
+
Page(page: $page, perPage: $perPage) {
|
|
153
|
+
activities(userId: $userId, sort: ID_DESC) {
|
|
154
|
+
... on TextActivity { id type isLiked createdAt user { id name } }
|
|
155
|
+
... on ListActivity { id type isLiked status progress media { title { userPreferred } } createdAt user { id name } }
|
|
156
|
+
... on MessageActivity { messenger { name } id type isLiked message createdAt recipient { id name } }
|
|
157
|
+
}
|
|
158
|
+
}
|
|
130
159
|
}
|
|
131
160
|
`;
|
|
132
|
-
export { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, malIdToAnilistAnimeId, malIdToAnilistMangaId, mangaSearchQuery, popularQuery, trendingQuery, upcomingAnimesQuery, userActivityQuery, userQuery, };
|
|
161
|
+
export { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, followingActivitiesQuery, globalActivitiesQuery, malIdToAnilistAnimeId, malIdToAnilistMangaId, mangaSearchQuery, popularQuery, specificUserActivitiesQuery, trendingQuery, upcomingAnimesQuery, userActivityQuery, userQuery, };
|