@irfanshadikrishad/anilist 1.2.4 → 1.2.6
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 +35 -20
- package/bin/helpers/auth.d.ts +13 -3
- package/bin/helpers/auth.js +297 -199
- package/bin/helpers/lists.d.ts +4 -1
- package/bin/helpers/lists.js +211 -114
- package/bin/helpers/queries.d.ts +5 -2
- package/bin/helpers/queries.js +20 -2
- package/bin/helpers/types.d.ts +179 -4
- package/bin/helpers/workers.d.ts +5 -4
- package/bin/helpers/workers.js +33 -2
- package/bin/index.js +25 -1
- package/package.json +7 -5
package/bin/helpers/workers.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ declare function getTitle(title: {
|
|
|
6
6
|
romaji?: string;
|
|
7
7
|
}): string;
|
|
8
8
|
declare function formatDateObject(dateObj: {
|
|
9
|
-
day?:
|
|
10
|
-
month?:
|
|
11
|
-
year?:
|
|
9
|
+
day?: number;
|
|
10
|
+
month?: number;
|
|
11
|
+
year?: number;
|
|
12
12
|
} | null): string;
|
|
13
13
|
declare function getNextSeasonAndYear(): {
|
|
14
14
|
nextSeason: string;
|
|
@@ -36,4 +36,5 @@ declare function createAnimeListXML(mediaWithProgress: MediaWithProgress[]): Pro
|
|
|
36
36
|
declare function createMangaListXML(mediaWithProgress: MediaWithProgress[]): Promise<string>;
|
|
37
37
|
declare function getCurrentPackageVersion(): string | null;
|
|
38
38
|
declare function timestampToTimeAgo(timestamp: number): string;
|
|
39
|
-
|
|
39
|
+
declare const anidbToanilistMapper: (romanjiName: string, year: number, englishName?: string) => Promise<number | null>;
|
|
40
|
+
export { anidbToanilistMapper, aniListEndpoint, createAnimeListXML, createAnimeXML, createMangaListXML, createMangaXML, formatDateObject, getCurrentPackageVersion, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, selectFile, timestampToTimeAgo, };
|
package/bin/helpers/workers.js
CHANGED
|
@@ -17,7 +17,9 @@ import { homedir } from "os";
|
|
|
17
17
|
import { join } from "path";
|
|
18
18
|
import process from "process";
|
|
19
19
|
import { Auth } from "./auth.js";
|
|
20
|
-
import {
|
|
20
|
+
import { fetcher } from "./fetcher.js";
|
|
21
|
+
import { animeSearchQuery } from "./queries.js";
|
|
22
|
+
import { MALAnimeStatus, MALMangaStatus, } from "./types.js";
|
|
21
23
|
const aniListEndpoint = `https://graphql.anilist.co`;
|
|
22
24
|
const redirectUri = "https://anilist.co/api/v2/oauth/pin";
|
|
23
25
|
function getTitle(title) {
|
|
@@ -314,4 +316,33 @@ function timestampToTimeAgo(timestamp) {
|
|
|
314
316
|
return `${years} year${years === 1 ? "" : "s"} ago`;
|
|
315
317
|
}
|
|
316
318
|
}
|
|
317
|
-
|
|
319
|
+
const anidbToanilistMapper = (romanjiName, year, englishName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
320
|
+
const fetchAnime = (search) => __awaiter(void 0, void 0, void 0, function* () {
|
|
321
|
+
var _a;
|
|
322
|
+
try {
|
|
323
|
+
const response = yield fetcher(animeSearchQuery, {
|
|
324
|
+
search,
|
|
325
|
+
perPage: 50,
|
|
326
|
+
});
|
|
327
|
+
return ((_a = response.data) === null || _a === void 0 ? void 0 : _a.Page.media) || [];
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
console.error("Error fetching AniList data:", error);
|
|
331
|
+
return [];
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
// Search using romanjiName first
|
|
335
|
+
let results = yield fetchAnime(romanjiName);
|
|
336
|
+
// If no results, fallback to englishName
|
|
337
|
+
if (!results.length && englishName) {
|
|
338
|
+
results = yield fetchAnime(englishName);
|
|
339
|
+
}
|
|
340
|
+
// Match using year
|
|
341
|
+
for (const anime of results) {
|
|
342
|
+
if (anime.startDate.year === year) {
|
|
343
|
+
return anime.id;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return null;
|
|
347
|
+
});
|
|
348
|
+
export { anidbToanilistMapper, aniListEndpoint, createAnimeListXML, createAnimeXML, createMangaListXML, createMangaXML, formatDateObject, getCurrentPackageVersion, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, selectFile, timestampToTimeAgo, };
|
package/bin/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
import { Command } from "commander";
|
|
12
12
|
import process from "process";
|
|
13
|
-
import { Auth } from "./helpers/auth.js";
|
|
13
|
+
import { Auth, Social } from "./helpers/auth.js";
|
|
14
14
|
import { AniList } from "./helpers/lists.js";
|
|
15
15
|
import { getCurrentPackageVersion } from "./helpers/workers.js";
|
|
16
16
|
const cli = new Command();
|
|
@@ -203,4 +203,28 @@ cli
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
}));
|
|
206
|
+
cli
|
|
207
|
+
.command("social")
|
|
208
|
+
.alias("sol")
|
|
209
|
+
.description("Automate your process")
|
|
210
|
+
.option("-f, --follow", "Follow the user whos following you.", false)
|
|
211
|
+
.option("-u, --unfollow", "Unfollow the user whos not following you.", false)
|
|
212
|
+
.action((_a) => __awaiter(void 0, [_a], void 0, function* ({ follow, unfollow }) {
|
|
213
|
+
if (!follow && !unfollow) {
|
|
214
|
+
console.error(`\nMust select an option, either --follow or --unfollow`);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
if (yield Auth.isLoggedIn()) {
|
|
218
|
+
if (follow) {
|
|
219
|
+
yield Social.follow();
|
|
220
|
+
}
|
|
221
|
+
else if (unfollow) {
|
|
222
|
+
yield Social.unfollow();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
console.error(`\nPlease login to use this feature.`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}));
|
|
206
230
|
cli.parse(process.argv);
|
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.2.
|
|
5
|
+
"version": "1.2.6",
|
|
6
6
|
"main": "./bin/index.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"types": "./bin/index.d.ts",
|
|
@@ -54,10 +54,12 @@
|
|
|
54
54
|
},
|
|
55
55
|
"license": "MPL-2.0",
|
|
56
56
|
"devDependencies": {
|
|
57
|
+
"@babel/preset-env": "^7.26.0",
|
|
57
58
|
"@eslint/js": "^9.17.0",
|
|
58
59
|
"@types/jest": "^29.5.14",
|
|
59
60
|
"@types/json2csv": "^5.0.7",
|
|
60
61
|
"@types/node": "^22.10.5",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^8.19.0",
|
|
61
63
|
"eslint": "^9.17.0",
|
|
62
64
|
"globals": "^15.14.0",
|
|
63
65
|
"jest": "^29.7.0",
|
|
@@ -65,16 +67,16 @@
|
|
|
65
67
|
"prettier-plugin-organize-imports": "^4.1.0",
|
|
66
68
|
"ts-jest": "^29.2.5",
|
|
67
69
|
"ts-node": "^10.9.2",
|
|
68
|
-
"typescript": "^5.7.2"
|
|
69
|
-
"@babel/preset-env": "^7.26.0",
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "^8.19.0"
|
|
70
|
+
"typescript": "^5.7.2"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"commander": "^13.0.0",
|
|
74
74
|
"fast-xml-parser": "^4.5.1",
|
|
75
75
|
"inquirer": "^12.3.0",
|
|
76
76
|
"json2csv": "^6.0.0-alpha.2",
|
|
77
|
+
"jsonrepair": "^3.11.2",
|
|
77
78
|
"node-fetch": "^3.3.2",
|
|
78
|
-
"open": "^10.1.0"
|
|
79
|
+
"open": "^10.1.0",
|
|
80
|
+
"tiny-spinner": "^2.0.4"
|
|
79
81
|
}
|
|
80
82
|
}
|