@irfanshadikrishad/anilist 1.0.0 → 1.0.2
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 +47 -22
- package/bin/helpers/auth.d.ts +4 -3
- package/bin/helpers/auth.js +71 -22
- package/bin/helpers/fetcher.d.ts +12 -0
- package/bin/helpers/fetcher.js +54 -0
- package/bin/helpers/lists.d.ts +2 -1
- package/bin/helpers/lists.js +174 -13
- package/bin/helpers/more.d.ts +5 -1
- package/bin/helpers/more.js +227 -10
- package/bin/helpers/mutations.d.ts +4 -0
- package/bin/helpers/mutations.js +20 -0
- package/bin/helpers/queries.d.ts +20 -9
- package/bin/helpers/queries.js +103 -165
- package/bin/helpers/workers.d.ts +11 -1
- package/bin/helpers/workers.js +47 -7
- package/bin/index.js +62 -9
- package/package.json +2 -1
package/bin/helpers/workers.js
CHANGED
|
@@ -1,14 +1,54 @@
|
|
|
1
1
|
const aniListEndpoint = `https://graphql.anilist.co`;
|
|
2
2
|
const redirectUri = "https://anilist.co/api/v2/oauth/pin";
|
|
3
3
|
function getTitle(title) {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
return (title === null || title === void 0 ? void 0 : title.english) || (title === null || title === void 0 ? void 0 : title.romaji) || "???";
|
|
5
|
+
}
|
|
6
|
+
function formatDateObject(dateObj) {
|
|
7
|
+
if (!dateObj)
|
|
8
|
+
return "null";
|
|
9
|
+
return ([dateObj.day, dateObj.month, dateObj.year].filter(Boolean).join("/") ||
|
|
10
|
+
"null");
|
|
11
|
+
}
|
|
12
|
+
function getNextSeasonAndYear() {
|
|
13
|
+
const currentMonth = new Date().getMonth() + 1;
|
|
14
|
+
const currentYear = new Date().getFullYear();
|
|
15
|
+
let nextSeason;
|
|
16
|
+
let nextYear;
|
|
17
|
+
// Determine the current season
|
|
18
|
+
if (currentMonth >= 12 || currentMonth <= 2) {
|
|
19
|
+
nextSeason = "SPRING";
|
|
20
|
+
nextYear = currentMonth === 12 ? currentYear + 1 : currentYear;
|
|
21
|
+
}
|
|
22
|
+
else if (currentMonth >= 3 && currentMonth <= 5) {
|
|
23
|
+
nextSeason = "SUMMER";
|
|
24
|
+
nextYear = currentYear;
|
|
6
25
|
}
|
|
7
|
-
else if (
|
|
8
|
-
|
|
26
|
+
else if (currentMonth >= 6 && currentMonth <= 8) {
|
|
27
|
+
nextSeason = "FALL";
|
|
28
|
+
nextYear = currentYear;
|
|
9
29
|
}
|
|
10
|
-
else {
|
|
11
|
-
|
|
30
|
+
else if (currentMonth >= 9 && currentMonth <= 11) {
|
|
31
|
+
nextSeason = "WINTER";
|
|
32
|
+
nextYear = currentYear + 1;
|
|
33
|
+
}
|
|
34
|
+
return { nextSeason, nextYear };
|
|
35
|
+
}
|
|
36
|
+
function removeHtmlAndMarkdown(input) {
|
|
37
|
+
if (input) {
|
|
38
|
+
input = input.replace(/<\/?[^>]+(>|$)/g, "");
|
|
39
|
+
input = input.replace(/(^|\n)#{1,6}\s+(.+?)(\n|$)/g, "$2 ");
|
|
40
|
+
input = input.replace(/(\*\*|__)(.*?)\1/g, "$2");
|
|
41
|
+
input = input.replace(/(\*|_)(.*?)\1/g, "$2");
|
|
42
|
+
input = input.replace(/`(.+?)`/g, "$1");
|
|
43
|
+
input = input.replace(/\[(.*?)\]\(.*?\)/g, "$1");
|
|
44
|
+
input = input.replace(/!\[(.*?)\]\(.*?\)/g, "$1");
|
|
45
|
+
input = input.replace(/(^|\n)>\s+(.+?)(\n|$)/g, "$2 ");
|
|
46
|
+
input = input.replace(/(^|\n)-\s+(.+?)(\n|$)/g, "$2 ");
|
|
47
|
+
input = input.replace(/(^|\n)\d+\.\s+(.+?)(\n|$)/g, "$2 ");
|
|
48
|
+
input = input.replace(/(^|\n)\s*([-*_]){3,}\s*(\n|$)/g, "$1");
|
|
49
|
+
input = input.replace(/~~(.*?)~~/g, "$1");
|
|
50
|
+
input = input.replace(/\s+/g, " ").trim();
|
|
12
51
|
}
|
|
52
|
+
return input;
|
|
13
53
|
}
|
|
14
|
-
export { aniListEndpoint, redirectUri, getTitle };
|
|
54
|
+
export { aniListEndpoint, redirectUri, getTitle, getNextSeasonAndYear, formatDateObject, removeHtmlAndMarkdown, };
|
package/bin/index.js
CHANGED
|
@@ -10,10 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
import { Command } from "commander";
|
|
12
12
|
import { anilistUserLogin, currentUserInfo, logoutUser, } from "./helpers/auth.js";
|
|
13
|
-
import { deleteAnimeCollection, deleteMangaCollection, getPopular, getTrending, loggedInUsersAnimeLists, loggedInUsersMangaLists, } from "./helpers/lists.js";
|
|
14
|
-
import { getUserInfoByUsername } from "./helpers/more.js";
|
|
13
|
+
import { deleteAnimeCollection, deleteMangaCollection, getPopular, getTrending, getUpcomingAnimes, loggedInUsersAnimeLists, loggedInUsersMangaLists, } from "./helpers/lists.js";
|
|
14
|
+
import { getAnimeDetailsByID, getAnimeSearchResults, getMangaSearchResults, deleteUserActivities, getUserInfoByUsername, } from "./helpers/more.js";
|
|
15
15
|
const cli = new Command();
|
|
16
|
-
cli.name("anilist").description("Unofficial AniList CLI").version("1.0.
|
|
16
|
+
cli.name("anilist").description("Unofficial AniList CLI").version("1.0.1");
|
|
17
17
|
cli
|
|
18
18
|
.command("login")
|
|
19
19
|
.description("Login with AniList")
|
|
@@ -70,7 +70,7 @@ cli
|
|
|
70
70
|
.option("-m, --manga", "For manga list of authenticated user", false)
|
|
71
71
|
.action((_a) => __awaiter(void 0, [_a], void 0, function* ({ anime, manga }) {
|
|
72
72
|
if ((!anime && !manga) || (anime && manga)) {
|
|
73
|
-
console.
|
|
73
|
+
console.error(`Must select an option, either --anime or --manga`);
|
|
74
74
|
}
|
|
75
75
|
else if (anime) {
|
|
76
76
|
yield loggedInUsersAnimeLists();
|
|
@@ -82,18 +82,71 @@ cli
|
|
|
82
82
|
cli
|
|
83
83
|
.command("delete")
|
|
84
84
|
.alias("del")
|
|
85
|
-
.description("Delete entire collections of anime or
|
|
85
|
+
.description("Delete entire collections of anime or manga")
|
|
86
86
|
.option("-a, --anime", "For anime list of authenticated user", false)
|
|
87
87
|
.option("-m, --manga", "For manga list of authenticated user", false)
|
|
88
|
-
.
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
.option("-ac, --activity", "For activity of authenticated user", false)
|
|
89
|
+
.action((_a) => __awaiter(void 0, [_a], void 0, function* ({ anime, manga, activity }) {
|
|
90
|
+
const selectedOptions = [anime, manga, activity].filter(Boolean).length;
|
|
91
|
+
if (selectedOptions === 0) {
|
|
92
|
+
console.error(`Must select one option: either --anime, --manga, or --activity`);
|
|
93
|
+
process.exit(1);
|
|
91
94
|
}
|
|
92
|
-
|
|
95
|
+
if (selectedOptions > 1) {
|
|
96
|
+
console.error(`Only one option can be selected at a time: --anime, --manga, or --activity`);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
if (anime) {
|
|
93
100
|
yield deleteAnimeCollection();
|
|
94
101
|
}
|
|
95
102
|
else if (manga) {
|
|
96
103
|
yield deleteMangaCollection();
|
|
97
104
|
}
|
|
105
|
+
else if (activity) {
|
|
106
|
+
yield deleteUserActivities();
|
|
107
|
+
}
|
|
108
|
+
}));
|
|
109
|
+
cli
|
|
110
|
+
.command("upcoming")
|
|
111
|
+
.alias("up")
|
|
112
|
+
.description("Anime that will be released in upcoming season")
|
|
113
|
+
.option("-c, --count <number>", "Number of items to get", "10")
|
|
114
|
+
.action((_a) => __awaiter(void 0, [_a], void 0, function* ({ count }) {
|
|
115
|
+
yield getUpcomingAnimes(Number(count));
|
|
116
|
+
}));
|
|
117
|
+
cli
|
|
118
|
+
.command("anime <id>")
|
|
119
|
+
.description("Get anime details by their ID")
|
|
120
|
+
.action((id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
|
+
if (id && !Number.isNaN(Number(id))) {
|
|
122
|
+
yield getAnimeDetailsByID(Number(id));
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
console.error("Invalid or missing ID. Please provide a valid numeric ID.");
|
|
126
|
+
}
|
|
127
|
+
}));
|
|
128
|
+
cli
|
|
129
|
+
.command("search <query>")
|
|
130
|
+
.alias("srch")
|
|
131
|
+
.alias("find")
|
|
132
|
+
.description("Search anime or manga.")
|
|
133
|
+
.option("-a, --anime", "To get the anime search results.", false)
|
|
134
|
+
.option("-m, --manga", "To get the manga search results.", false)
|
|
135
|
+
.option("-c, --count", "Number of search results to show.", "10")
|
|
136
|
+
.action((query_1, _a) => __awaiter(void 0, [query_1, _a], void 0, function* (query, { anime, manga, count }) {
|
|
137
|
+
if ((!anime && !manga) || (anime && manga)) {
|
|
138
|
+
console.error(`Must select an option, either --anime or --manga`);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
if (anime) {
|
|
142
|
+
yield getAnimeSearchResults(query, Number(count));
|
|
143
|
+
}
|
|
144
|
+
else if (manga) {
|
|
145
|
+
yield getMangaSearchResults(query, Number(count));
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
console.error(`Must select an option, either --anime or --manga`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
98
151
|
}));
|
|
99
152
|
cli.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@irfanshadikrishad/anilist",
|
|
3
3
|
"description": "Unofficial AniList CLI",
|
|
4
4
|
"author": "Irfan Shadik Rishad",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.2",
|
|
6
6
|
"main": "./bin/index.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"types": "./bin/index.d.ts",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"type": "git",
|
|
24
24
|
"url": "https://github.com/irfanshadikrishad/anilist"
|
|
25
25
|
},
|
|
26
|
+
"homepage": "https://github.com/irfanshadikrishad/anilist",
|
|
26
27
|
"bugs": {
|
|
27
28
|
"url": "https://github.com/irfanshadikrishad/anilist/issues"
|
|
28
29
|
},
|