@irfanshadikrishad/anilist 3.0.0-forbidden.0 → 3.0.1-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/README.md +4 -4
- package/bin/helpers/auth.js +62 -112
- package/bin/helpers/fetcher.d.ts +4 -8
- package/bin/helpers/fetcher.js +10 -16
- package/bin/helpers/lib/render.d.ts +2 -0
- package/bin/helpers/lib/render.js +35 -0
- package/bin/helpers/lists.js +10 -70
- package/bin/helpers/types.d.ts +25 -0
- package/bin/helpers/workers.d.ts +27 -1
- package/bin/helpers/workers.js +135 -1
- package/bin/index.js +1 -23
- package/package.json +11 -6
- package/.claude/settings.local.json +0 -3
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts.
|
|
4
4
|
|
|
5
|
-

|
|
6
|
+

|
|
7
|
+

|
|
8
8
|
|
|
9
9
|
#### How to install?
|
|
10
10
|
|
|
@@ -20,7 +20,7 @@ If you see the version then its installed. Otherwise install nodejs and npm shou
|
|
|
20
20
|
Then install the package by running
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
npm install -g @irfanshadikrishad/anilist
|
|
23
|
+
npm install -g @irfanshadikrishad/anilist@forbidden
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
This will install the package globally. And you have to use commands like
|
package/bin/helpers/auth.js
CHANGED
|
@@ -19,11 +19,12 @@ import Spinner from 'tiny-spinner';
|
|
|
19
19
|
import { fetcher } from './fetcher.js';
|
|
20
20
|
import { colorize } from './lib/colorize.js';
|
|
21
21
|
import { rate_limit_time_ms, symbol_done, symbol_fail, symbol_neutral, } from './lib/constants.js';
|
|
22
|
+
import { renderUserProfile } from './lib/render.js';
|
|
22
23
|
import { AniDB, AniList, MyAnimeList } from './lists.js';
|
|
23
|
-
import {
|
|
24
|
+
import { deleteMangaEntryMutation, deleteMediaEntryMutation, likeActivityMutation, saveTextActivityMutation, toggleFollowMutation, } from './mutations.js';
|
|
24
25
|
import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, followingActivitiesQuery, globalActivitiesQuery, specificUserActivitiesQuery, userActivityQuery, userFollowersQuery, userFollowingQuery, userQuery, } from './queries.js';
|
|
25
26
|
import { responsiveOutput } from './truncate.js';
|
|
26
|
-
import { activityBy, aniListEndpoint, getTitle, redirectUri, sleep, timestampToTimeAgo, } from './workers.js';
|
|
27
|
+
import { activityBy, aniListEndpoint, deleteActivities, getTitle, redirectUri, sleep, timestampToTimeAgo, } from './workers.js';
|
|
27
28
|
const home_dir = os.homedir();
|
|
28
29
|
const save_path = path.join(home_dir, '.anilist_token');
|
|
29
30
|
const spinner = new Spinner();
|
|
@@ -71,12 +72,10 @@ class Auth {
|
|
|
71
72
|
static RetriveAccessToken() {
|
|
72
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
74
|
try {
|
|
74
|
-
if (fs.existsSync(save_path)) {
|
|
75
|
-
return vigenere.decrypt(fs.readFileSync(save_path, { encoding: 'utf8' }));
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
75
|
+
if (!fs.existsSync(save_path)) {
|
|
78
76
|
return null;
|
|
79
77
|
}
|
|
78
|
+
return vigenere.decrypt(fs.readFileSync(save_path, { encoding: 'utf8' }));
|
|
80
79
|
}
|
|
81
80
|
catch (error) {
|
|
82
81
|
console.error(`\nError retriving acess-token. ${error.message}`);
|
|
@@ -106,19 +105,13 @@ class Auth {
|
|
|
106
105
|
}),
|
|
107
106
|
});
|
|
108
107
|
const token_Data = yield tokenResponse.json();
|
|
109
|
-
if (token_Data === null || token_Data === void 0 ? void 0 : token_Data.access_token) {
|
|
110
|
-
yield Auth.StoreAccessToken(token_Data === null || token_Data === void 0 ? void 0 : token_Data.access_token);
|
|
111
|
-
const name = yield Auth.MyUserName();
|
|
112
|
-
if (name) {
|
|
113
|
-
console.log(`\nWelcome Back, ${name}!`);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
console.log(`\nLogged in successfull!`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
108
|
+
if (!(token_Data === null || token_Data === void 0 ? void 0 : token_Data.access_token)) {
|
|
120
109
|
console.error('\nFailed to get access token:', token_Data);
|
|
110
|
+
return;
|
|
121
111
|
}
|
|
112
|
+
yield Auth.StoreAccessToken(token_Data.access_token);
|
|
113
|
+
const name = yield Auth.MyUserName();
|
|
114
|
+
console.log(name ? `\nWelcome Back, ${name}!` : '\nLogged in successfully!');
|
|
122
115
|
}
|
|
123
116
|
catch (error) {
|
|
124
117
|
console.error(`\nFailed logging in. ${error.message}`);
|
|
@@ -127,81 +120,53 @@ class Auth {
|
|
|
127
120
|
}
|
|
128
121
|
static Myself() {
|
|
129
122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o
|
|
123
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
131
124
|
try {
|
|
132
|
-
if (yield Auth.isLoggedIn()) {
|
|
133
|
-
|
|
125
|
+
if (!(yield Auth.isLoggedIn())) {
|
|
126
|
+
console.error('\nPlease login first to use this feature.');
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
const accessToken = yield Auth.RetriveAccessToken();
|
|
130
|
+
const request = yield fetch(aniListEndpoint, {
|
|
131
|
+
method: 'POST',
|
|
132
|
+
headers: {
|
|
134
133
|
'Content-Type': 'application/json',
|
|
135
|
-
'Authorization': `Bearer ${
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
if (request.status === 200) {
|
|
144
|
-
const user = data === null || data === void 0 ? void 0 : data.Viewer;
|
|
145
|
-
const activiResponse = yield fetcher(userActivityQuery, {
|
|
146
|
-
id: user === null || user === void 0 ? void 0 : user.id,
|
|
147
|
-
page: 1,
|
|
148
|
-
perPage: 10,
|
|
149
|
-
});
|
|
150
|
-
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;
|
|
151
|
-
// Get follower/following information
|
|
152
|
-
const req_followers = yield fetcher(userFollowersQuery, {
|
|
153
|
-
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
154
|
-
});
|
|
155
|
-
const req_following = yield fetcher(userFollowingQuery, {
|
|
156
|
-
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
157
|
-
});
|
|
158
|
-
const followersCount = ((_e = (_d = (_c = req_followers === null || req_followers === void 0 ? void 0 : req_followers.data) === null || _c === void 0 ? void 0 : _c.Page) === null || _d === void 0 ? void 0 : _d.pageInfo) === null || _e === void 0 ? void 0 : _e.total) || 0;
|
|
159
|
-
const followingCount = ((_h = (_g = (_f = req_following === null || req_following === void 0 ? void 0 : req_following.data) === null || _f === void 0 ? void 0 : _f.Page) === null || _g === void 0 ? void 0 : _g.pageInfo) === null || _h === void 0 ? void 0 : _h.total) || 0;
|
|
160
|
-
console.log(`
|
|
161
|
-
ID: ${user === null || user === void 0 ? void 0 : user.id}
|
|
162
|
-
Name: ${user === null || user === void 0 ? void 0 : user.name}
|
|
163
|
-
siteUrl: ${user === null || user === void 0 ? void 0 : user.siteUrl}
|
|
164
|
-
profileColor: ${(_j = user === null || user === void 0 ? void 0 : user.options) === null || _j === void 0 ? void 0 : _j.profileColor}
|
|
165
|
-
timeZone: ${(_k = user === null || user === void 0 ? void 0 : user.options) === null || _k === void 0 ? void 0 : _k.timezone}
|
|
166
|
-
activityMergeTime: ${(_l = user === null || user === void 0 ? void 0 : user.options) === null || _l === void 0 ? void 0 : _l.activityMergeTime}
|
|
167
|
-
donatorTier: ${user === null || user === void 0 ? void 0 : user.donatorTier}
|
|
168
|
-
donatorBadge: ${user === null || user === void 0 ? void 0 : user.donatorBadge}
|
|
169
|
-
unreadNotificationCount:${user === null || user === void 0 ? void 0 : user.unreadNotificationCount}
|
|
170
|
-
Account Created: ${new Date((user === null || user === void 0 ? void 0 : user.createdAt) * 1000).toUTCString()}
|
|
171
|
-
Account Updated: ${new Date((user === null || user === void 0 ? void 0 : user.updatedAt) * 1000).toUTCString()}
|
|
172
|
-
|
|
173
|
-
Followers: ${followersCount}
|
|
174
|
-
Following: ${followingCount}
|
|
175
|
-
|
|
176
|
-
Statistics (Anime):
|
|
177
|
-
Count: ${(_o = (_m = user === null || user === void 0 ? void 0 : user.statistics) === null || _m === void 0 ? void 0 : _m.anime) === null || _o === void 0 ? void 0 : _o.count}
|
|
178
|
-
Mean Score: ${(_q = (_p = user === null || user === void 0 ? void 0 : user.statistics) === null || _p === void 0 ? void 0 : _p.anime) === null || _q === void 0 ? void 0 : _q.meanScore}
|
|
179
|
-
Minutes Watched: ${(_s = (_r = user === null || user === void 0 ? void 0 : user.statistics) === null || _r === void 0 ? void 0 : _r.anime) === null || _s === void 0 ? void 0 : _s.minutesWatched}
|
|
180
|
-
Episodes Watched: ${(_u = (_t = user === null || user === void 0 ? void 0 : user.statistics) === null || _t === void 0 ? void 0 : _t.anime) === null || _u === void 0 ? void 0 : _u.episodesWatched}
|
|
181
|
-
|
|
182
|
-
Statistics (Manga):
|
|
183
|
-
Count: ${(_w = (_v = user === null || user === void 0 ? void 0 : user.statistics) === null || _v === void 0 ? void 0 : _v.manga) === null || _w === void 0 ? void 0 : _w.count}
|
|
184
|
-
Mean Score: ${(_y = (_x = user === null || user === void 0 ? void 0 : user.statistics) === null || _x === void 0 ? void 0 : _x.manga) === null || _y === void 0 ? void 0 : _y.meanScore}
|
|
185
|
-
Chapters Read: ${(_0 = (_z = user === null || user === void 0 ? void 0 : user.statistics) === null || _z === void 0 ? void 0 : _z.manga) === null || _0 === void 0 ? void 0 : _0.chaptersRead}
|
|
186
|
-
Volumes Read: ${(_2 = (_1 = user === null || user === void 0 ? void 0 : user.statistics) === null || _1 === void 0 ? void 0 : _1.manga) === null || _2 === void 0 ? void 0 : _2.volumesRead}
|
|
187
|
-
`);
|
|
188
|
-
console.log(`\nRecent Activities:`);
|
|
189
|
-
if (activities.length > 0) {
|
|
190
|
-
activities.map(({ status, progress, media, createdAt }) => {
|
|
191
|
-
responsiveOutput(`${timestampToTimeAgo(createdAt)}\t${status} ${progress ? `${progress} of ` : ''}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
return user;
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
console.error(`\nSomething went wrong. Please log in again. ${errors[0].message}`);
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
134
|
+
'Authorization': `Bearer ${accessToken}`,
|
|
135
|
+
},
|
|
136
|
+
body: JSON.stringify({ query: currentUserQuery }),
|
|
137
|
+
});
|
|
138
|
+
const { data, errors } = yield request.json();
|
|
139
|
+
if (!request.ok) {
|
|
140
|
+
console.error(`\nSomething went wrong. Please log in again. ${(_b = (_a = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'Unknown error'}`);
|
|
141
|
+
return null;
|
|
200
142
|
}
|
|
201
|
-
|
|
202
|
-
|
|
143
|
+
const user = data === null || data === void 0 ? void 0 : data.Viewer;
|
|
144
|
+
if (!user) {
|
|
145
|
+
console.error('\nUnable to retrieve user information.');
|
|
203
146
|
return null;
|
|
204
147
|
}
|
|
148
|
+
const [activityResponse, followersResponse, followingResponse] = yield Promise.all([
|
|
149
|
+
fetcher(userActivityQuery, {
|
|
150
|
+
id: user.id,
|
|
151
|
+
page: 1,
|
|
152
|
+
perPage: 10,
|
|
153
|
+
}),
|
|
154
|
+
fetcher(userFollowersQuery, {
|
|
155
|
+
userId: user.id,
|
|
156
|
+
}),
|
|
157
|
+
fetcher(userFollowingQuery, {
|
|
158
|
+
userId: user.id,
|
|
159
|
+
}),
|
|
160
|
+
]);
|
|
161
|
+
const activities = (_e = (_d = (_c = activityResponse === null || activityResponse === void 0 ? void 0 : activityResponse.data) === null || _c === void 0 ? void 0 : _c.Page) === null || _d === void 0 ? void 0 : _d.activities) !== null && _e !== void 0 ? _e : [];
|
|
162
|
+
const followersCount = (_j = (_h = (_g = (_f = followersResponse === null || followersResponse === void 0 ? void 0 : followersResponse.data) === null || _f === void 0 ? void 0 : _f.Page) === null || _g === void 0 ? void 0 : _g.pageInfo) === null || _h === void 0 ? void 0 : _h.total) !== null && _j !== void 0 ? _j : 0;
|
|
163
|
+
const followingCount = (_o = (_m = (_l = (_k = followingResponse === null || followingResponse === void 0 ? void 0 : followingResponse.data) === null || _k === void 0 ? void 0 : _k.Page) === null || _l === void 0 ? void 0 : _l.pageInfo) === null || _m === void 0 ? void 0 : _m.total) !== null && _o !== void 0 ? _o : 0;
|
|
164
|
+
renderUserProfile(user, followersCount, followingCount);
|
|
165
|
+
console.log('\nRecent Activities:');
|
|
166
|
+
activities.forEach(({ status, progress, media, createdAt }) => {
|
|
167
|
+
responsiveOutput(`${timestampToTimeAgo(createdAt)}\t${status} ${progress ? `${progress} of ` : ''}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
|
|
168
|
+
});
|
|
169
|
+
return user;
|
|
205
170
|
}
|
|
206
171
|
catch (error) {
|
|
207
172
|
console.error(`\nError from Myself. ${error.message}`);
|
|
@@ -266,7 +231,7 @@ Statistics (Manga):
|
|
|
266
231
|
}
|
|
267
232
|
static DeleteMyActivities() {
|
|
268
233
|
return __awaiter(this, void 0, void 0, function* () {
|
|
269
|
-
var _a, _b
|
|
234
|
+
var _a, _b;
|
|
270
235
|
try {
|
|
271
236
|
if (!(yield Auth.isLoggedIn())) {
|
|
272
237
|
console.error(`\nPlease log in to delete your activities.`);
|
|
@@ -304,34 +269,19 @@ Statistics (Manga):
|
|
|
304
269
|
perPage: 50,
|
|
305
270
|
userId: yield Auth.MyUserId(),
|
|
306
271
|
});
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const activities = (_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.activities;
|
|
310
|
-
if (!activities || activities.length === 0) {
|
|
311
|
-
console.log(`\nNo more activities available.`);
|
|
312
|
-
hasMoreActivities = false;
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
for (const act of activities) {
|
|
316
|
-
if (act === null || act === void 0 ? void 0 : act.id) {
|
|
317
|
-
const deleteResponse = yield fetcher(deleteActivityMutation, {
|
|
318
|
-
id: act === null || act === void 0 ? void 0 : act.id,
|
|
319
|
-
});
|
|
320
|
-
const isDeleted = (_f = (_e = deleteResponse === null || deleteResponse === void 0 ? void 0 : deleteResponse.data) === null || _e === void 0 ? void 0 : _e.DeleteActivity) === null || _f === void 0 ? void 0 : _f.deleted;
|
|
321
|
-
count++;
|
|
322
|
-
totalCount++;
|
|
323
|
-
console.log(`[${count}/${activities.length}/${totalCount}]\t${act === null || act === void 0 ? void 0 : act.id} ${isDeleted ? symbol_done : symbol_fail}`);
|
|
324
|
-
// Avoiding rate-limit
|
|
325
|
-
yield sleep(rate_limit_time_ms);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
272
|
+
const activities = (_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.activities;
|
|
273
|
+
if (!activities) {
|
|
331
274
|
// In case of an unexpected null response, exit the loop
|
|
332
275
|
console.log(`\nProbably deleted all the activities of this type.`);
|
|
333
276
|
hasMoreActivities = false;
|
|
334
277
|
}
|
|
278
|
+
else if (activities.length === 0) {
|
|
279
|
+
console.log(`\nNo more activities available.`);
|
|
280
|
+
hasMoreActivities = false;
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
totalCount = yield deleteActivities(activities, totalCount);
|
|
284
|
+
}
|
|
335
285
|
}
|
|
336
286
|
}
|
|
337
287
|
catch (error) {
|
package/bin/helpers/fetcher.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sends a GraphQL request to the AniList API.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @param {string} query - The AniList GraphQL query to be executed.
|
|
9
|
-
* @param {object} variables - An object containing the variables for the query.
|
|
10
|
-
* @returns {Promise<object|null>} The response from the API as a JSON object if successful; otherwise, null.
|
|
4
|
+
* @param query - The GraphQL query to execute.
|
|
5
|
+
* @param variables - Variables for the GraphQL query.
|
|
6
|
+
* @returns The API response if successful; otherwise, null.
|
|
11
7
|
*/
|
|
12
|
-
declare function fetcher(query: string, variables: object): Promise<
|
|
8
|
+
declare function fetcher<T = Record<string, unknown>>(query: string, variables: object): Promise<T | null>;
|
|
13
9
|
export { fetcher };
|
package/bin/helpers/fetcher.js
CHANGED
|
@@ -13,13 +13,9 @@ import { aniListEndpoint, handleRateLimitRetry } from './workers.js';
|
|
|
13
13
|
/**
|
|
14
14
|
* Sends a GraphQL request to the AniList API.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @param {string} query - The AniList GraphQL query to be executed.
|
|
21
|
-
* @param {object} variables - An object containing the variables for the query.
|
|
22
|
-
* @returns {Promise<object|null>} The response from the API as a JSON object if successful; otherwise, null.
|
|
16
|
+
* @param query - The GraphQL query to execute.
|
|
17
|
+
* @param variables - Variables for the GraphQL query.
|
|
18
|
+
* @returns The API response if successful; otherwise, null.
|
|
23
19
|
*/
|
|
24
20
|
function fetcher(query, variables) {
|
|
25
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -35,24 +31,22 @@ function fetcher(query, variables) {
|
|
|
35
31
|
headers['Authorization'] = `Bearer ${token}`;
|
|
36
32
|
const request = yield fetch(aniListEndpoint, {
|
|
37
33
|
method: 'POST',
|
|
38
|
-
headers
|
|
34
|
+
headers,
|
|
39
35
|
body: JSON.stringify({ query, variables }),
|
|
40
36
|
});
|
|
41
|
-
const response = yield request.json();
|
|
37
|
+
const response = (yield request.json());
|
|
42
38
|
if (request.status === 200) {
|
|
43
39
|
return response;
|
|
44
40
|
}
|
|
45
|
-
|
|
41
|
+
if (request.status === 429) {
|
|
46
42
|
yield handleRateLimitRetry(60);
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
console.error(`\n${request.status} ${((_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'}.`);
|
|
51
|
-
return null;
|
|
43
|
+
return fetcher(query, variables);
|
|
52
44
|
}
|
|
45
|
+
console.error(`\n${request.status} ${((_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'}.`);
|
|
46
|
+
return null;
|
|
53
47
|
}
|
|
54
48
|
catch (error) {
|
|
55
|
-
console.error(`\nSomething went wrong. ${error.message}.`);
|
|
49
|
+
console.error(`\nSomething went wrong. ${error instanceof Error ? error.message : String(error)}.`);
|
|
56
50
|
return null;
|
|
57
51
|
}
|
|
58
52
|
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Table from 'cli-table3';
|
|
2
|
+
export function renderUserProfile(user, followersCount, followingCount) {
|
|
3
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
4
|
+
const table = new Table({
|
|
5
|
+
chars: {
|
|
6
|
+
'top': '',
|
|
7
|
+
'top-mid': '',
|
|
8
|
+
'top-left': '',
|
|
9
|
+
'top-right': '',
|
|
10
|
+
'bottom': '',
|
|
11
|
+
'bottom-mid': '',
|
|
12
|
+
'bottom-left': '',
|
|
13
|
+
'bottom-right': '',
|
|
14
|
+
'left': '',
|
|
15
|
+
'left-mid': '',
|
|
16
|
+
'mid': '',
|
|
17
|
+
'mid-mid': '',
|
|
18
|
+
'right': '',
|
|
19
|
+
'right-mid': '',
|
|
20
|
+
'middle': '',
|
|
21
|
+
},
|
|
22
|
+
style: {
|
|
23
|
+
'padding-left': 0,
|
|
24
|
+
'padding-right': 0,
|
|
25
|
+
'head': [],
|
|
26
|
+
'border': [],
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
const row = (label, value) => [
|
|
30
|
+
label.padEnd(30),
|
|
31
|
+
String(value !== null && value !== void 0 ? value : 'null'),
|
|
32
|
+
];
|
|
33
|
+
table.push(row('ID:', user.id), row('Name:', user.name), row('siteUrl:', user.siteUrl), row('profileColor:', (_a = user.options) === null || _a === void 0 ? void 0 : _a.profileColor), row('timeZone:', (_b = user.options) === null || _b === void 0 ? void 0 : _b.timezone), row('activityMergeTime:', (_c = user.options) === null || _c === void 0 ? void 0 : _c.activityMergeTime), row('donatorTier:', user.donatorTier), row('donatorBadge:', user.donatorBadge), row('unreadNotificationCount:', user.unreadNotificationCount), row('Account Created:', new Date(user.createdAt * 1000).toUTCString()), row('Account Updated:', new Date(user.updatedAt * 1000).toUTCString()), ['', ''], row('Followers:', followersCount), row('Following:', followingCount), ['', ''], ['Statistics (Anime):', ''], row(' Count:', (_e = (_d = user.statistics) === null || _d === void 0 ? void 0 : _d.anime) === null || _e === void 0 ? void 0 : _e.count), row(' Mean Score:', (_g = (_f = user.statistics) === null || _f === void 0 ? void 0 : _f.anime) === null || _g === void 0 ? void 0 : _g.meanScore), row(' Minutes Watched:', (_j = (_h = user.statistics) === null || _h === void 0 ? void 0 : _h.anime) === null || _j === void 0 ? void 0 : _j.minutesWatched), row(' Episodes Watched:', (_l = (_k = user.statistics) === null || _k === void 0 ? void 0 : _k.anime) === null || _l === void 0 ? void 0 : _l.episodesWatched), ['', ''], ['Statistics (Manga):', ''], row(' Count:', (_o = (_m = user.statistics) === null || _m === void 0 ? void 0 : _m.manga) === null || _o === void 0 ? void 0 : _o.count), row(' Mean Score:', (_q = (_p = user.statistics) === null || _p === void 0 ? void 0 : _p.manga) === null || _q === void 0 ? void 0 : _q.meanScore), row(' Chapters Read:', (_s = (_r = user.statistics) === null || _r === void 0 ? void 0 : _r.manga) === null || _s === void 0 ? void 0 : _s.chaptersRead), row(' Volumes Read:', (_u = (_t = user.statistics) === null || _t === void 0 ? void 0 : _t.manga) === null || _u === void 0 ? void 0 : _u.volumesRead));
|
|
34
|
+
console.log(`\n${table.toString()}`);
|
|
35
|
+
}
|
package/bin/helpers/lists.js
CHANGED
|
@@ -19,7 +19,7 @@ import { animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserM
|
|
|
19
19
|
import { responsiveOutput } from './truncate.js';
|
|
20
20
|
import { AniListMediaStatus, } from './types.js';
|
|
21
21
|
import { Validate } from './validation.js';
|
|
22
|
-
import {
|
|
22
|
+
import { formatDateObject, getDownloadFolderPath, getNextSeasonAndYear, getTitle, logUserDetails, processAnimeList, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, saveJSONasXML, selectFile, simpleDateFormat, timestampToTimeAgo, } from './workers.js';
|
|
23
23
|
class AniList {
|
|
24
24
|
/**
|
|
25
25
|
* Prompt the user for a list status (Planning/Watching-Reading/Completed/Paused/Dropped)
|
|
@@ -675,7 +675,6 @@ class MyAnimeList {
|
|
|
675
675
|
class AniDB {
|
|
676
676
|
static importAnime() {
|
|
677
677
|
return __awaiter(this, void 0, void 0, function* () {
|
|
678
|
-
var _a, _b;
|
|
679
678
|
try {
|
|
680
679
|
const filename = yield selectFile('.json');
|
|
681
680
|
if (!filename) {
|
|
@@ -688,76 +687,17 @@ class AniDB {
|
|
|
688
687
|
console.error(`\nInvalid JSON Large file.`);
|
|
689
688
|
return;
|
|
690
689
|
}
|
|
691
|
-
if (js0n_repaired) {
|
|
692
|
-
const obj3ct = yield JSON.parse(js0n_repaired);
|
|
693
|
-
const animeList = obj3ct === null || obj3ct === void 0 ? void 0 : obj3ct.anime;
|
|
694
|
-
if ((animeList === null || animeList === void 0 ? void 0 : animeList.length) > 0) {
|
|
695
|
-
let count = 0;
|
|
696
|
-
let iteration = 0;
|
|
697
|
-
let missed = [];
|
|
698
|
-
for (const anime of animeList) {
|
|
699
|
-
iteration++;
|
|
700
|
-
const anidbId = anime.id;
|
|
701
|
-
const released = anime.broadcastDate; // DD-MM-YYYY (eg: "23.07.2016")
|
|
702
|
-
const status = anime.status;
|
|
703
|
-
// const type = anime.type
|
|
704
|
-
const totalEpisodes = anime.totalEpisodes;
|
|
705
|
-
const ownEpisodes = anime.ownEpisodes;
|
|
706
|
-
const romanjiName = anime.romanjiName;
|
|
707
|
-
const englishName = anime.englishName;
|
|
708
|
-
function getStatus(anidbStatus, episodesSeen) {
|
|
709
|
-
if (anidbStatus === 'complete') {
|
|
710
|
-
return AniListMediaStatus.COMPLETED;
|
|
711
|
-
}
|
|
712
|
-
else if (anidbStatus === 'incomplete' &&
|
|
713
|
-
Number(episodesSeen) > 0) {
|
|
714
|
-
return AniListMediaStatus.CURRENT;
|
|
715
|
-
}
|
|
716
|
-
else {
|
|
717
|
-
return AniListMediaStatus.PLANNING;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
let anilistId = yield anidbToanilistMapper(romanjiName, Number(released.split('.')[2]), englishName);
|
|
721
|
-
if (anilistId) {
|
|
722
|
-
try {
|
|
723
|
-
const saveResponse = yield fetcher(saveAnimeWithProgressMutation, {
|
|
724
|
-
mediaId: anilistId,
|
|
725
|
-
progress: ownEpisodes - 2,
|
|
726
|
-
status: getStatus(status, ownEpisodes),
|
|
727
|
-
hiddenFromStatusLists: false,
|
|
728
|
-
private: false,
|
|
729
|
-
});
|
|
730
|
-
const entryId = (_b = (_a = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _a === void 0 ? void 0 : _a.SaveMediaListEntry) === null || _b === void 0 ? void 0 : _b.id;
|
|
731
|
-
if (entryId) {
|
|
732
|
-
count++;
|
|
733
|
-
responsiveOutput(`[${count}]\t${entryId} ✅\t${anidbId}\t${anilistId}\t(${ownEpisodes}/${totalEpisodes})\t${status}–>${getStatus(status, ownEpisodes)}`);
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
catch (error) {
|
|
737
|
-
console.error(`Error processing AniDB ID ${anidbId}: ${error.message}`);
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
else {
|
|
741
|
-
missed.push({
|
|
742
|
-
anidbId: anidbId,
|
|
743
|
-
englishTitle: englishName,
|
|
744
|
-
romajiTitle: romanjiName,
|
|
745
|
-
});
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
responsiveOutput(`\nAccuracy: ${(((animeList.length - missed.length) / animeList.length) * 100).toFixed(2)}%\tTotal Processed: ${iteration}\tMissed: ${missed.length}`);
|
|
749
|
-
if (missed.length > 0) {
|
|
750
|
-
responsiveOutput(`Exporting missed entries to JSON file, Please add them manually.`);
|
|
751
|
-
yield saveJSONasJSON(missed, 'anidb-missed');
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
else {
|
|
755
|
-
console.log(`\nNo anime list found in the file.`);
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
else {
|
|
690
|
+
if (!js0n_repaired) {
|
|
759
691
|
console.log(`\nNo content found in the file or unable to read.`);
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
const obj3ct = yield JSON.parse(js0n_repaired);
|
|
695
|
+
const animeList = obj3ct === null || obj3ct === void 0 ? void 0 : obj3ct.anime;
|
|
696
|
+
if (!((animeList === null || animeList === void 0 ? void 0 : animeList.length) > 0)) {
|
|
697
|
+
console.log(`\nNo anime list found in the file.`);
|
|
698
|
+
return;
|
|
760
699
|
}
|
|
700
|
+
yield processAnimeList(animeList);
|
|
761
701
|
}
|
|
762
702
|
catch (error) {
|
|
763
703
|
console.error(`\nError in AniDB import process: ${error.message}`);
|
package/bin/helpers/types.d.ts
CHANGED
|
@@ -399,4 +399,29 @@ type MangaDetails = {
|
|
|
399
399
|
};
|
|
400
400
|
errors?: Error;
|
|
401
401
|
};
|
|
402
|
+
export type DeleteActivityResponse = {
|
|
403
|
+
data?: {
|
|
404
|
+
DeleteActivity: {
|
|
405
|
+
deleted: boolean;
|
|
406
|
+
};
|
|
407
|
+
};
|
|
408
|
+
errors?: {
|
|
409
|
+
message: string;
|
|
410
|
+
}[];
|
|
411
|
+
};
|
|
412
|
+
export type MissedEntry = {
|
|
413
|
+
anidbId: number;
|
|
414
|
+
englishTitle?: string;
|
|
415
|
+
romajiTitle?: string;
|
|
416
|
+
};
|
|
417
|
+
export type EntryResult = 'saved' | 'skipped' | 'missed';
|
|
418
|
+
export type AniDBAnimeEntry = {
|
|
419
|
+
id: number;
|
|
420
|
+
broadcastDate: string;
|
|
421
|
+
status: string;
|
|
422
|
+
totalEpisodes: number | string;
|
|
423
|
+
ownEpisodes: number | string;
|
|
424
|
+
romanjiName: string;
|
|
425
|
+
englishName?: string;
|
|
426
|
+
};
|
|
402
427
|
export { Activity, AniListMediaStatus, AnimeDetails, AnimeList, AnimeSearchResponse, DateMonthYear, DeleteMangaResponse, DeleteMediaListResponse, LikeActivityResponse, List, MALAnimeStatus, MALAnimeXML, MALMangaStatus, MalIdToAnilistIdResponse, MangaDetails, MediaEntry, MediaList, MediaListCollectionResponse, MediaListEntry, MediaTitle, MediaWithProgress, Myself, SaveMediaListEntryResponse, SaveTextActivityResponse, SpecificUserActivitiesResponse, TheActivity, ToggleFollowResponse, User, UserActivitiesResponse, UserFollower, UserFollowing, UserResponse, saveAnimeWithProgressResponse, };
|
package/bin/helpers/workers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateMonthYear, MALAnimeStatus, MALMangaStatus, MediaWithProgress, TheActivity, User } from './types.js';
|
|
1
|
+
import { Activity, AniDBAnimeEntry, DateMonthYear, MALAnimeStatus, MALMangaStatus, MediaWithProgress, TheActivity, User } from './types.js';
|
|
2
2
|
declare const aniListEndpoint = "https://graphql.anilist.co";
|
|
3
3
|
declare const redirectUri = "https://anilist.co/api/v2/oauth/pin";
|
|
4
4
|
declare function getTitle(title: {
|
|
@@ -50,4 +50,30 @@ declare function simpleDateFormat(date: DateMonthYear): string;
|
|
|
50
50
|
declare function sleep(ms: number): Promise<void>;
|
|
51
51
|
declare function handleRateLimitRetry(retryCount: number): Promise<void>;
|
|
52
52
|
declare function logUserDetails(user: User, followersCount: number, followingCount: number): void;
|
|
53
|
+
/**
|
|
54
|
+
* Dispatch to exactly one handler out of a set of mutually-exclusive options
|
|
55
|
+
* (eg: --anime/--manga, --follow/--unfollow/--inactive), optionally requiring login.
|
|
56
|
+
*/
|
|
57
|
+
export declare function dispatchOneOf(options: {
|
|
58
|
+
flag: boolean;
|
|
59
|
+
name: string;
|
|
60
|
+
handler: () => Promise<unknown>;
|
|
61
|
+
}[], { requireLogin }?: {
|
|
62
|
+
requireLogin?: boolean;
|
|
63
|
+
}): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Deletes a single activity and returns whether the API reported it as deleted.
|
|
66
|
+
*/
|
|
67
|
+
export declare function deleteActivity(id: number): Promise<boolean>;
|
|
68
|
+
/**
|
|
69
|
+
* Deletes every activity in the page (skipping entries without an id),
|
|
70
|
+
* logging progress and respecting the rate limit.
|
|
71
|
+
* Returns the updated running total.
|
|
72
|
+
*/
|
|
73
|
+
export declare function deleteActivities(activities: Activity[], totalCount: number): Promise<number>;
|
|
74
|
+
/**
|
|
75
|
+
* Processes the whole anime list, prints the summary,
|
|
76
|
+
* and exports unmapped entries to JSON.
|
|
77
|
+
*/
|
|
78
|
+
export declare function processAnimeList(animeList: AniDBAnimeEntry[]): Promise<void>;
|
|
53
79
|
export { activityBy, anidbToanilistMapper, aniListEndpoint, createAnimeListXML, createAnimeXML, createMangaListXML, createMangaXML, formatDateObject, getCurrentPackageVersion, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, handleRateLimitRetry, logUserDetails, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, saveJSONasXML, saveToPath, selectFile, simpleDateFormat, sleep, timestampToTimeAgo, };
|
package/bin/helpers/workers.js
CHANGED
|
@@ -30,8 +30,11 @@ import process from 'process';
|
|
|
30
30
|
import Spinner from 'tiny-spinner';
|
|
31
31
|
import { Auth } from './auth.js';
|
|
32
32
|
import { fetcher } from './fetcher.js';
|
|
33
|
+
import { rate_limit_time_ms, symbol_done, symbol_fail, } from './lib/constants.js';
|
|
34
|
+
import { deleteActivityMutation, saveAnimeWithProgressMutation, } from './mutations.js';
|
|
33
35
|
import { animeSearchQuery } from './queries.js';
|
|
34
|
-
import {
|
|
36
|
+
import { responsiveOutput } from './truncate.js';
|
|
37
|
+
import { AniListMediaStatus, MALAnimeStatus, MALMangaStatus, } from './types.js';
|
|
35
38
|
const aniListEndpoint = `https://graphql.anilist.co`;
|
|
36
39
|
const redirectUri = 'https://anilist.co/api/v2/oauth/pin';
|
|
37
40
|
const spinner = new Spinner();
|
|
@@ -476,4 +479,135 @@ function logUserDetails(user, followersCount, followingCount) {
|
|
|
476
479
|
'Volumes Read': ((_p = (_o = user.statistics) === null || _o === void 0 ? void 0 : _o.manga) === null || _p === void 0 ? void 0 : _p.volumesRead) || 0,
|
|
477
480
|
});
|
|
478
481
|
}
|
|
482
|
+
/**
|
|
483
|
+
* Dispatch to exactly one handler out of a set of mutually-exclusive options
|
|
484
|
+
* (eg: --anime/--manga, --follow/--unfollow/--inactive), optionally requiring login.
|
|
485
|
+
*/
|
|
486
|
+
export function dispatchOneOf(options_1) {
|
|
487
|
+
return __awaiter(this, arguments, void 0, function* (options, { requireLogin = false } = {}) {
|
|
488
|
+
const selected = options.filter(({ flag }) => flag);
|
|
489
|
+
if (selected.length !== 1) {
|
|
490
|
+
const names = options.map(({ name }) => `--${name}`);
|
|
491
|
+
const optionList = names.length <= 2
|
|
492
|
+
? names.join(' or ')
|
|
493
|
+
: `${names.slice(0, -1).join(', ')} or ${names[names.length - 1]}`;
|
|
494
|
+
console.error(`\nMust select an option, either ${optionList}`);
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
if (requireLogin && !(yield Auth.isLoggedIn())) {
|
|
498
|
+
console.error(`\nPlease login to use this feature.`);
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
yield selected[0].handler();
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Deletes a single activity and returns whether the API reported it as deleted.
|
|
506
|
+
*/
|
|
507
|
+
export function deleteActivity(id) {
|
|
508
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
509
|
+
var _a, _b;
|
|
510
|
+
const deleteResponse = yield fetcher(deleteActivityMutation, { id });
|
|
511
|
+
return Boolean((_b = (_a = deleteResponse === null || deleteResponse === void 0 ? void 0 : deleteResponse.data) === null || _a === void 0 ? void 0 : _a.DeleteActivity) === null || _b === void 0 ? void 0 : _b.deleted);
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Deletes every activity in the page (skipping entries without an id),
|
|
516
|
+
* logging progress and respecting the rate limit.
|
|
517
|
+
* Returns the updated running total.
|
|
518
|
+
*/
|
|
519
|
+
export function deleteActivities(activities, totalCount) {
|
|
520
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
521
|
+
let count = 0;
|
|
522
|
+
for (const act of activities) {
|
|
523
|
+
if (!(act === null || act === void 0 ? void 0 : act.id))
|
|
524
|
+
continue;
|
|
525
|
+
const isDeleted = yield deleteActivity(act.id);
|
|
526
|
+
count++;
|
|
527
|
+
totalCount++;
|
|
528
|
+
console.log(`[${count}/${activities.length}/${totalCount}]\t${act.id} ${isDeleted ? symbol_done : symbol_fail}`);
|
|
529
|
+
// Avoiding rate-limit
|
|
530
|
+
yield sleep(rate_limit_time_ms);
|
|
531
|
+
}
|
|
532
|
+
return totalCount;
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
function getStatus(anidbStatus, episodesSeen) {
|
|
536
|
+
if (anidbStatus === 'complete') {
|
|
537
|
+
return AniListMediaStatus.COMPLETED;
|
|
538
|
+
}
|
|
539
|
+
else if (anidbStatus === 'incomplete' && Number(episodesSeen) > 0) {
|
|
540
|
+
return AniListMediaStatus.CURRENT;
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
return AniListMediaStatus.PLANNING;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Maps a single AniDB entry to AniList and saves it.
|
|
548
|
+
* `nextCount` is the running success counter value to display if the save succeeds.
|
|
549
|
+
* Pushes unmapped entries into `missed`.
|
|
550
|
+
*/
|
|
551
|
+
function processAnimeEntry(anime, nextCount, missed) {
|
|
552
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
553
|
+
var _a, _b;
|
|
554
|
+
const anidbId = anime.id;
|
|
555
|
+
const released = anime.broadcastDate; // DD-MM-YYYY (eg: "23.07.2016")
|
|
556
|
+
const status = anime.status;
|
|
557
|
+
// const type = anime.type
|
|
558
|
+
const totalEpisodes = anime.totalEpisodes;
|
|
559
|
+
const ownEpisodes = anime.ownEpisodes;
|
|
560
|
+
const romanjiName = anime.romanjiName;
|
|
561
|
+
const englishName = anime.englishName;
|
|
562
|
+
const anilistId = yield anidbToanilistMapper(romanjiName, Number(released.split('.')[2]), englishName);
|
|
563
|
+
if (!anilistId) {
|
|
564
|
+
missed.push({
|
|
565
|
+
anidbId: anidbId,
|
|
566
|
+
englishTitle: englishName,
|
|
567
|
+
romajiTitle: romanjiName,
|
|
568
|
+
});
|
|
569
|
+
return 'missed';
|
|
570
|
+
}
|
|
571
|
+
try {
|
|
572
|
+
const saveResponse = yield fetcher(saveAnimeWithProgressMutation, {
|
|
573
|
+
mediaId: anilistId,
|
|
574
|
+
progress: Number(ownEpisodes) - 2,
|
|
575
|
+
status: getStatus(status, ownEpisodes),
|
|
576
|
+
hiddenFromStatusLists: false,
|
|
577
|
+
private: false,
|
|
578
|
+
});
|
|
579
|
+
const entryId = (_b = (_a = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.data) === null || _a === void 0 ? void 0 : _a.SaveMediaListEntry) === null || _b === void 0 ? void 0 : _b.id;
|
|
580
|
+
if (!entryId)
|
|
581
|
+
return 'skipped';
|
|
582
|
+
responsiveOutput(`[${nextCount}]\t${entryId} ✅\t${anidbId}\t${anilistId}\t(${ownEpisodes}/${totalEpisodes})\t${status}–>${getStatus(status, ownEpisodes)}`);
|
|
583
|
+
return 'saved';
|
|
584
|
+
}
|
|
585
|
+
catch (error) {
|
|
586
|
+
console.error(`Error processing AniDB ID ${anidbId}: ${error.message}`);
|
|
587
|
+
return 'skipped';
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Processes the whole anime list, prints the summary,
|
|
593
|
+
* and exports unmapped entries to JSON.
|
|
594
|
+
*/
|
|
595
|
+
export function processAnimeList(animeList) {
|
|
596
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
597
|
+
let count = 0;
|
|
598
|
+
let iteration = 0;
|
|
599
|
+
const missed = [];
|
|
600
|
+
for (const anime of animeList) {
|
|
601
|
+
iteration++;
|
|
602
|
+
const result = yield processAnimeEntry(anime, count + 1, missed);
|
|
603
|
+
if (result === 'saved')
|
|
604
|
+
count++;
|
|
605
|
+
}
|
|
606
|
+
responsiveOutput(`\nAccuracy: ${(((animeList.length - missed.length) / animeList.length) * 100).toFixed(2)}%\tTotal Processed: ${iteration}\tMissed: ${missed.length}`);
|
|
607
|
+
if (missed.length > 0) {
|
|
608
|
+
responsiveOutput(`Exporting missed entries to JSON file, Please add them manually.`);
|
|
609
|
+
yield saveJSONasJSON(missed, 'anidb-missed');
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
}
|
|
479
613
|
export { activityBy, anidbToanilistMapper, aniListEndpoint, createAnimeListXML, createAnimeXML, createMangaListXML, createMangaXML, formatDateObject, getCurrentPackageVersion, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, handleRateLimitRetry, logUserDetails, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, saveJSONasXML, saveToPath, selectFile, simpleDateFormat, sleep, timestampToTimeAgo, };
|
package/bin/index.js
CHANGED
|
@@ -12,30 +12,8 @@ import { Command } from 'commander';
|
|
|
12
12
|
import process from 'process';
|
|
13
13
|
import { Auth, Social } from './helpers/auth.js';
|
|
14
14
|
import { AniList } from './helpers/lists.js';
|
|
15
|
-
import { getCurrentPackageVersion } from './helpers/workers.js';
|
|
15
|
+
import { dispatchOneOf, getCurrentPackageVersion } from './helpers/workers.js';
|
|
16
16
|
const cli = new Command();
|
|
17
|
-
/**
|
|
18
|
-
* Dispatch to exactly one handler out of a set of mutually-exclusive options
|
|
19
|
-
* (eg: --anime/--manga, --follow/--unfollow/--inactive), optionally requiring login.
|
|
20
|
-
*/
|
|
21
|
-
function dispatchOneOf(options_1) {
|
|
22
|
-
return __awaiter(this, arguments, void 0, function* (options, { requireLogin = false } = {}) {
|
|
23
|
-
const selected = options.filter(({ flag }) => flag);
|
|
24
|
-
if (selected.length !== 1) {
|
|
25
|
-
const names = options.map(({ name }) => `--${name}`);
|
|
26
|
-
const optionList = names.length <= 2
|
|
27
|
-
? names.join(' or ')
|
|
28
|
-
: `${names.slice(0, -1).join(', ')} or ${names[names.length - 1]}`;
|
|
29
|
-
console.error(`\nMust select an option, either ${optionList}`);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (requireLogin && !(yield Auth.isLoggedIn())) {
|
|
33
|
-
console.error(`\nPlease login to use this feature.`);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
yield selected[0].handler();
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
17
|
cli
|
|
40
18
|
.name('anilist')
|
|
41
19
|
.description('Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts.')
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@irfanshadikrishad/anilist",
|
|
3
3
|
"description": "Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.1-forbidden.0",
|
|
5
5
|
"author": "Irfan Shadik Rishad",
|
|
6
6
|
"license": "MPL-2.0",
|
|
7
7
|
"scripts": {
|
|
@@ -56,17 +56,22 @@
|
|
|
56
56
|
"bin": {
|
|
57
57
|
"anilist": "./bin/index.js"
|
|
58
58
|
},
|
|
59
|
+
"allowScripts": {
|
|
60
|
+
"@parcel/watcher@2.6.0": true
|
|
61
|
+
},
|
|
59
62
|
"prettier": "@irfanshadikrishad/prettier",
|
|
60
63
|
"dependencies": {
|
|
61
64
|
"@irfanshadikrishad/cipher": "^1.7.2",
|
|
62
|
-
"
|
|
63
|
-
"
|
|
65
|
+
"@irfanshadikrishad/logger": "^0.2.1",
|
|
66
|
+
"chalk": "^6.0.1",
|
|
67
|
+
"cli-table3": "^0.6.5",
|
|
68
|
+
"cli-truncate": "^6.2.0",
|
|
64
69
|
"commander": "^14.0.3",
|
|
65
70
|
"fast-xml-parser": "^5.12.1",
|
|
66
71
|
"inquirer": "^12.11.1",
|
|
67
72
|
"jsonrepair": "^3.15.0",
|
|
68
73
|
"node-fetch": "^3.3.2",
|
|
69
|
-
"open": "^
|
|
74
|
+
"open": "^11.0.4",
|
|
70
75
|
"papaparse": "^5.7.1",
|
|
71
76
|
"tiny-spinner": "^2.0.5",
|
|
72
77
|
"xml2js": "^0.6.2"
|
|
@@ -81,10 +86,10 @@
|
|
|
81
86
|
"@types/xml2js": "^0.4.14",
|
|
82
87
|
"@typescript-eslint/eslint-plugin": "^8.74.0",
|
|
83
88
|
"eslint": "^9.39.5",
|
|
84
|
-
"globals": "^
|
|
89
|
+
"globals": "^17.14.0",
|
|
85
90
|
"husky": "^9.1.7",
|
|
86
91
|
"jest": "^30.5.2",
|
|
87
|
-
"lint-staged": "^17.6.
|
|
92
|
+
"lint-staged": "^17.6.3",
|
|
88
93
|
"prettier": "^3.10.1",
|
|
89
94
|
"prettier-plugin-organize-imports": "^4.3.0",
|
|
90
95
|
"ts-jest": "^29.4.15",
|