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