@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/README.md
CHANGED
|
@@ -208,7 +208,7 @@ anilist export -a
|
|
|
208
208
|
- **Options**:
|
|
209
209
|
- `-a, --anime`: To export anime list.
|
|
210
210
|
- `-m, --manga`: To export manga list.
|
|
211
|
-
- **Description**: Export anime or manga list
|
|
211
|
+
- **Description**: Export anime or manga list. For `XML (MyAnimeList)` file, to import it on MyAnimeList, go [here](https://myanimelist.net/import.php) and choose `MyAnimeList Import`.
|
|
212
212
|
|
|
213
213
|
#### `import` _(alias: `imp`)_:
|
|
214
214
|
|
|
@@ -219,7 +219,7 @@ anilist import -m
|
|
|
219
219
|
- **Options**:
|
|
220
220
|
- `-a, --anime`: To import anime list.
|
|
221
221
|
- `-m, --manga`: To import manga list.
|
|
222
|
-
- **Description**: Import anime or manga list
|
|
222
|
+
- **Description**: Import anime or manga list. If you want to import anime/manga list from MyAnimeList, export the XML from [here](https://myanimelist.net/panel.php?go=export).
|
|
223
223
|
|
|
224
224
|
#### Security
|
|
225
225
|
|
package/bin/helpers/auth.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ declare function storeAccessToken(token: string): Promise<void>;
|
|
|
3
3
|
declare function retriveAccessToken(): Promise<string>;
|
|
4
4
|
declare function anilistUserLogin(clientId: number, clientSecret: string): Promise<void>;
|
|
5
5
|
declare function currentUserInfo(): Promise<any>;
|
|
6
|
-
declare function isLoggedIn(): Promise<
|
|
6
|
+
declare function isLoggedIn(): Promise<boolean>;
|
|
7
7
|
declare function logoutUser(): Promise<void>;
|
|
8
8
|
declare function currentUsersId(): Promise<any>;
|
|
9
9
|
declare function currentUsersName(): Promise<any>;
|
|
10
|
-
export {
|
|
10
|
+
export { anilistUserLogin, currentUserInfo, currentUsersId, currentUsersName, getAccessTokenFromUser, isLoggedIn, logoutUser, retriveAccessToken, storeAccessToken, };
|
package/bin/helpers/auth.js
CHANGED
|
@@ -8,14 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import fs from "fs";
|
|
11
|
-
import os from "os";
|
|
12
|
-
import path from "path";
|
|
13
11
|
import inquirer from "inquirer";
|
|
14
|
-
import open from "open";
|
|
15
12
|
import fetch from "node-fetch";
|
|
13
|
+
import open from "open";
|
|
14
|
+
import os from "os";
|
|
15
|
+
import path from "path";
|
|
16
|
+
import { fetcher } from "./fetcher.js";
|
|
16
17
|
import { currentUserQuery, userActivityQuery } from "./queries.js";
|
|
17
18
|
import { aniListEndpoint, getTitle, redirectUri } from "./workers.js";
|
|
18
|
-
import { fetcher } from "./fetcher.js";
|
|
19
19
|
const home_dir = os.homedir();
|
|
20
20
|
const save_path = path.join(home_dir, ".anilist_token");
|
|
21
21
|
function getAccessTokenFromUser() {
|
|
@@ -36,7 +36,7 @@ function storeAccessToken(token) {
|
|
|
36
36
|
fs.writeFileSync(save_path, token, { encoding: "utf8" });
|
|
37
37
|
}
|
|
38
38
|
catch (error) {
|
|
39
|
-
console.error(
|
|
39
|
+
console.error(`\nError storing acess-token. ${error.message}`);
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
}
|
|
@@ -78,23 +78,21 @@ function anilistUserLogin(clientId, clientSecret) {
|
|
|
78
78
|
console.log(`\nWelcome Back, ${name}!`);
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
|
-
console.log(
|
|
81
|
+
console.log(`\nLogged in successfull!`);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
|
-
console.error("
|
|
85
|
+
console.error("\nFailed to get access token:", token_Data);
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
function currentUserInfo() {
|
|
90
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
91
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
92
|
-
|
|
93
|
-
if (loggedIn) {
|
|
94
|
-
const sToken = yield retriveAccessToken();
|
|
92
|
+
if (yield isLoggedIn()) {
|
|
95
93
|
const headers = {
|
|
96
94
|
"Content-Type": "application/json",
|
|
97
|
-
Authorization: `Bearer ${
|
|
95
|
+
"Authorization": `Bearer ${yield retriveAccessToken()}`,
|
|
98
96
|
};
|
|
99
97
|
const request = yield fetch(aniListEndpoint, {
|
|
100
98
|
method: "POST",
|
|
@@ -110,26 +108,35 @@ function currentUserInfo() {
|
|
|
110
108
|
perPage: 10,
|
|
111
109
|
});
|
|
112
110
|
const activities = (_b = (_a = activiResponse === null || activiResponse === void 0 ? void 0 : activiResponse.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.activities;
|
|
113
|
-
console.log(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
111
|
+
console.log(`
|
|
112
|
+
ID: ${user === null || user === void 0 ? void 0 : user.id}
|
|
113
|
+
Name: ${user === null || user === void 0 ? void 0 : user.name}
|
|
114
|
+
siteUrl: ${user === null || user === void 0 ? void 0 : user.siteUrl}
|
|
115
|
+
profileColor: ${(_c = user === null || user === void 0 ? void 0 : user.options) === null || _c === void 0 ? void 0 : _c.profileColor}
|
|
116
|
+
timeZone: ${(_d = user === null || user === void 0 ? void 0 : user.options) === null || _d === void 0 ? void 0 : _d.timezone}
|
|
117
|
+
activityMergeTime: ${(_e = user === null || user === void 0 ? void 0 : user.options) === null || _e === void 0 ? void 0 : _e.activityMergeTime}
|
|
118
|
+
donatorTier: ${user === null || user === void 0 ? void 0 : user.donatorTier}
|
|
119
|
+
donatorBadge: ${user === null || user === void 0 ? void 0 : user.donatorBadge}
|
|
120
|
+
unreadNotificationCount:${user === null || user === void 0 ? void 0 : user.unreadNotificationCount}
|
|
121
|
+
Account Created: ${new Date((user === null || user === void 0 ? void 0 : user.createdAt) * 1000).toUTCString()}
|
|
122
|
+
Account Updated: ${new Date((user === null || user === void 0 ? void 0 : user.updatedAt) * 1000).toUTCString()}
|
|
123
|
+
|
|
124
|
+
Statistics (Anime):
|
|
125
|
+
Count: ${(_g = (_f = user === null || user === void 0 ? void 0 : user.statistics) === null || _f === void 0 ? void 0 : _f.anime) === null || _g === void 0 ? void 0 : _g.count}
|
|
126
|
+
Mean Score: ${(_j = (_h = user === null || user === void 0 ? void 0 : user.statistics) === null || _h === void 0 ? void 0 : _h.anime) === null || _j === void 0 ? void 0 : _j.meanScore}
|
|
127
|
+
Minutes Watched: ${(_l = (_k = user === null || user === void 0 ? void 0 : user.statistics) === null || _k === void 0 ? void 0 : _k.anime) === null || _l === void 0 ? void 0 : _l.minutesWatched}
|
|
128
|
+
|
|
129
|
+
Statistics (Manga):
|
|
130
|
+
Count: ${(_o = (_m = user === null || user === void 0 ? void 0 : user.statistics) === null || _m === void 0 ? void 0 : _m.manga) === null || _o === void 0 ? void 0 : _o.count}
|
|
131
|
+
Chapters Read: ${(_q = (_p = user === null || user === void 0 ? void 0 : user.statistics) === null || _p === void 0 ? void 0 : _p.manga) === null || _q === void 0 ? void 0 : _q.chaptersRead}
|
|
132
|
+
Volumes Read: ${(_s = (_r = user === null || user === void 0 ? void 0 : user.statistics) === null || _r === void 0 ? void 0 : _r.manga) === null || _s === void 0 ? void 0 : _s.volumesRead}
|
|
133
|
+
`);
|
|
126
134
|
console.log(`\nRecent Activities:`);
|
|
127
|
-
activities.length > 0
|
|
128
|
-
activities.map(({
|
|
129
|
-
progress
|
|
130
|
-
? console.log(`${status} ${progress} of ${getTitle(media === null || media === void 0 ? void 0 : media.title)}`)
|
|
131
|
-
: console.log(`${status} ${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
|
|
135
|
+
if (activities.length > 0) {
|
|
136
|
+
activities.map(({ status, progress, media }) => {
|
|
137
|
+
console.log(`${status} ${progress ? `${progress} of ` : ""}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
|
|
132
138
|
});
|
|
139
|
+
}
|
|
133
140
|
return user;
|
|
134
141
|
}
|
|
135
142
|
else {
|
|
@@ -145,8 +152,7 @@ function currentUserInfo() {
|
|
|
145
152
|
}
|
|
146
153
|
function isLoggedIn() {
|
|
147
154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
-
|
|
149
|
-
if (isTokenStored !== null) {
|
|
155
|
+
if ((yield retriveAccessToken()) !== null) {
|
|
150
156
|
return true;
|
|
151
157
|
}
|
|
152
158
|
else {
|
|
@@ -158,9 +164,8 @@ function logoutUser() {
|
|
|
158
164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
159
165
|
if (fs.existsSync(save_path)) {
|
|
160
166
|
try {
|
|
161
|
-
const username = yield currentUsersName();
|
|
162
167
|
fs.unlinkSync(save_path);
|
|
163
|
-
console.log(`\nLogout successful. See you soon, ${
|
|
168
|
+
console.log(`\nLogout successful. See you soon, ${yield currentUsersName()}.`);
|
|
164
169
|
}
|
|
165
170
|
catch (error) {
|
|
166
171
|
console.error("\nError logging out:", error);
|
|
@@ -174,11 +179,15 @@ function logoutUser() {
|
|
|
174
179
|
function currentUsersId() {
|
|
175
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
176
181
|
var _a;
|
|
182
|
+
if (!(yield isLoggedIn())) {
|
|
183
|
+
console.log(`\nUser not logged in.`);
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
177
186
|
const request = yield fetch(aniListEndpoint, {
|
|
178
187
|
method: "POST",
|
|
179
188
|
headers: {
|
|
180
189
|
"Content-Type": "application/json",
|
|
181
|
-
Authorization: `Bearer ${yield retriveAccessToken()}`,
|
|
190
|
+
"Authorization": `Bearer ${yield retriveAccessToken()}`,
|
|
182
191
|
},
|
|
183
192
|
body: JSON.stringify({ query: currentUserQuery }),
|
|
184
193
|
});
|
|
@@ -194,11 +203,15 @@ function currentUsersId() {
|
|
|
194
203
|
function currentUsersName() {
|
|
195
204
|
return __awaiter(this, void 0, void 0, function* () {
|
|
196
205
|
var _a;
|
|
206
|
+
if (!(yield isLoggedIn())) {
|
|
207
|
+
console.log(`\nUser not logged in.`);
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
197
210
|
const request = yield fetch(aniListEndpoint, {
|
|
198
211
|
method: "POST",
|
|
199
212
|
headers: {
|
|
200
213
|
"Content-Type": "application/json",
|
|
201
|
-
Authorization: `Bearer ${yield retriveAccessToken()}`,
|
|
214
|
+
"Authorization": `Bearer ${yield retriveAccessToken()}`,
|
|
202
215
|
},
|
|
203
216
|
body: JSON.stringify({ query: currentUserQuery }),
|
|
204
217
|
});
|
|
@@ -211,4 +224,4 @@ function currentUsersName() {
|
|
|
211
224
|
}
|
|
212
225
|
});
|
|
213
226
|
}
|
|
214
|
-
export {
|
|
227
|
+
export { anilistUserLogin, currentUserInfo, currentUsersId, currentUsersName, getAccessTokenFromUser, isLoggedIn, logoutUser, retriveAccessToken, storeAccessToken, };
|
package/bin/helpers/fetcher.js
CHANGED
|
@@ -8,8 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import fetch from "node-fetch";
|
|
11
|
-
import { aniListEndpoint } from "./workers.js";
|
|
12
11
|
import { isLoggedIn, retriveAccessToken } from "./auth.js";
|
|
12
|
+
import { aniListEndpoint } from "./workers.js";
|
|
13
13
|
/**
|
|
14
14
|
* Sends a GraphQL request to the AniList API.
|
|
15
15
|
*
|
|
@@ -24,11 +24,10 @@ function fetcher(query, variables) {
|
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
var _a;
|
|
26
26
|
try {
|
|
27
|
-
const LOGGEDIN = yield isLoggedIn();
|
|
28
27
|
const headers = {
|
|
29
28
|
"content-type": "application/json",
|
|
30
29
|
};
|
|
31
|
-
if (
|
|
30
|
+
if (yield isLoggedIn()) {
|
|
32
31
|
headers["Authorization"] = `Bearer ${yield retriveAccessToken()}`;
|
|
33
32
|
}
|
|
34
33
|
const request = yield fetch(aniListEndpoint, {
|
package/bin/helpers/lists.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ declare function loggedInUsersMangaLists(): Promise<void>;
|
|
|
5
5
|
declare function deleteAnimeCollection(): Promise<void>;
|
|
6
6
|
declare function deleteMangaCollection(): Promise<void>;
|
|
7
7
|
declare function getUpcomingAnimes(count: number): Promise<void>;
|
|
8
|
-
export {
|
|
8
|
+
export { deleteAnimeCollection, deleteMangaCollection, getPopular, getTrending, getUpcomingAnimes, loggedInUsersAnimeLists, loggedInUsersMangaLists, };
|
package/bin/helpers/lists.js
CHANGED
|
@@ -7,14 +7,13 @@ 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 fetch from "node-fetch";
|
|
11
10
|
import inquirer from "inquirer";
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import { currentUserAnimeList, currentUserMangaList } from "./queries.js";
|
|
15
|
-
import { isLoggedIn, currentUsersId, retriveAccessToken } from "./auth.js";
|
|
16
|
-
import { addAnimeToListMutation, addMangaToListMutation } from "./mutations.js";
|
|
11
|
+
import fetch from "node-fetch";
|
|
12
|
+
import { currentUsersId, isLoggedIn, retriveAccessToken } from "./auth.js";
|
|
17
13
|
import { fetcher } from "./fetcher.js";
|
|
14
|
+
import { addAnimeToListMutation, addMangaToListMutation } from "./mutations.js";
|
|
15
|
+
import { currentUserAnimeList, currentUserMangaList, deleteMangaEntryMutation, deleteMediaEntryMutation, popularQuery, trendingQuery, upcomingAnimesQuery, } from "./queries.js";
|
|
16
|
+
import { aniListEndpoint, getNextSeasonAndYear, getTitle } from "./workers.js";
|
|
18
17
|
function getTrending(count) {
|
|
19
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
19
|
var _a, _b, _c, _d;
|
|
@@ -61,8 +60,7 @@ function getTrending(count) {
|
|
|
61
60
|
},
|
|
62
61
|
]);
|
|
63
62
|
// Lets save to the list now
|
|
64
|
-
|
|
65
|
-
if (ISLOGGEDIN) {
|
|
63
|
+
if (yield isLoggedIn()) {
|
|
66
64
|
const query = addAnimeToListMutation;
|
|
67
65
|
const variables = {
|
|
68
66
|
mediaId: selectedAnime,
|
|
@@ -137,8 +135,7 @@ function getPopular(count) {
|
|
|
137
135
|
},
|
|
138
136
|
]);
|
|
139
137
|
// Lets save to the list now
|
|
140
|
-
|
|
141
|
-
if (ISLOGGEDIN) {
|
|
138
|
+
if (yield isLoggedIn()) {
|
|
142
139
|
const query = addAnimeToListMutation;
|
|
143
140
|
const variables = {
|
|
144
141
|
mediaId: selectedAnime,
|
|
@@ -171,19 +168,17 @@ function loggedInUsersAnimeLists() {
|
|
|
171
168
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
169
|
var _a, _b, _c, _d, _e;
|
|
173
170
|
try {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const userID = yield currentUsersId();
|
|
177
|
-
if (userID) {
|
|
171
|
+
if (yield isLoggedIn()) {
|
|
172
|
+
if (yield currentUsersId()) {
|
|
178
173
|
const request = yield fetch(aniListEndpoint, {
|
|
179
174
|
method: "POST",
|
|
180
175
|
headers: {
|
|
181
176
|
"content-type": "application/json",
|
|
182
|
-
Authorization: `Bearer ${yield retriveAccessToken()}`,
|
|
177
|
+
"Authorization": `Bearer ${yield retriveAccessToken()}`,
|
|
183
178
|
},
|
|
184
179
|
body: JSON.stringify({
|
|
185
180
|
query: currentUserAnimeList,
|
|
186
|
-
variables: { id:
|
|
181
|
+
variables: { id: yield currentUsersId() },
|
|
187
182
|
}),
|
|
188
183
|
});
|
|
189
184
|
const response = yield request.json();
|
|
@@ -233,8 +228,7 @@ function loggedInUsersAnimeLists() {
|
|
|
233
228
|
},
|
|
234
229
|
]);
|
|
235
230
|
// Lets save to the list now
|
|
236
|
-
|
|
237
|
-
if (ISLOGGEDIN) {
|
|
231
|
+
if (yield isLoggedIn()) {
|
|
238
232
|
const query = addAnimeToListMutation;
|
|
239
233
|
const variables = {
|
|
240
234
|
mediaId: selectedAnime,
|
|
@@ -283,15 +277,14 @@ function loggedInUsersMangaLists() {
|
|
|
283
277
|
return __awaiter(this, void 0, void 0, function* () {
|
|
284
278
|
var _a, _b, _c, _d, _e, _f;
|
|
285
279
|
try {
|
|
286
|
-
|
|
287
|
-
if (loggedIn) {
|
|
280
|
+
if (yield isLoggedIn()) {
|
|
288
281
|
const userID = yield currentUsersId();
|
|
289
282
|
if (userID) {
|
|
290
283
|
const request = yield fetch(aniListEndpoint, {
|
|
291
284
|
method: "POST",
|
|
292
285
|
headers: {
|
|
293
286
|
"Content-Type": "application/json",
|
|
294
|
-
Authorization: `Bearer ${yield retriveAccessToken()}`,
|
|
287
|
+
"Authorization": `Bearer ${yield retriveAccessToken()}`,
|
|
295
288
|
},
|
|
296
289
|
body: JSON.stringify({
|
|
297
290
|
query: currentUserMangaList,
|
|
@@ -344,8 +337,7 @@ function loggedInUsersMangaLists() {
|
|
|
344
337
|
},
|
|
345
338
|
]);
|
|
346
339
|
// Save the selected manga to the selected list type
|
|
347
|
-
|
|
348
|
-
if (ISLOGGEDIN) {
|
|
340
|
+
if (yield isLoggedIn()) {
|
|
349
341
|
const query = addMangaToListMutation;
|
|
350
342
|
const variables = {
|
|
351
343
|
mediaId: selectedManga,
|
|
@@ -355,7 +347,7 @@ function loggedInUsersMangaLists() {
|
|
|
355
347
|
method: "POST",
|
|
356
348
|
headers: {
|
|
357
349
|
"Content-Type": "application/json",
|
|
358
|
-
Authorization: `Bearer ${yield retriveAccessToken()}`,
|
|
350
|
+
"Authorization": `Bearer ${yield retriveAccessToken()}`,
|
|
359
351
|
},
|
|
360
352
|
body: JSON.stringify({ query, variables }),
|
|
361
353
|
});
|
|
@@ -400,15 +392,14 @@ function loggedInUsersMangaLists() {
|
|
|
400
392
|
function deleteAnimeCollection() {
|
|
401
393
|
return __awaiter(this, void 0, void 0, function* () {
|
|
402
394
|
var _a, _b, _c, _d;
|
|
403
|
-
|
|
404
|
-
if (loggedIn) {
|
|
395
|
+
if (yield isLoggedIn()) {
|
|
405
396
|
const userID = yield currentUsersId();
|
|
406
397
|
if (userID) {
|
|
407
398
|
const request = yield fetch(aniListEndpoint, {
|
|
408
399
|
method: "POST",
|
|
409
400
|
headers: {
|
|
410
401
|
"content-type": "application/json",
|
|
411
|
-
Authorization: `Bearer ${yield retriveAccessToken()}`,
|
|
402
|
+
"Authorization": `Bearer ${yield retriveAccessToken()}`,
|
|
412
403
|
},
|
|
413
404
|
body: JSON.stringify({
|
|
414
405
|
query: currentUserAnimeList,
|
|
@@ -431,7 +422,7 @@ function deleteAnimeCollection() {
|
|
|
431
422
|
const selectedEntries = lists.find((list) => list.name === selectedList);
|
|
432
423
|
if (selectedEntries) {
|
|
433
424
|
console.log(`\nDeleting entries of '${selectedEntries.name}':`);
|
|
434
|
-
for (const [
|
|
425
|
+
for (const [_, entry] of selectedEntries.entries.entries()) {
|
|
435
426
|
if (entry === null || entry === void 0 ? void 0 : entry.id) {
|
|
436
427
|
yield deleteAnimeByAnimeId(entry === null || entry === void 0 ? void 0 : entry.id, (_c = entry === null || entry === void 0 ? void 0 : entry.media) === null || _c === void 0 ? void 0 : _c.title);
|
|
437
428
|
yield new Promise((resolve) => setTimeout(resolve, 2000));
|
|
@@ -471,7 +462,7 @@ function deleteAnimeByAnimeId(id, title) {
|
|
|
471
462
|
method: "POST",
|
|
472
463
|
headers: {
|
|
473
464
|
"content-type": "application/json",
|
|
474
|
-
Authorization: `Bearer ${yield retriveAccessToken()}`,
|
|
465
|
+
"Authorization": `Bearer ${yield retriveAccessToken()}`,
|
|
475
466
|
},
|
|
476
467
|
body: JSON.stringify({
|
|
477
468
|
query: deleteMediaEntryMutation,
|
|
@@ -496,15 +487,14 @@ function deleteAnimeByAnimeId(id, title) {
|
|
|
496
487
|
function deleteMangaCollection() {
|
|
497
488
|
return __awaiter(this, void 0, void 0, function* () {
|
|
498
489
|
var _a, _b, _c, _d;
|
|
499
|
-
|
|
500
|
-
if (loggedIn) {
|
|
490
|
+
if (yield isLoggedIn()) {
|
|
501
491
|
const userID = yield currentUsersId();
|
|
502
492
|
if (userID) {
|
|
503
493
|
const request = yield fetch(aniListEndpoint, {
|
|
504
494
|
method: "POST",
|
|
505
495
|
headers: {
|
|
506
496
|
"content-type": "application/json",
|
|
507
|
-
Authorization: `Bearer ${yield retriveAccessToken()}`,
|
|
497
|
+
"Authorization": `Bearer ${yield retriveAccessToken()}`,
|
|
508
498
|
},
|
|
509
499
|
body: JSON.stringify({
|
|
510
500
|
query: currentUserMangaList,
|
|
@@ -527,7 +517,7 @@ function deleteMangaCollection() {
|
|
|
527
517
|
const selectedEntries = lists.find((list) => list.name === selectedList);
|
|
528
518
|
if (selectedEntries) {
|
|
529
519
|
console.log(`\nDeleting entries of '${selectedEntries.name}':`);
|
|
530
|
-
for (const [
|
|
520
|
+
for (const [_, entry] of selectedEntries.entries.entries()) {
|
|
531
521
|
if (entry === null || entry === void 0 ? void 0 : entry.id) {
|
|
532
522
|
yield deleteMangaByMangaId(entry === null || entry === void 0 ? void 0 : entry.id, (_c = entry === null || entry === void 0 ? void 0 : entry.media) === null || _c === void 0 ? void 0 : _c.title);
|
|
533
523
|
yield new Promise((resolve) => setTimeout(resolve, 2000));
|
|
@@ -561,31 +551,31 @@ function deleteMangaCollection() {
|
|
|
561
551
|
}
|
|
562
552
|
function deleteMangaByMangaId(id, title) {
|
|
563
553
|
return __awaiter(this, void 0, void 0, function* () {
|
|
564
|
-
var _a, _b
|
|
554
|
+
var _a, _b;
|
|
565
555
|
try {
|
|
566
556
|
const request = yield fetch(aniListEndpoint, {
|
|
567
557
|
method: "POST",
|
|
568
558
|
headers: {
|
|
569
|
-
"
|
|
570
|
-
Authorization: `Bearer ${yield retriveAccessToken()}`,
|
|
559
|
+
"Content-Type": "application/json",
|
|
560
|
+
"Authorization": `Bearer ${yield retriveAccessToken()}`,
|
|
571
561
|
},
|
|
572
562
|
body: JSON.stringify({
|
|
573
563
|
query: deleteMangaEntryMutation,
|
|
574
564
|
variables: { id },
|
|
575
565
|
}),
|
|
576
566
|
});
|
|
577
|
-
const
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
567
|
+
const { data, errors } = yield request.json();
|
|
568
|
+
const statusMessage = title ? getTitle(title) : "";
|
|
569
|
+
if (request.ok) {
|
|
570
|
+
const deleted = (_a = data === null || data === void 0 ? void 0 : data.DeleteMediaListEntry) === null || _a === void 0 ? void 0 : _a.deleted;
|
|
571
|
+
console.log(`del ${statusMessage} ${deleted ? "✅" : "❌"}`);
|
|
581
572
|
}
|
|
582
573
|
else {
|
|
583
|
-
console.
|
|
584
|
-
console.log(response);
|
|
574
|
+
console.error(`Error deleting manga. ${(_b = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _b === void 0 ? void 0 : _b.message}`);
|
|
585
575
|
}
|
|
586
576
|
}
|
|
587
577
|
catch (error) {
|
|
588
|
-
console.
|
|
578
|
+
console.error(`Error deleting manga. ${id} ${error instanceof Error ? error.message : error}`);
|
|
589
579
|
}
|
|
590
580
|
});
|
|
591
581
|
}
|
|
@@ -594,24 +584,13 @@ function getUpcomingAnimes(count) {
|
|
|
594
584
|
var _a, _b, _c, _d, _e;
|
|
595
585
|
try {
|
|
596
586
|
const { nextSeason, nextYear } = getNextSeasonAndYear();
|
|
597
|
-
const
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
if (loggedIn) {
|
|
602
|
-
headers["Authorization"] = `Bearer ${yield retriveAccessToken()}`;
|
|
603
|
-
}
|
|
604
|
-
const request = yield fetch(aniListEndpoint, {
|
|
605
|
-
method: "POST",
|
|
606
|
-
headers: headers,
|
|
607
|
-
body: JSON.stringify({
|
|
608
|
-
query: upcomingAnimesQuery,
|
|
609
|
-
variables: { nextSeason, nextYear, perPage: count },
|
|
610
|
-
}),
|
|
587
|
+
const request = yield fetcher(upcomingAnimesQuery, {
|
|
588
|
+
nextSeason,
|
|
589
|
+
nextYear,
|
|
590
|
+
perPage: count,
|
|
611
591
|
});
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
const upcoming = (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.media) !== null && _c !== void 0 ? _c : [];
|
|
592
|
+
if (request) {
|
|
593
|
+
const upcoming = (_c = (_b = (_a = request === null || request === void 0 ? void 0 : request.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.media) !== null && _c !== void 0 ? _c : [];
|
|
615
594
|
const { selectedAnime } = yield inquirer.prompt([
|
|
616
595
|
{
|
|
617
596
|
type: "list",
|
|
@@ -640,8 +619,7 @@ function getUpcomingAnimes(count) {
|
|
|
640
619
|
},
|
|
641
620
|
]);
|
|
642
621
|
// Lets save to the list now
|
|
643
|
-
|
|
644
|
-
if (ISLOGGEDIN) {
|
|
622
|
+
if (yield isLoggedIn()) {
|
|
645
623
|
const query = addAnimeToListMutation;
|
|
646
624
|
const variables = { mediaId: selectedAnime, status: selectedListType };
|
|
647
625
|
const response = yield fetcher(query, variables);
|
|
@@ -655,7 +633,7 @@ function getUpcomingAnimes(count) {
|
|
|
655
633
|
}
|
|
656
634
|
}
|
|
657
635
|
else {
|
|
658
|
-
console.error(`\nSomething went wrong. ${(_e =
|
|
636
|
+
console.error(`\nSomething went wrong. ${(_e = request === null || request === void 0 ? void 0 : request.errors[0]) === null || _e === void 0 ? void 0 : _e.message}`);
|
|
659
637
|
}
|
|
660
638
|
}
|
|
661
639
|
catch (error) {
|
|
@@ -663,4 +641,4 @@ function getUpcomingAnimes(count) {
|
|
|
663
641
|
}
|
|
664
642
|
});
|
|
665
643
|
}
|
|
666
|
-
export {
|
|
644
|
+
export { deleteAnimeCollection, deleteMangaCollection, getPopular, getTrending, getUpcomingAnimes, loggedInUsersAnimeLists, loggedInUsersMangaLists, };
|
package/bin/helpers/more.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ declare function exportAnimeList(): Promise<void>;
|
|
|
8
8
|
declare function exportMangaList(): Promise<void>;
|
|
9
9
|
declare function importAnimeList(): Promise<void>;
|
|
10
10
|
declare function importMangaList(): Promise<void>;
|
|
11
|
-
export {
|
|
11
|
+
export { deleteUserActivities, exportAnimeList, exportMangaList, getAnimeDetailsByID, getAnimeSearchResults, getMangaSearchResults, getUserInfoByUsername, importAnimeList, importMangaList, writeTextActivity, };
|