@irfanshadikrishad/anilist 2.0.0-forbidden → 2.0.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.
- package/.husky/pre-commit +3 -0
- package/README.md +26 -21
- package/bin/helpers/auth.d.ts +22 -2
- package/bin/helpers/auth.js +223 -236
- package/bin/helpers/lists.d.ts +40 -0
- package/bin/helpers/lists.js +339 -705
- package/bin/helpers/validation.d.ts +10 -1
- package/bin/helpers/validation.js +24 -36
- package/bin/helpers/workers.d.ts +2 -1
- package/bin/helpers/workers.js +5 -2
- package/bin/index.js +57 -67
- package/package.json +4 -2
package/bin/helpers/lists.js
CHANGED
|
@@ -21,7 +21,60 @@ import { AniListMediaStatus, } from './types.js';
|
|
|
21
21
|
import { Validate } from './validation.js';
|
|
22
22
|
import { anidbToanilistMapper, formatDateObject, getDownloadFolderPath, getNextSeasonAndYear, getTitle, logUserDetails, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, saveJSONasXML, selectFile, simpleDateFormat, timestampToTimeAgo, } from './workers.js';
|
|
23
23
|
class AniList {
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Prompt the user for a list status (Planning/Watching-Reading/Completed/Paused/Dropped)
|
|
26
|
+
*/
|
|
27
|
+
static promptListType(kind) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const label = kind === 'ANIME' ? 'anime' : 'manga';
|
|
30
|
+
const { selectedListType } = yield inquirer.prompt([
|
|
31
|
+
{
|
|
32
|
+
type: 'list',
|
|
33
|
+
name: 'selectedListType',
|
|
34
|
+
message: `Select the list where you want to save this ${label}:`,
|
|
35
|
+
choices: [
|
|
36
|
+
{ name: 'Planning', value: 'PLANNING' },
|
|
37
|
+
{
|
|
38
|
+
name: kind === 'ANIME' ? 'Watching' : 'Reading',
|
|
39
|
+
value: 'CURRENT',
|
|
40
|
+
},
|
|
41
|
+
{ name: 'Completed', value: 'COMPLETED' },
|
|
42
|
+
{ name: 'Paused', value: 'PAUSED' },
|
|
43
|
+
{ name: 'Dropped', value: 'DROPPED' },
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
]);
|
|
47
|
+
return selectedListType;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Save a media entry to the authenticated user's list, logging the outcome.
|
|
52
|
+
*/
|
|
53
|
+
static saveEntryToList(mutation, mediaId, status) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
var _a, _b, _c;
|
|
56
|
+
if (!(yield Auth.isLoggedIn())) {
|
|
57
|
+
console.error(`\nPlease log in first to use this feature.`);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const response = yield fetcher(mutation, {
|
|
61
|
+
mediaId,
|
|
62
|
+
status,
|
|
63
|
+
});
|
|
64
|
+
const saved = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.SaveMediaListEntry;
|
|
65
|
+
if (saved) {
|
|
66
|
+
console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
console.error(`\nFailed to save the entry. ${((_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'}`);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Import a previously exported AniList JSON file, saving each entry with
|
|
75
|
+
* progress via the given mutation.
|
|
76
|
+
*/
|
|
77
|
+
static importJSONList(mutation, buildVariables, label) {
|
|
25
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
79
|
try {
|
|
27
80
|
const filename = yield selectFile('.json');
|
|
@@ -39,93 +92,57 @@ class AniList {
|
|
|
39
92
|
const batchSize = 1;
|
|
40
93
|
for (let i = 0; i < importedData.length; i += batchSize) {
|
|
41
94
|
const batch = importedData.slice(i, i + batchSize);
|
|
42
|
-
yield Promise.all(batch.map((
|
|
95
|
+
yield Promise.all(batch.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
43
96
|
var _a, _b;
|
|
44
|
-
const query = saveAnimeWithProgressMutation;
|
|
45
|
-
const variables = {
|
|
46
|
-
mediaId: anime === null || anime === void 0 ? void 0 : anime.id,
|
|
47
|
-
progress: anime === null || anime === void 0 ? void 0 : anime.progress,
|
|
48
|
-
status: anime === null || anime === void 0 ? void 0 : anime.status,
|
|
49
|
-
hiddenFromStatusLists: false,
|
|
50
|
-
};
|
|
51
97
|
try {
|
|
52
|
-
const save = yield fetcher(
|
|
98
|
+
const save = yield fetcher(mutation, buildVariables(item));
|
|
53
99
|
if (save) {
|
|
54
100
|
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;
|
|
55
101
|
count++;
|
|
56
|
-
console.log(`[${count}]\t${id}\t${
|
|
102
|
+
console.log(`[${count}]\t${id}\t${item === null || item === void 0 ? void 0 : item.id} ✅`);
|
|
57
103
|
}
|
|
58
104
|
else {
|
|
59
|
-
console.error(`\nError saving ${
|
|
105
|
+
console.error(`\nError saving ${item === null || item === void 0 ? void 0 : item.id}`);
|
|
60
106
|
}
|
|
61
107
|
}
|
|
62
108
|
catch (error) {
|
|
63
|
-
console.error(`\nError saving ${
|
|
109
|
+
console.error(`\nError saving ${item === null || item === void 0 ? void 0 : item.id}: ${error.message}`);
|
|
64
110
|
}
|
|
65
111
|
})));
|
|
66
112
|
}
|
|
67
|
-
console.log(`\nTotal ${count}
|
|
113
|
+
console.log(`\nTotal ${count} ${label}(s) imported successfully.`);
|
|
68
114
|
}
|
|
69
115
|
catch (error) {
|
|
70
116
|
console.error(`\n${error.message}`);
|
|
71
117
|
}
|
|
72
118
|
});
|
|
73
119
|
}
|
|
120
|
+
static importAnime() {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
return AniList.importJSONList(saveAnimeWithProgressMutation, (anime) => ({
|
|
123
|
+
mediaId: anime === null || anime === void 0 ? void 0 : anime.id,
|
|
124
|
+
progress: anime === null || anime === void 0 ? void 0 : anime.progress,
|
|
125
|
+
status: anime === null || anime === void 0 ? void 0 : anime.status,
|
|
126
|
+
hiddenFromStatusLists: false,
|
|
127
|
+
}), 'anime');
|
|
128
|
+
});
|
|
129
|
+
}
|
|
74
130
|
static importManga() {
|
|
75
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const importedData = JSON.parse(fileContent);
|
|
84
|
-
if (!Validate.Import_JSON(importedData)) {
|
|
85
|
-
console.error(`\nInvalid JSON file.`);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
let count = 0;
|
|
89
|
-
const batchSize = 1;
|
|
90
|
-
for (let i = 0; i < importedData.length; i += batchSize) {
|
|
91
|
-
const batch = importedData.slice(i, i + batchSize);
|
|
92
|
-
yield Promise.all(batch.map((manga) => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
var _a, _b;
|
|
94
|
-
const query = saveMangaWithProgressMutation;
|
|
95
|
-
const variables = {
|
|
96
|
-
mediaId: manga === null || manga === void 0 ? void 0 : manga.id,
|
|
97
|
-
progress: manga === null || manga === void 0 ? void 0 : manga.progress,
|
|
98
|
-
status: manga === null || manga === void 0 ? void 0 : manga.status,
|
|
99
|
-
hiddenFromStatusLists: false,
|
|
100
|
-
private: manga === null || manga === void 0 ? void 0 : manga.private,
|
|
101
|
-
};
|
|
102
|
-
try {
|
|
103
|
-
const save = yield fetcher(query, variables);
|
|
104
|
-
if (save) {
|
|
105
|
-
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;
|
|
106
|
-
count++;
|
|
107
|
-
console.log(`[${count}]\t${id}\t${manga === null || manga === void 0 ? void 0 : manga.id} ✅`);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
catch (err) {
|
|
111
|
-
console.error(`\nError saving ${manga === null || manga === void 0 ? void 0 : manga.id}: ${err.message}`);
|
|
112
|
-
}
|
|
113
|
-
})));
|
|
114
|
-
}
|
|
115
|
-
console.log(`\nTotal ${count} manga(s) imported successfully.`);
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
console.error(`\nError: ${error.message}`);
|
|
119
|
-
}
|
|
132
|
+
return AniList.importJSONList(saveMangaWithProgressMutation, (manga) => ({
|
|
133
|
+
mediaId: manga === null || manga === void 0 ? void 0 : manga.id,
|
|
134
|
+
progress: manga === null || manga === void 0 ? void 0 : manga.progress,
|
|
135
|
+
status: manga === null || manga === void 0 ? void 0 : manga.status,
|
|
136
|
+
hiddenFromStatusLists: false,
|
|
137
|
+
private: manga === null || manga === void 0 ? void 0 : manga.private,
|
|
138
|
+
}), 'manga');
|
|
120
139
|
});
|
|
121
140
|
}
|
|
122
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Prompt for CSV/JSON/XML and dispatch to the matching exporter.
|
|
143
|
+
*/
|
|
144
|
+
static promptExportFormatAndSave(mediaWithProgress, dataType, xmlLabel, exportAsXML) {
|
|
123
145
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
var _a, _b, _c;
|
|
125
|
-
if (!(yield Auth.isLoggedIn())) {
|
|
126
|
-
console.error(`\nMust login to use this feature.`);
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
146
|
const { exportType } = yield inquirer.prompt([
|
|
130
147
|
{
|
|
131
148
|
type: 'list',
|
|
@@ -134,46 +151,55 @@ class AniList {
|
|
|
134
151
|
choices: [
|
|
135
152
|
{ name: 'CSV', value: 1 },
|
|
136
153
|
{ name: 'JSON', value: 2 },
|
|
137
|
-
{ name:
|
|
154
|
+
{ name: xmlLabel, value: 3 },
|
|
138
155
|
],
|
|
139
156
|
pageSize: 10,
|
|
140
157
|
},
|
|
141
158
|
]);
|
|
159
|
+
switch (exportType) {
|
|
160
|
+
case 1:
|
|
161
|
+
yield saveJSONasCSV(mediaWithProgress, dataType);
|
|
162
|
+
break;
|
|
163
|
+
case 2:
|
|
164
|
+
yield saveJSONasJSON(mediaWithProgress, dataType);
|
|
165
|
+
break;
|
|
166
|
+
case 3:
|
|
167
|
+
yield exportAsXML();
|
|
168
|
+
break;
|
|
169
|
+
default:
|
|
170
|
+
console.log(`\nInvalid export type. ${exportType}`);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
static exportAnime() {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
var _a, _b, _c;
|
|
178
|
+
if (!(yield Auth.isLoggedIn())) {
|
|
179
|
+
console.error(`\nMust login to use this feature.`);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
142
182
|
const animeList = yield fetcher(currentUserAnimeList, {
|
|
143
183
|
id: yield Auth.MyUserId(),
|
|
144
184
|
});
|
|
145
|
-
if (animeList) {
|
|
146
|
-
const lists = (_c = (_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) !== null && _c !== void 0 ? _c : [];
|
|
147
|
-
const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => {
|
|
148
|
-
var _a, _b, _c, _d;
|
|
149
|
-
return ({
|
|
150
|
-
id: (_a = entry === null || entry === void 0 ? void 0 : entry.media) === null || _a === void 0 ? void 0 : _a.id,
|
|
151
|
-
title: (_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.title,
|
|
152
|
-
episodes: (_c = entry === null || entry === void 0 ? void 0 : entry.media) === null || _c === void 0 ? void 0 : _c.episodes,
|
|
153
|
-
siteUrl: (_d = entry === null || entry === void 0 ? void 0 : entry.media) === null || _d === void 0 ? void 0 : _d.siteUrl,
|
|
154
|
-
progress: entry.progress,
|
|
155
|
-
status: entry === null || entry === void 0 ? void 0 : entry.status,
|
|
156
|
-
hiddenFromStatusLists: entry.hiddenFromStatusLists,
|
|
157
|
-
});
|
|
158
|
-
}));
|
|
159
|
-
switch (exportType) {
|
|
160
|
-
case 1:
|
|
161
|
-
yield saveJSONasCSV(mediaWithProgress, 'anime');
|
|
162
|
-
break;
|
|
163
|
-
case 2:
|
|
164
|
-
yield saveJSONasJSON(mediaWithProgress, 'anime');
|
|
165
|
-
break;
|
|
166
|
-
case 3:
|
|
167
|
-
yield MyAnimeList.exportAnime();
|
|
168
|
-
break;
|
|
169
|
-
default:
|
|
170
|
-
console.log(`\nInvalid export type. ${exportType}`);
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
185
|
+
if (!animeList) {
|
|
175
186
|
console.error(`\nNo anime(s) found in your lists.`);
|
|
187
|
+
return;
|
|
176
188
|
}
|
|
189
|
+
const lists = (_c = (_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) !== null && _c !== void 0 ? _c : [];
|
|
190
|
+
const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => {
|
|
191
|
+
var _a, _b, _c, _d;
|
|
192
|
+
return ({
|
|
193
|
+
id: (_a = entry === null || entry === void 0 ? void 0 : entry.media) === null || _a === void 0 ? void 0 : _a.id,
|
|
194
|
+
title: (_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.title,
|
|
195
|
+
episodes: (_c = entry === null || entry === void 0 ? void 0 : entry.media) === null || _c === void 0 ? void 0 : _c.episodes,
|
|
196
|
+
siteUrl: (_d = entry === null || entry === void 0 ? void 0 : entry.media) === null || _d === void 0 ? void 0 : _d.siteUrl,
|
|
197
|
+
progress: entry.progress,
|
|
198
|
+
status: entry === null || entry === void 0 ? void 0 : entry.status,
|
|
199
|
+
hiddenFromStatusLists: entry.hiddenFromStatusLists,
|
|
200
|
+
});
|
|
201
|
+
}));
|
|
202
|
+
yield AniList.promptExportFormatAndSave(mediaWithProgress, 'anime', 'XML (MyAnimeList/AniDB)', MyAnimeList.exportAnime);
|
|
177
203
|
});
|
|
178
204
|
}
|
|
179
205
|
static exportManga() {
|
|
@@ -191,75 +217,56 @@ class AniList {
|
|
|
191
217
|
return;
|
|
192
218
|
}
|
|
193
219
|
const lists = ((_b = (_a = mangaLists === null || mangaLists === void 0 ? void 0 : mangaLists.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists) || [];
|
|
194
|
-
if (lists.length
|
|
195
|
-
const { exportType } = yield inquirer.prompt([
|
|
196
|
-
{
|
|
197
|
-
type: 'list',
|
|
198
|
-
name: 'exportType',
|
|
199
|
-
message: 'Choose export type:',
|
|
200
|
-
choices: [
|
|
201
|
-
{ name: 'CSV', value: 1 },
|
|
202
|
-
{ name: 'JSON', value: 2 },
|
|
203
|
-
{ name: 'XML (MyAnimeList)', value: 3 },
|
|
204
|
-
],
|
|
205
|
-
pageSize: 10,
|
|
206
|
-
},
|
|
207
|
-
]);
|
|
208
|
-
const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => {
|
|
209
|
-
var _a, _b;
|
|
210
|
-
return ({
|
|
211
|
-
id: (_a = entry === null || entry === void 0 ? void 0 : entry.media) === null || _a === void 0 ? void 0 : _a.id,
|
|
212
|
-
title: (_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.title,
|
|
213
|
-
private: entry.private,
|
|
214
|
-
chapters: entry.media.chapters,
|
|
215
|
-
progress: entry.progress,
|
|
216
|
-
status: entry === null || entry === void 0 ? void 0 : entry.status,
|
|
217
|
-
hiddenFromStatusLists: entry.hiddenFromStatusLists,
|
|
218
|
-
});
|
|
219
|
-
}));
|
|
220
|
-
switch (exportType) {
|
|
221
|
-
case 1:
|
|
222
|
-
yield saveJSONasCSV(mediaWithProgress, 'manga');
|
|
223
|
-
break;
|
|
224
|
-
case 2:
|
|
225
|
-
yield saveJSONasJSON(mediaWithProgress, 'manga');
|
|
226
|
-
break;
|
|
227
|
-
case 3:
|
|
228
|
-
yield MyAnimeList.exportManga();
|
|
229
|
-
break;
|
|
230
|
-
default:
|
|
231
|
-
console.log(`\nInvalid export type. ${exportType}`);
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
220
|
+
if (lists.length === 0) {
|
|
236
221
|
console.log(`\nList seems to be empty.`);
|
|
222
|
+
return;
|
|
237
223
|
}
|
|
224
|
+
const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => {
|
|
225
|
+
var _a, _b;
|
|
226
|
+
return ({
|
|
227
|
+
id: (_a = entry === null || entry === void 0 ? void 0 : entry.media) === null || _a === void 0 ? void 0 : _a.id,
|
|
228
|
+
title: (_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.title,
|
|
229
|
+
private: entry.private,
|
|
230
|
+
chapters: entry.media.chapters,
|
|
231
|
+
progress: entry.progress,
|
|
232
|
+
status: entry === null || entry === void 0 ? void 0 : entry.status,
|
|
233
|
+
hiddenFromStatusLists: entry.hiddenFromStatusLists,
|
|
234
|
+
});
|
|
235
|
+
}));
|
|
236
|
+
yield AniList.promptExportFormatAndSave(mediaWithProgress, 'manga', 'XML (MyAnimeList)', MyAnimeList.exportManga);
|
|
238
237
|
});
|
|
239
238
|
}
|
|
240
|
-
|
|
239
|
+
/**
|
|
240
|
+
* Pick an existing entry from one of the user's own lists and re-save it
|
|
241
|
+
* under a (possibly different) list status.
|
|
242
|
+
*/
|
|
243
|
+
static pickFromMyListAndResave(listQuery, addMutation, kind) {
|
|
241
244
|
return __awaiter(this, void 0, void 0, function* () {
|
|
242
|
-
var _a, _b, _c, _d
|
|
245
|
+
var _a, _b, _c, _d;
|
|
243
246
|
try {
|
|
247
|
+
const label = kind === 'ANIME' ? 'anime' : 'manga';
|
|
244
248
|
if (!(yield Auth.isLoggedIn())) {
|
|
245
249
|
return console.error(`\nPlease log in first to access your lists.`);
|
|
246
250
|
}
|
|
247
|
-
|
|
248
|
-
|
|
251
|
+
const userId = yield Auth.MyUserId();
|
|
252
|
+
if (!userId) {
|
|
253
|
+
return console.error(`\nFailed getting current user Id.`);
|
|
249
254
|
}
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
255
|
+
const response = yield fetcher(listQuery, {
|
|
256
|
+
id: userId,
|
|
257
|
+
});
|
|
258
|
+
if (!(response === null || response === void 0 ? void 0 : response.data)) {
|
|
259
|
+
return 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'}`);
|
|
253
260
|
}
|
|
254
|
-
const lists = (_d = (_c =
|
|
261
|
+
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;
|
|
255
262
|
if (!lists || lists.length === 0) {
|
|
256
|
-
return console.log(`\nYou seem to have no
|
|
263
|
+
return console.log(`\nYou seem to have no ${label}(s) in your lists.`);
|
|
257
264
|
}
|
|
258
265
|
const { selectedList } = yield inquirer.prompt([
|
|
259
266
|
{
|
|
260
267
|
type: 'list',
|
|
261
268
|
name: 'selectedList',
|
|
262
|
-
message:
|
|
269
|
+
message: `Select a${kind === 'ANIME' ? 'n' : ''} ${label} list:`,
|
|
263
270
|
choices: lists.map((list) => list.name),
|
|
264
271
|
},
|
|
265
272
|
]);
|
|
@@ -268,11 +275,11 @@ class AniList {
|
|
|
268
275
|
return console.log(`\nNo entries found or not available at this moment.`);
|
|
269
276
|
}
|
|
270
277
|
console.log(`\nEntries for '${selectedEntries.name}':`);
|
|
271
|
-
const {
|
|
278
|
+
const { selectedMedia } = yield inquirer.prompt([
|
|
272
279
|
{
|
|
273
280
|
type: 'list',
|
|
274
|
-
name: '
|
|
275
|
-
message:
|
|
281
|
+
name: 'selectedMedia',
|
|
282
|
+
message: `Select ${label} to add to the list:`,
|
|
276
283
|
choices: selectedEntries.entries.map((entry, idx) => ({
|
|
277
284
|
name: `[${idx + 1}] ${getTitle(entry.media.title)}`,
|
|
278
285
|
value: entry.media.id,
|
|
@@ -280,134 +287,47 @@ class AniList {
|
|
|
280
287
|
pageSize: 10,
|
|
281
288
|
},
|
|
282
289
|
]);
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
type: 'list',
|
|
286
|
-
name: 'selectedListType',
|
|
287
|
-
message: 'Select the list where you want to save this anime:',
|
|
288
|
-
choices: [
|
|
289
|
-
{ name: 'Planning', value: 'PLANNING' },
|
|
290
|
-
{ name: 'Watching', value: 'CURRENT' },
|
|
291
|
-
{ name: 'Completed', value: 'COMPLETED' },
|
|
292
|
-
{ name: 'Paused', value: 'PAUSED' },
|
|
293
|
-
{ name: 'Dropped', value: 'DROPPED' },
|
|
294
|
-
],
|
|
295
|
-
},
|
|
296
|
-
]);
|
|
297
|
-
const saveResponse = yield fetcher(addAnimeToListMutation, {
|
|
298
|
-
mediaId: selectedAnime,
|
|
299
|
-
status: selectedListType,
|
|
300
|
-
});
|
|
301
|
-
if (saveResponse) {
|
|
302
|
-
const savedEntry = (_e = saveResponse.data) === null || _e === void 0 ? void 0 : _e.SaveMediaListEntry;
|
|
303
|
-
console.log(`\nEntry ${savedEntry === null || savedEntry === void 0 ? void 0 : savedEntry.id}. Saved as ${savedEntry === null || savedEntry === void 0 ? void 0 : savedEntry.status}.`);
|
|
304
|
-
}
|
|
305
|
-
else {
|
|
306
|
-
console.error(`\nPlease log in first to use this feature.`);
|
|
307
|
-
}
|
|
290
|
+
const selectedListType = yield AniList.promptListType(kind);
|
|
291
|
+
yield AniList.saveEntryToList(addMutation, selectedMedia, selectedListType);
|
|
308
292
|
}
|
|
309
293
|
catch (error) {
|
|
310
294
|
console.log(`\nSomething went wrong. ${error.message}`);
|
|
311
295
|
}
|
|
312
296
|
});
|
|
313
297
|
}
|
|
298
|
+
static MyAnime() {
|
|
299
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
300
|
+
return AniList.pickFromMyListAndResave(currentUserAnimeList, addAnimeToListMutation, 'ANIME');
|
|
301
|
+
});
|
|
302
|
+
}
|
|
314
303
|
static MyManga() {
|
|
315
304
|
return __awaiter(this, void 0, void 0, function* () {
|
|
316
|
-
|
|
317
|
-
try {
|
|
318
|
-
if (!(yield Auth.isLoggedIn())) {
|
|
319
|
-
return console.error(`\nPlease log in first to access your lists.`);
|
|
320
|
-
}
|
|
321
|
-
const userId = yield Auth.MyUserId();
|
|
322
|
-
if (!userId) {
|
|
323
|
-
return console.error(`\nFailed to get the current user ID.`);
|
|
324
|
-
}
|
|
325
|
-
const response = yield fetcher(currentUserMangaList, { id: userId });
|
|
326
|
-
if (!(response === null || response === void 0 ? void 0 : response.data)) {
|
|
327
|
-
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'}`);
|
|
328
|
-
}
|
|
329
|
-
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;
|
|
330
|
-
if (!lists || lists.length === 0) {
|
|
331
|
-
return console.log("\nYou don't seem to have any manga in your lists.");
|
|
332
|
-
}
|
|
333
|
-
const { selectedList } = yield inquirer.prompt([
|
|
334
|
-
{
|
|
335
|
-
type: 'list',
|
|
336
|
-
name: 'selectedList',
|
|
337
|
-
message: 'Select a manga list:',
|
|
338
|
-
choices: lists.map((list) => list.name),
|
|
339
|
-
},
|
|
340
|
-
]);
|
|
341
|
-
const selectedEntries = lists.find((list) => list.name === selectedList);
|
|
342
|
-
if (!selectedEntries || selectedEntries.entries.length === 0) {
|
|
343
|
-
return console.log('\nNo manga entries found in the selected list.');
|
|
344
|
-
}
|
|
345
|
-
console.log(`\nEntries for '${selectedEntries.name}':`);
|
|
346
|
-
const { selectedManga } = yield inquirer.prompt([
|
|
347
|
-
{
|
|
348
|
-
type: 'list',
|
|
349
|
-
name: 'selectedManga',
|
|
350
|
-
message: 'Select a manga to add to the list:',
|
|
351
|
-
choices: selectedEntries.entries.map((entry, idx) => {
|
|
352
|
-
var _a;
|
|
353
|
-
return ({
|
|
354
|
-
name: `[${idx + 1}] ${getTitle(entry.media.title)}`,
|
|
355
|
-
value: (_a = entry === null || entry === void 0 ? void 0 : entry.media) === null || _a === void 0 ? void 0 : _a.id,
|
|
356
|
-
});
|
|
357
|
-
}),
|
|
358
|
-
pageSize: 10,
|
|
359
|
-
},
|
|
360
|
-
]);
|
|
361
|
-
const { selectedListType } = yield inquirer.prompt([
|
|
362
|
-
{
|
|
363
|
-
type: 'list',
|
|
364
|
-
name: 'selectedListType',
|
|
365
|
-
message: 'Select the list where you want to save this manga:',
|
|
366
|
-
choices: [
|
|
367
|
-
{ name: 'Planning', value: 'PLANNING' },
|
|
368
|
-
{ name: 'Reading', value: 'CURRENT' },
|
|
369
|
-
{ name: 'Completed', value: 'COMPLETED' },
|
|
370
|
-
{ name: 'Paused', value: 'PAUSED' },
|
|
371
|
-
{ name: 'Dropped', value: 'DROPPED' },
|
|
372
|
-
],
|
|
373
|
-
},
|
|
374
|
-
]);
|
|
375
|
-
const saveResponse = yield fetcher(addMangaToListMutation, {
|
|
376
|
-
mediaId: selectedManga,
|
|
377
|
-
status: selectedListType,
|
|
378
|
-
});
|
|
379
|
-
const saved = (_e = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _e === void 0 ? void 0 : _e.SaveMediaListEntry;
|
|
380
|
-
if (saved) {
|
|
381
|
-
console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
|
|
382
|
-
}
|
|
383
|
-
else {
|
|
384
|
-
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'}`);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
catch (error) {
|
|
388
|
-
console.error(`\nSomething went wrong. ${error.message}`);
|
|
389
|
-
}
|
|
305
|
+
return AniList.pickFromMyListAndResave(currentUserMangaList, addMangaToListMutation, 'MANGA');
|
|
390
306
|
});
|
|
391
307
|
}
|
|
392
|
-
|
|
308
|
+
/**
|
|
309
|
+
* Page through a media browse query (trending/popular/upcoming), letting the
|
|
310
|
+
* user "see more" or pick an entry to add to one of their lists.
|
|
311
|
+
*/
|
|
312
|
+
static browseAndAddAnime(query, count, extraVariables, emptyMessage) {
|
|
393
313
|
return __awaiter(this, void 0, void 0, function* () {
|
|
394
|
-
var _a, _b, _c, _d
|
|
314
|
+
var _a, _b, _c, _d;
|
|
395
315
|
try {
|
|
396
316
|
let page = 1;
|
|
397
|
-
let
|
|
317
|
+
let allMedia = [];
|
|
398
318
|
while (true) {
|
|
399
|
-
const response = yield fetcher(
|
|
400
|
-
if (response === null || response === void 0 ? void 0 : response.
|
|
319
|
+
const response = yield fetcher(query, Object.assign({ page, perPage: count }, extraVariables));
|
|
320
|
+
if (!(response === null || response === void 0 ? void 0 : response.data)) {
|
|
401
321
|
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'}`);
|
|
402
322
|
return;
|
|
403
323
|
}
|
|
404
324
|
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;
|
|
405
325
|
if (!media || media.length === 0) {
|
|
406
|
-
console.log(`\
|
|
326
|
+
console.log(`\n${emptyMessage}`);
|
|
407
327
|
break;
|
|
408
328
|
}
|
|
409
|
-
|
|
410
|
-
const choices =
|
|
329
|
+
allMedia = [...allMedia, ...media];
|
|
330
|
+
const choices = allMedia.map((anime, idx) => ({
|
|
411
331
|
name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
|
|
412
332
|
value: String(anime === null || anime === void 0 ? void 0 : anime.id),
|
|
413
333
|
}));
|
|
@@ -425,36 +345,9 @@ class AniList {
|
|
|
425
345
|
page++;
|
|
426
346
|
continue;
|
|
427
347
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
type: 'list',
|
|
432
|
-
name: 'selectedListType',
|
|
433
|
-
message: 'Select the list where you want to save this anime:',
|
|
434
|
-
choices: [
|
|
435
|
-
{ name: 'Planning', value: 'PLANNING' },
|
|
436
|
-
{ name: 'Watching', value: 'CURRENT' },
|
|
437
|
-
{ name: 'Completed', value: 'COMPLETED' },
|
|
438
|
-
{ name: 'Paused', value: 'PAUSED' },
|
|
439
|
-
{ name: 'Dropped', value: 'DROPPED' },
|
|
440
|
-
],
|
|
441
|
-
},
|
|
442
|
-
]);
|
|
443
|
-
if (!(yield Auth.isLoggedIn())) {
|
|
444
|
-
console.error(`\nPlease log in first to use this feature.`);
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
const variables = { mediaId: selectedAnime, status: selectedListType };
|
|
448
|
-
const saveResponse = yield fetcher(addAnimeToListMutation, variables);
|
|
449
|
-
const saved = (_e = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _e === void 0 ? void 0 : _e.SaveMediaListEntry;
|
|
450
|
-
if (saved) {
|
|
451
|
-
console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
|
|
452
|
-
}
|
|
453
|
-
else {
|
|
454
|
-
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'}`);
|
|
455
|
-
}
|
|
456
|
-
break;
|
|
457
|
-
}
|
|
348
|
+
const selectedListType = yield AniList.promptListType('ANIME');
|
|
349
|
+
yield AniList.saveEntryToList(addAnimeToListMutation, selectedAnime, selectedListType);
|
|
350
|
+
break;
|
|
458
351
|
}
|
|
459
352
|
}
|
|
460
353
|
catch (error) {
|
|
@@ -462,154 +355,20 @@ class AniList {
|
|
|
462
355
|
}
|
|
463
356
|
});
|
|
464
357
|
}
|
|
358
|
+
static getTrendingAnime(count) {
|
|
359
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
360
|
+
return AniList.browseAndAddAnime(trendingQuery, count, {}, 'No more trending anime available.');
|
|
361
|
+
});
|
|
362
|
+
}
|
|
465
363
|
static getPopularAnime(count) {
|
|
466
364
|
return __awaiter(this, void 0, void 0, function* () {
|
|
467
|
-
|
|
468
|
-
try {
|
|
469
|
-
let page = 1;
|
|
470
|
-
let allMedia = [];
|
|
471
|
-
while (true) {
|
|
472
|
-
const response = yield fetcher(popularQuery, { page, perPage: count });
|
|
473
|
-
if (!(response === null || response === void 0 ? void 0 : response.data)) {
|
|
474
|
-
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'}`);
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
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;
|
|
478
|
-
if (!newMedia || newMedia.length === 0) {
|
|
479
|
-
console.log(`\nNo more popular anime available.`);
|
|
480
|
-
break;
|
|
481
|
-
}
|
|
482
|
-
allMedia = [...allMedia, ...newMedia];
|
|
483
|
-
const choices = allMedia.map((anime, idx) => ({
|
|
484
|
-
name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
|
|
485
|
-
value: String(anime === null || anime === void 0 ? void 0 : anime.id),
|
|
486
|
-
}));
|
|
487
|
-
choices.push({ name: 'See more', value: 'see_more' });
|
|
488
|
-
const { selectedAnime } = yield inquirer.prompt([
|
|
489
|
-
{
|
|
490
|
-
type: 'list',
|
|
491
|
-
name: 'selectedAnime',
|
|
492
|
-
message: 'Select anime to add to the list:',
|
|
493
|
-
choices,
|
|
494
|
-
pageSize: choices.length,
|
|
495
|
-
},
|
|
496
|
-
]);
|
|
497
|
-
if (selectedAnime === 'see_more') {
|
|
498
|
-
page++;
|
|
499
|
-
continue;
|
|
500
|
-
}
|
|
501
|
-
else {
|
|
502
|
-
const { selectedListType } = yield inquirer.prompt([
|
|
503
|
-
{
|
|
504
|
-
type: 'list',
|
|
505
|
-
name: 'selectedListType',
|
|
506
|
-
message: 'Select the list where you want to save this anime:',
|
|
507
|
-
choices: [
|
|
508
|
-
{ name: 'Planning', value: 'PLANNING' },
|
|
509
|
-
{ name: 'Watching', value: 'CURRENT' },
|
|
510
|
-
{ name: 'Completed', value: 'COMPLETED' },
|
|
511
|
-
{ name: 'Paused', value: 'PAUSED' },
|
|
512
|
-
{ name: 'Dropped', value: 'DROPPED' },
|
|
513
|
-
],
|
|
514
|
-
},
|
|
515
|
-
]);
|
|
516
|
-
if (!(yield Auth.isLoggedIn())) {
|
|
517
|
-
return console.error(`\nPlease log in first to use this feature.`);
|
|
518
|
-
}
|
|
519
|
-
const variables = { mediaId: selectedAnime, status: selectedListType };
|
|
520
|
-
const saveResponse = yield fetcher(addAnimeToListMutation, variables);
|
|
521
|
-
const saved = (_e = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _e === void 0 ? void 0 : _e.SaveMediaListEntry;
|
|
522
|
-
if (saved) {
|
|
523
|
-
console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
|
|
524
|
-
}
|
|
525
|
-
else {
|
|
526
|
-
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'}`);
|
|
527
|
-
}
|
|
528
|
-
break;
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
catch (error) {
|
|
533
|
-
console.error(`\nSomething went wrong. ${error.message}`);
|
|
534
|
-
}
|
|
365
|
+
return AniList.browseAndAddAnime(popularQuery, count, {}, 'No more popular anime available.');
|
|
535
366
|
});
|
|
536
367
|
}
|
|
537
368
|
static getUpcomingAnime(count) {
|
|
538
369
|
return __awaiter(this, void 0, void 0, function* () {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
const { nextSeason, nextYear } = getNextSeasonAndYear();
|
|
542
|
-
let page = 1;
|
|
543
|
-
let allUpcoming = [];
|
|
544
|
-
while (true) {
|
|
545
|
-
const request = yield fetcher(upcomingAnimesQuery, {
|
|
546
|
-
nextSeason,
|
|
547
|
-
nextYear,
|
|
548
|
-
page,
|
|
549
|
-
perPage: count,
|
|
550
|
-
});
|
|
551
|
-
if (!request || !request.data) {
|
|
552
|
-
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'}`);
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
|
-
const newUpcoming = (_c = request.data.Page.media) !== null && _c !== void 0 ? _c : [];
|
|
556
|
-
if (newUpcoming.length === 0) {
|
|
557
|
-
console.log(`\nNo more upcoming anime available.`);
|
|
558
|
-
break;
|
|
559
|
-
}
|
|
560
|
-
allUpcoming = [...allUpcoming, ...newUpcoming];
|
|
561
|
-
const choices = allUpcoming.map((anime, idx) => ({
|
|
562
|
-
name: `[${idx + 1}] ${getTitle(anime === null || anime === void 0 ? void 0 : anime.title)}`,
|
|
563
|
-
value: String(anime === null || anime === void 0 ? void 0 : anime.id),
|
|
564
|
-
}));
|
|
565
|
-
choices.push({ name: 'See more', value: 'see_more' });
|
|
566
|
-
const { selectedAnime } = yield inquirer.prompt([
|
|
567
|
-
{
|
|
568
|
-
type: 'list',
|
|
569
|
-
name: 'selectedAnime',
|
|
570
|
-
message: 'Select anime to add to the list:',
|
|
571
|
-
choices,
|
|
572
|
-
pageSize: choices.length + 2,
|
|
573
|
-
},
|
|
574
|
-
]);
|
|
575
|
-
if (selectedAnime === 'see_more') {
|
|
576
|
-
page++;
|
|
577
|
-
continue;
|
|
578
|
-
}
|
|
579
|
-
else {
|
|
580
|
-
const { selectedListType } = yield inquirer.prompt([
|
|
581
|
-
{
|
|
582
|
-
type: 'list',
|
|
583
|
-
name: 'selectedListType',
|
|
584
|
-
message: 'Select the list where you want to save this anime:',
|
|
585
|
-
choices: [
|
|
586
|
-
{ name: 'Planning', value: 'PLANNING' },
|
|
587
|
-
{ name: 'Watching', value: 'CURRENT' },
|
|
588
|
-
{ name: 'Completed', value: 'COMPLETED' },
|
|
589
|
-
{ name: 'Paused', value: 'PAUSED' },
|
|
590
|
-
{ name: 'Dropped', value: 'DROPPED' },
|
|
591
|
-
],
|
|
592
|
-
},
|
|
593
|
-
]);
|
|
594
|
-
if (!(yield Auth.isLoggedIn())) {
|
|
595
|
-
return console.error(`\nPlease log in first to use this feature.`);
|
|
596
|
-
}
|
|
597
|
-
const variables = { mediaId: selectedAnime, status: selectedListType };
|
|
598
|
-
const saveResponse = yield fetcher(addAnimeToListMutation, variables);
|
|
599
|
-
const saved = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _d === void 0 ? void 0 : _d.SaveMediaListEntry;
|
|
600
|
-
if (saved) {
|
|
601
|
-
console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
|
|
602
|
-
}
|
|
603
|
-
else {
|
|
604
|
-
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'}`);
|
|
605
|
-
}
|
|
606
|
-
break;
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
catch (error) {
|
|
611
|
-
console.error(`\nError getting upcoming animes. ${error.message}`);
|
|
612
|
-
}
|
|
370
|
+
const { nextSeason, nextYear } = getNextSeasonAndYear();
|
|
371
|
+
return AniList.browseAndAddAnime(upcomingAnimesQuery, count, { nextSeason, nextYear }, 'No more upcoming anime available.');
|
|
613
372
|
});
|
|
614
373
|
}
|
|
615
374
|
static getUserByUsername(username) {
|
|
@@ -703,128 +462,56 @@ class AniList {
|
|
|
703
462
|
}
|
|
704
463
|
});
|
|
705
464
|
}
|
|
706
|
-
|
|
465
|
+
/**
|
|
466
|
+
* Search AniList and let the user pick a result to add to one of their lists.
|
|
467
|
+
*/
|
|
468
|
+
static searchAndAddToList(query, addMutation, search, count, kind) {
|
|
707
469
|
return __awaiter(this, void 0, void 0, function* () {
|
|
708
|
-
var _a, _b
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
perPage: count,
|
|
713
|
-
});
|
|
714
|
-
if (searchResults) {
|
|
715
|
-
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;
|
|
716
|
-
if (results.length > 0) {
|
|
717
|
-
const { selectedAnime } = yield inquirer.prompt([
|
|
718
|
-
{
|
|
719
|
-
type: 'list',
|
|
720
|
-
name: 'selectedAnime',
|
|
721
|
-
message: 'Select anime to add to your list:',
|
|
722
|
-
choices: results.map((res, idx) => ({
|
|
723
|
-
name: `[${idx + 1}] ${getTitle(res === null || res === void 0 ? void 0 : res.title)}`,
|
|
724
|
-
value: res === null || res === void 0 ? void 0 : res.id,
|
|
725
|
-
})),
|
|
726
|
-
pageSize: 10,
|
|
727
|
-
},
|
|
728
|
-
]);
|
|
729
|
-
const { selectedListType } = yield inquirer.prompt([
|
|
730
|
-
{
|
|
731
|
-
type: 'list',
|
|
732
|
-
name: 'selectedListType',
|
|
733
|
-
message: 'Select the list where you want to save this anime:',
|
|
734
|
-
choices: [
|
|
735
|
-
{ name: 'Planning', value: 'PLANNING' },
|
|
736
|
-
{ name: 'Watching', value: 'CURRENT' },
|
|
737
|
-
{ name: 'Completed', value: 'COMPLETED' },
|
|
738
|
-
{ name: 'Paused', value: 'PAUSED' },
|
|
739
|
-
{ name: 'Dropped', value: 'DROPPED' },
|
|
740
|
-
],
|
|
741
|
-
},
|
|
742
|
-
]);
|
|
743
|
-
// Save selected anime to chosen list type
|
|
744
|
-
if (yield Auth.isLoggedIn()) {
|
|
745
|
-
const response = yield fetcher(addAnimeToListMutation, {
|
|
746
|
-
mediaId: selectedAnime,
|
|
747
|
-
status: selectedListType,
|
|
748
|
-
});
|
|
749
|
-
if (response) {
|
|
750
|
-
const saved = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
|
|
751
|
-
console.log(`\nEntry ${saved === null || saved === void 0 ? void 0 : saved.id}. Saved as ${saved === null || saved === void 0 ? void 0 : saved.status}.`);
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
else {
|
|
755
|
-
console.error(`\nPlease log in first to use this feature.`);
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
else {
|
|
759
|
-
console.log(`\nNo search results found.`);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
else {
|
|
470
|
+
var _a, _b;
|
|
471
|
+
const label = kind === 'ANIME' ? 'anime' : 'manga';
|
|
472
|
+
const searchResults = yield fetcher(query, { search, page: 1, perPage: count });
|
|
473
|
+
if (!searchResults) {
|
|
763
474
|
console.error(`\nSomething went wrong.`);
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
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;
|
|
478
|
+
if (!results || results.length === 0) {
|
|
479
|
+
console.log(`\nNo search results found.`);
|
|
480
|
+
return;
|
|
764
481
|
}
|
|
482
|
+
const { selectedMedia } = yield inquirer.prompt([
|
|
483
|
+
{
|
|
484
|
+
type: 'list',
|
|
485
|
+
name: 'selectedMedia',
|
|
486
|
+
message: `Select ${label} to add to your list:`,
|
|
487
|
+
choices: results.map((res, idx) => ({
|
|
488
|
+
name: `[${idx + 1}] ${getTitle(res === null || res === void 0 ? void 0 : res.title)}`,
|
|
489
|
+
value: res === null || res === void 0 ? void 0 : res.id,
|
|
490
|
+
})),
|
|
491
|
+
pageSize: 10,
|
|
492
|
+
},
|
|
493
|
+
]);
|
|
494
|
+
const selectedListType = yield AniList.promptListType(kind);
|
|
495
|
+
yield AniList.saveEntryToList(addMutation, selectedMedia, selectedListType);
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
static searchAnime(search, count) {
|
|
499
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
500
|
+
return AniList.searchAndAddToList(animeSearchQuery, addAnimeToListMutation, search, count, 'ANIME');
|
|
765
501
|
});
|
|
766
502
|
}
|
|
767
503
|
static searchManga(search, count) {
|
|
768
504
|
return __awaiter(this, void 0, void 0, function* () {
|
|
769
|
-
|
|
770
|
-
const mangaSearchResult = yield fetcher(mangaSearchQuery, {
|
|
771
|
-
search,
|
|
772
|
-
page: 1,
|
|
773
|
-
perPage: count,
|
|
774
|
-
});
|
|
775
|
-
if (mangaSearchResult) {
|
|
776
|
-
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;
|
|
777
|
-
// List of manga search results
|
|
778
|
-
const { selectedMangaId } = yield inquirer.prompt([
|
|
779
|
-
{
|
|
780
|
-
type: 'list',
|
|
781
|
-
name: 'selectedMangaId',
|
|
782
|
-
message: 'Select manga to add to your list:',
|
|
783
|
-
choices: results.map((res, idx) => ({
|
|
784
|
-
name: `[${idx + 1}] ${getTitle(res === null || res === void 0 ? void 0 : res.title)}`,
|
|
785
|
-
value: res === null || res === void 0 ? void 0 : res.id,
|
|
786
|
-
})),
|
|
787
|
-
pageSize: 10,
|
|
788
|
-
},
|
|
789
|
-
]);
|
|
790
|
-
// Options to save to the list
|
|
791
|
-
const { selectedListType } = yield inquirer.prompt([
|
|
792
|
-
{
|
|
793
|
-
type: 'list',
|
|
794
|
-
name: 'selectedListType',
|
|
795
|
-
message: 'Select the list where you want to save this manga:',
|
|
796
|
-
choices: [
|
|
797
|
-
{ name: 'Planning', value: 'PLANNING' },
|
|
798
|
-
{ name: 'Reading', value: 'CURRENT' },
|
|
799
|
-
{ name: 'Completed', value: 'COMPLETED' },
|
|
800
|
-
{ name: 'Paused', value: 'PAUSED' },
|
|
801
|
-
{ name: 'Dropped', value: 'DROPPED' },
|
|
802
|
-
],
|
|
803
|
-
},
|
|
804
|
-
]);
|
|
805
|
-
// If logged in save to the list
|
|
806
|
-
if (yield Auth.isLoggedIn()) {
|
|
807
|
-
const response = yield fetcher(addMangaToListMutation, {
|
|
808
|
-
mediaId: selectedMangaId,
|
|
809
|
-
status: selectedListType,
|
|
810
|
-
});
|
|
811
|
-
if (response) {
|
|
812
|
-
const saved = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
|
|
813
|
-
console.log(`\nEntry ${saved === null || saved === void 0 ? void 0 : saved.id}. Saved as ${saved === null || saved === void 0 ? void 0 : saved.status}.`);
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
else {
|
|
817
|
-
console.error(`\nPlease log in first to use this feature.`);
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
else {
|
|
821
|
-
console.error(`\nSomething went wrong.`);
|
|
822
|
-
}
|
|
505
|
+
return AniList.searchAndAddToList(mangaSearchQuery, addMangaToListMutation, search, count, 'MANGA');
|
|
823
506
|
});
|
|
824
507
|
}
|
|
825
508
|
}
|
|
826
509
|
class MyAnimeList {
|
|
827
|
-
|
|
510
|
+
/**
|
|
511
|
+
* Import a MyAnimeList export XML file, mapping each entry to its AniList
|
|
512
|
+
* equivalent by MAL id and saving it with progress.
|
|
513
|
+
*/
|
|
514
|
+
static importMALList(options) {
|
|
828
515
|
return __awaiter(this, void 0, void 0, function* () {
|
|
829
516
|
var _a, _b, _c, _d, _e;
|
|
830
517
|
try {
|
|
@@ -834,209 +521,156 @@ class MyAnimeList {
|
|
|
834
521
|
}
|
|
835
522
|
const filePath = join(getDownloadFolderPath(), filename);
|
|
836
523
|
const fileContent = yield readFile(filePath, 'utf8');
|
|
837
|
-
if (!(yield
|
|
524
|
+
if (!(yield options.validator(fileContent))) {
|
|
838
525
|
console.error(`\nInvalid XML file.`);
|
|
839
526
|
return;
|
|
840
527
|
}
|
|
841
528
|
const parser = new XMLParser();
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
});
|
|
871
|
-
const entryId = (_e = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _d === void 0 ? void 0 : _d.SaveMediaListEntry) === null || _e === void 0 ? void 0 : _e.id;
|
|
872
|
-
if (entryId) {
|
|
873
|
-
count++;
|
|
874
|
-
console.log(`[${count}] ${entryId} ✅`);
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
else {
|
|
878
|
-
console.error(`Could not retrieve AniList ID for MAL ID ${malId}`);
|
|
879
|
-
}
|
|
529
|
+
const XMLObject = parser.parse(fileContent);
|
|
530
|
+
const entries = (_a = XMLObject === null || XMLObject === void 0 ? void 0 : XMLObject.myanimelist) === null || _a === void 0 ? void 0 : _a[options.listKey];
|
|
531
|
+
if (!entries || entries.length === 0) {
|
|
532
|
+
console.log(`\nNo ${options.listKey} list found in the file.`);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
let count = 0;
|
|
536
|
+
for (const entry of entries) {
|
|
537
|
+
const malId = entry[options.malIdField];
|
|
538
|
+
const progress = entry[options.progressField];
|
|
539
|
+
const status = options.statusMap[entry.my_status];
|
|
540
|
+
try {
|
|
541
|
+
// Fetch AniList ID using MAL ID
|
|
542
|
+
const anilistResponse = yield fetcher(options.malIdQuery, { malId });
|
|
543
|
+
const anilistId = (_c = (_b = anilistResponse === null || anilistResponse === void 0 ? void 0 : anilistResponse.data) === null || _b === void 0 ? void 0 : _b.Media) === null || _c === void 0 ? void 0 : _c.id;
|
|
544
|
+
if (anilistId) {
|
|
545
|
+
// Save entry with progress
|
|
546
|
+
const saveResponse = yield fetcher(options.saveMutation, {
|
|
547
|
+
mediaId: anilistId,
|
|
548
|
+
progress,
|
|
549
|
+
status,
|
|
550
|
+
hiddenFromStatusLists: false,
|
|
551
|
+
private: false,
|
|
552
|
+
});
|
|
553
|
+
const entryId = (_e = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _d === void 0 ? void 0 : _d.SaveMediaListEntry) === null || _e === void 0 ? void 0 : _e.id;
|
|
554
|
+
if (entryId) {
|
|
555
|
+
count++;
|
|
556
|
+
console.log(`[${count}] ${entryId} ✅`);
|
|
880
557
|
}
|
|
881
|
-
|
|
882
|
-
console.error(`
|
|
558
|
+
else {
|
|
559
|
+
console.error(`Failed to save entry for ${malId}`);
|
|
883
560
|
}
|
|
884
561
|
}
|
|
885
|
-
|
|
562
|
+
else {
|
|
563
|
+
console.error(`Could not retrieve AniList ID for MAL ID ${malId}`);
|
|
564
|
+
}
|
|
886
565
|
}
|
|
887
|
-
|
|
888
|
-
console.
|
|
566
|
+
catch (error) {
|
|
567
|
+
console.error(`Error processing MAL ID ${malId}: ${error.message}`);
|
|
889
568
|
}
|
|
890
569
|
}
|
|
570
|
+
console.log(`\nTotal Entries Processed: ${count}`);
|
|
891
571
|
}
|
|
892
572
|
catch (error) {
|
|
893
573
|
console.error(`\nError in MAL import process: ${error.message}`);
|
|
894
574
|
}
|
|
895
575
|
});
|
|
896
576
|
}
|
|
897
|
-
static
|
|
577
|
+
static importAnime() {
|
|
898
578
|
return __awaiter(this, void 0, void 0, function* () {
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
const mangas = (_a = XMLObject === null || XMLObject === void 0 ? void 0 : XMLObject.myanimelist) === null || _a === void 0 ? void 0 : _a.manga;
|
|
915
|
-
if ((mangas === null || mangas === void 0 ? void 0 : mangas.length) > 0) {
|
|
916
|
-
let count = 0;
|
|
917
|
-
const statusMap = {
|
|
918
|
-
'On-Hold': AniListMediaStatus.PAUSED,
|
|
919
|
-
'Dropped': AniListMediaStatus.DROPPED,
|
|
920
|
-
'Completed': AniListMediaStatus.COMPLETED,
|
|
921
|
-
'Reading': AniListMediaStatus.CURRENT,
|
|
922
|
-
'Plan to Read': AniListMediaStatus.PLANNING,
|
|
923
|
-
};
|
|
924
|
-
for (const manga of mangas) {
|
|
925
|
-
const malId = manga.manga_mangadb_id;
|
|
926
|
-
const progress = manga.my_read_chapters;
|
|
927
|
-
const status = statusMap[manga.my_status];
|
|
928
|
-
try {
|
|
929
|
-
// Fetch AniList ID using MAL ID
|
|
930
|
-
const anilistResponse = yield fetcher(malIdToAnilistMangaId, { malId });
|
|
931
|
-
const anilistId = (_c = (_b = anilistResponse === null || anilistResponse === void 0 ? void 0 : anilistResponse.data) === null || _b === void 0 ? void 0 : _b.Media) === null || _c === void 0 ? void 0 : _c.id;
|
|
932
|
-
if (anilistId) {
|
|
933
|
-
// Save manga entry with progress
|
|
934
|
-
const saveResponse = yield fetcher(saveMangaWithProgressMutation, {
|
|
935
|
-
mediaId: anilistId,
|
|
936
|
-
progress,
|
|
937
|
-
status,
|
|
938
|
-
hiddenFromStatusLists: false,
|
|
939
|
-
private: false,
|
|
940
|
-
});
|
|
941
|
-
const entryId = (_e = (_d = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _d === void 0 ? void 0 : _d.SaveMediaListEntry) === null || _e === void 0 ? void 0 : _e.id;
|
|
942
|
-
if (entryId) {
|
|
943
|
-
count++;
|
|
944
|
-
console.log(`[${count}] ${entryId} ✅`);
|
|
945
|
-
}
|
|
946
|
-
else {
|
|
947
|
-
console.error(`Failed to save entry for ${malId}`);
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
else {
|
|
951
|
-
console.error(`Could not retrieve AniList ID for MAL ID ${malId}`);
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
catch (error) {
|
|
955
|
-
console.error(`Error processing MAL ID ${malId}: ${error.message}`);
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
console.log(`\nTotal Entries Processed: ${count}`);
|
|
959
|
-
}
|
|
960
|
-
else {
|
|
961
|
-
console.log(`\nNo manga list seems to be found.`);
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
catch (error) {
|
|
966
|
-
console.error(`\nError from MAL import: ${error.message}`);
|
|
967
|
-
}
|
|
579
|
+
return MyAnimeList.importMALList({
|
|
580
|
+
validator: Validate.Import_AnimeXML,
|
|
581
|
+
listKey: 'anime',
|
|
582
|
+
malIdField: 'series_animedb_id',
|
|
583
|
+
progressField: 'my_watched_episodes',
|
|
584
|
+
statusMap: {
|
|
585
|
+
'On-Hold': AniListMediaStatus.PAUSED,
|
|
586
|
+
'Dropped': AniListMediaStatus.DROPPED,
|
|
587
|
+
'Completed': AniListMediaStatus.COMPLETED,
|
|
588
|
+
'Watching': AniListMediaStatus.CURRENT,
|
|
589
|
+
'Plan to Watch': AniListMediaStatus.PLANNING,
|
|
590
|
+
},
|
|
591
|
+
malIdQuery: malIdToAnilistAnimeId,
|
|
592
|
+
saveMutation: saveAnimeWithProgressMutation,
|
|
593
|
+
});
|
|
968
594
|
});
|
|
969
595
|
}
|
|
970
|
-
static
|
|
596
|
+
static importManga() {
|
|
971
597
|
return __awaiter(this, void 0, void 0, function* () {
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
siteUrl: (_e = entry === null || entry === void 0 ? void 0 : entry.media) === null || _e === void 0 ? void 0 : _e.siteUrl,
|
|
988
|
-
progress: entry.progress,
|
|
989
|
-
status: entry === null || entry === void 0 ? void 0 : entry.status,
|
|
990
|
-
hiddenFromStatusLists: false,
|
|
991
|
-
format: (_f = entry === null || entry === void 0 ? void 0 : entry.media) === null || _f === void 0 ? void 0 : _f.format,
|
|
992
|
-
});
|
|
993
|
-
}));
|
|
994
|
-
yield saveJSONasXML(mediaWithProgress, 0);
|
|
995
|
-
}
|
|
996
|
-
else {
|
|
997
|
-
console.log(`\nHey, ${yield Auth.MyUserName()}. Your anime list seems to be empty.`);
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
catch (error) {
|
|
1002
|
-
console.error(`\nError from MALexport. ${error.message}`);
|
|
1003
|
-
}
|
|
598
|
+
return MyAnimeList.importMALList({
|
|
599
|
+
validator: Validate.Import_MangaXML,
|
|
600
|
+
listKey: 'manga',
|
|
601
|
+
malIdField: 'manga_mangadb_id',
|
|
602
|
+
progressField: 'my_read_chapters',
|
|
603
|
+
statusMap: {
|
|
604
|
+
'On-Hold': AniListMediaStatus.PAUSED,
|
|
605
|
+
'Dropped': AniListMediaStatus.DROPPED,
|
|
606
|
+
'Completed': AniListMediaStatus.COMPLETED,
|
|
607
|
+
'Reading': AniListMediaStatus.CURRENT,
|
|
608
|
+
'Plan to Read': AniListMediaStatus.PLANNING,
|
|
609
|
+
},
|
|
610
|
+
malIdQuery: malIdToAnilistMangaId,
|
|
611
|
+
saveMutation: saveMangaWithProgressMutation,
|
|
612
|
+
});
|
|
1004
613
|
});
|
|
1005
614
|
}
|
|
1006
|
-
|
|
615
|
+
/**
|
|
616
|
+
* Fetch the authenticated user's anime/manga list and export it as MAL XML.
|
|
617
|
+
*/
|
|
618
|
+
static exportMALList(listQuery, mapEntry, dataType) {
|
|
1007
619
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1008
|
-
var _a, _b
|
|
620
|
+
var _a, _b;
|
|
1009
621
|
try {
|
|
1010
622
|
if (!(yield Auth.isLoggedIn())) {
|
|
1011
623
|
console.log(`\nPlease login to use this feature.`);
|
|
1012
624
|
return;
|
|
1013
625
|
}
|
|
1014
|
-
const
|
|
626
|
+
const list = yield fetcher(listQuery, {
|
|
1015
627
|
id: yield Auth.MyUserId(),
|
|
1016
628
|
});
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => ({
|
|
1020
|
-
id: entry.media.id,
|
|
1021
|
-
malId: entry.media.idMal,
|
|
1022
|
-
title: entry.media.title,
|
|
1023
|
-
private: entry.private,
|
|
1024
|
-
chapters: entry.media.chapters,
|
|
1025
|
-
progress: entry.progress,
|
|
1026
|
-
status: entry.status,
|
|
1027
|
-
hiddenFromStatusLists: entry.hiddenFromStatusLists,
|
|
1028
|
-
})));
|
|
1029
|
-
yield saveJSONasXML(mediaWithProgress, 1);
|
|
1030
|
-
}
|
|
1031
|
-
else {
|
|
629
|
+
const lists = (_b = (_a = list === null || list === void 0 ? void 0 : list.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists;
|
|
630
|
+
if (!lists || lists.length === 0) {
|
|
1032
631
|
console.log(`\nHey, ${yield Auth.MyUserName()}. Your anime list seems to be empty.`);
|
|
632
|
+
return;
|
|
1033
633
|
}
|
|
634
|
+
const mediaWithProgress = lists.flatMap((l) => l.entries.map(mapEntry));
|
|
635
|
+
yield saveJSONasXML(mediaWithProgress, dataType);
|
|
1034
636
|
}
|
|
1035
637
|
catch (error) {
|
|
1036
638
|
console.error(`\nError from MALexport. ${error.message}`);
|
|
1037
639
|
}
|
|
1038
640
|
});
|
|
1039
641
|
}
|
|
642
|
+
static exportAnime() {
|
|
643
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
644
|
+
return MyAnimeList.exportMALList(currentUserAnimeList, (entry) => {
|
|
645
|
+
var _a, _b, _c, _d, _e, _f;
|
|
646
|
+
return ({
|
|
647
|
+
id: (_a = entry === null || entry === void 0 ? void 0 : entry.media) === null || _a === void 0 ? void 0 : _a.id,
|
|
648
|
+
malId: (_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.idMal,
|
|
649
|
+
title: (_c = entry === null || entry === void 0 ? void 0 : entry.media) === null || _c === void 0 ? void 0 : _c.title,
|
|
650
|
+
episodes: (_d = entry === null || entry === void 0 ? void 0 : entry.media) === null || _d === void 0 ? void 0 : _d.episodes,
|
|
651
|
+
siteUrl: (_e = entry === null || entry === void 0 ? void 0 : entry.media) === null || _e === void 0 ? void 0 : _e.siteUrl,
|
|
652
|
+
progress: entry.progress,
|
|
653
|
+
status: entry === null || entry === void 0 ? void 0 : entry.status,
|
|
654
|
+
hiddenFromStatusLists: false,
|
|
655
|
+
format: (_f = entry === null || entry === void 0 ? void 0 : entry.media) === null || _f === void 0 ? void 0 : _f.format,
|
|
656
|
+
});
|
|
657
|
+
}, 0);
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
static exportManga() {
|
|
661
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
662
|
+
return MyAnimeList.exportMALList(currentUserMangaList, (entry) => ({
|
|
663
|
+
id: entry.media.id,
|
|
664
|
+
malId: entry.media.idMal,
|
|
665
|
+
title: entry.media.title,
|
|
666
|
+
private: entry.private,
|
|
667
|
+
chapters: entry.media.chapters,
|
|
668
|
+
progress: entry.progress,
|
|
669
|
+
status: entry.status,
|
|
670
|
+
hiddenFromStatusLists: entry.hiddenFromStatusLists,
|
|
671
|
+
}), 1);
|
|
672
|
+
});
|
|
673
|
+
}
|
|
1040
674
|
}
|
|
1041
675
|
class AniDB {
|
|
1042
676
|
static importAnime() {
|