@irfanshadikrishad/anilist 1.3.2-forbidden.1 → 1.4.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/{LICENSE.md → LICENSE} +373 -382
- package/README.md +79 -53
- package/bin/helpers/auth.d.ts +13 -7
- package/bin/helpers/auth.js +297 -399
- package/bin/helpers/lists.d.ts +5 -1
- package/bin/helpers/lists.js +276 -127
- package/bin/helpers/mutations.d.ts +1 -2
- package/bin/helpers/mutations.js +32 -37
- package/bin/helpers/queries.d.ts +10 -9
- package/bin/helpers/queries.js +151 -154
- package/bin/helpers/truncate.d.ts +6 -0
- package/bin/helpers/truncate.js +9 -0
- package/bin/helpers/types.d.ts +206 -36
- package/bin/helpers/validation.d.ts +29 -0
- package/bin/helpers/validation.js +117 -0
- package/bin/helpers/workers.d.ts +19 -10
- package/bin/helpers/workers.js +157 -93
- package/bin/index.js +30 -6
- package/package.json +22 -17
package/bin/helpers/auth.js
CHANGED
|
@@ -13,13 +13,16 @@ import fetch from "node-fetch";
|
|
|
13
13
|
import open from "open";
|
|
14
14
|
import os from "os";
|
|
15
15
|
import path from "path";
|
|
16
|
+
import Spinner from "tiny-spinner";
|
|
16
17
|
import { fetcher } from "./fetcher.js";
|
|
17
|
-
import { AniList, MyAnimeList } from "./lists.js";
|
|
18
|
-
import { deleteActivityMutation,
|
|
19
|
-
import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation,
|
|
20
|
-
import {
|
|
18
|
+
import { AniDB, AniList, MyAnimeList } from "./lists.js";
|
|
19
|
+
import { deleteActivityMutation, saveTextActivityMutation, } from "./mutations.js";
|
|
20
|
+
import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, toggleFollowMutation, userActivityQuery, userFollowersQuery, userFollowingQuery, } from "./queries.js";
|
|
21
|
+
import { responsiveOutput } from "./truncate.js";
|
|
22
|
+
import { aniListEndpoint, getTitle, redirectUri, timestampToTimeAgo, } from "./workers.js";
|
|
21
23
|
const home_dir = os.homedir();
|
|
22
24
|
const save_path = path.join(home_dir, ".anilist_token");
|
|
25
|
+
const spinner = new Spinner();
|
|
23
26
|
class Auth {
|
|
24
27
|
/**
|
|
25
28
|
* Get access-token from user
|
|
@@ -34,20 +37,29 @@ class Auth {
|
|
|
34
37
|
message: "Please enter your AniList access token:",
|
|
35
38
|
},
|
|
36
39
|
]);
|
|
40
|
+
if (!token) {
|
|
41
|
+
console.warn("\nNo token entered. Please try again.");
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
37
44
|
return token;
|
|
38
45
|
}
|
|
39
46
|
catch (error) {
|
|
40
|
-
console.error(`\
|
|
47
|
+
console.error(`\nAn error occurred while getting the access token: ${error.message}`);
|
|
48
|
+
return null;
|
|
41
49
|
}
|
|
42
50
|
});
|
|
43
51
|
}
|
|
44
52
|
static StoreAccessToken(token) {
|
|
45
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
54
|
try {
|
|
55
|
+
if (!token) {
|
|
56
|
+
console.warn("\nNo token provided. Nothing to store.");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
47
59
|
fs.writeFileSync(save_path, token, { encoding: "utf8" });
|
|
48
60
|
}
|
|
49
61
|
catch (error) {
|
|
50
|
-
console.error(`\nError storing
|
|
62
|
+
console.error(`\nError storing access token: ${error.message}`);
|
|
51
63
|
}
|
|
52
64
|
});
|
|
53
65
|
}
|
|
@@ -63,6 +75,7 @@ class Auth {
|
|
|
63
75
|
}
|
|
64
76
|
catch (error) {
|
|
65
77
|
console.error(`\nError retriving acess-token. ${error.message}`);
|
|
78
|
+
return null;
|
|
66
79
|
}
|
|
67
80
|
});
|
|
68
81
|
}
|
|
@@ -109,7 +122,7 @@ class Auth {
|
|
|
109
122
|
}
|
|
110
123
|
static Myself() {
|
|
111
124
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
125
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
113
126
|
try {
|
|
114
127
|
if (yield Auth.isLoggedIn()) {
|
|
115
128
|
const headers = {
|
|
@@ -130,35 +143,47 @@ class Auth {
|
|
|
130
143
|
perPage: 10,
|
|
131
144
|
});
|
|
132
145
|
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;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
146
|
+
// Get follower/following information
|
|
147
|
+
const req_followers = yield fetcher(userFollowersQuery, {
|
|
148
|
+
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
149
|
+
});
|
|
150
|
+
const req_following = yield fetcher(userFollowingQuery, {
|
|
151
|
+
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
152
|
+
});
|
|
153
|
+
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;
|
|
154
|
+
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;
|
|
155
|
+
console.log(`
|
|
156
|
+
ID: ${user === null || user === void 0 ? void 0 : user.id}
|
|
157
|
+
Name: ${user === null || user === void 0 ? void 0 : user.name}
|
|
158
|
+
siteUrl: ${user === null || user === void 0 ? void 0 : user.siteUrl}
|
|
159
|
+
profileColor: ${(_j = user === null || user === void 0 ? void 0 : user.options) === null || _j === void 0 ? void 0 : _j.profileColor}
|
|
160
|
+
timeZone: ${(_k = user === null || user === void 0 ? void 0 : user.options) === null || _k === void 0 ? void 0 : _k.timezone}
|
|
161
|
+
activityMergeTime: ${(_l = user === null || user === void 0 ? void 0 : user.options) === null || _l === void 0 ? void 0 : _l.activityMergeTime}
|
|
162
|
+
donatorTier: ${user === null || user === void 0 ? void 0 : user.donatorTier}
|
|
163
|
+
donatorBadge: ${user === null || user === void 0 ? void 0 : user.donatorBadge}
|
|
164
|
+
unreadNotificationCount:${user === null || user === void 0 ? void 0 : user.unreadNotificationCount}
|
|
165
|
+
Account Created: ${new Date((user === null || user === void 0 ? void 0 : user.createdAt) * 1000).toUTCString()}
|
|
166
|
+
Account Updated: ${new Date((user === null || user === void 0 ? void 0 : user.updatedAt) * 1000).toUTCString()}
|
|
167
|
+
|
|
168
|
+
Followers: ${followersCount}
|
|
169
|
+
Following: ${followingCount}
|
|
170
|
+
|
|
171
|
+
Statistics (Anime):
|
|
172
|
+
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}
|
|
173
|
+
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}
|
|
174
|
+
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}
|
|
175
|
+
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}
|
|
176
|
+
|
|
177
|
+
Statistics (Manga):
|
|
178
|
+
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}
|
|
179
|
+
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}
|
|
180
|
+
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}
|
|
181
|
+
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}
|
|
157
182
|
`);
|
|
158
183
|
console.log(`\nRecent Activities:`);
|
|
159
184
|
if (activities.length > 0) {
|
|
160
185
|
activities.map(({ status, progress, media, createdAt }) => {
|
|
161
|
-
|
|
186
|
+
responsiveOutput(`${timestampToTimeAgo(createdAt)}\t${status} ${progress ? `${progress} of ` : ""}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
|
|
162
187
|
});
|
|
163
188
|
}
|
|
164
189
|
return user;
|
|
@@ -181,15 +206,12 @@ Statistics (Manga):
|
|
|
181
206
|
static isLoggedIn() {
|
|
182
207
|
return __awaiter(this, void 0, void 0, function* () {
|
|
183
208
|
try {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
209
|
+
const token = yield Auth.RetriveAccessToken();
|
|
210
|
+
return token !== null;
|
|
190
211
|
}
|
|
191
212
|
catch (error) {
|
|
192
|
-
console.error(
|
|
213
|
+
console.error(`Error checking login status: ${error.message}`);
|
|
214
|
+
return false;
|
|
193
215
|
}
|
|
194
216
|
});
|
|
195
217
|
}
|
|
@@ -203,15 +225,15 @@ Statistics (Manga):
|
|
|
203
225
|
console.log(`\nLogout successful. See you soon, ${username}.`);
|
|
204
226
|
}
|
|
205
227
|
catch (error) {
|
|
206
|
-
console.error("\
|
|
228
|
+
console.error("\nFailed to remove the save file during logout:", error.message);
|
|
207
229
|
}
|
|
208
230
|
}
|
|
209
231
|
else {
|
|
210
|
-
console.
|
|
232
|
+
console.warn("\nNo active session found. You may already be logged out.");
|
|
211
233
|
}
|
|
212
234
|
}
|
|
213
235
|
catch (error) {
|
|
214
|
-
console.error(`\
|
|
236
|
+
console.error(`\nAn error occurred during logout: ${error.message}`);
|
|
215
237
|
}
|
|
216
238
|
});
|
|
217
239
|
}
|
|
@@ -222,20 +244,7 @@ Statistics (Manga):
|
|
|
222
244
|
console.warn(`\nUser not logged in.`);
|
|
223
245
|
return null;
|
|
224
246
|
}
|
|
225
|
-
const
|
|
226
|
-
const request = yield fetch(aniListEndpoint, {
|
|
227
|
-
method: "POST",
|
|
228
|
-
headers: {
|
|
229
|
-
"Content-Type": "application/json",
|
|
230
|
-
"Authorization": `Bearer ${token}`,
|
|
231
|
-
},
|
|
232
|
-
body: JSON.stringify({ query: currentUserQuery }),
|
|
233
|
-
});
|
|
234
|
-
if (!(request.status === 200)) {
|
|
235
|
-
console.error(`Failed to fetch user data. Status: ${request.status}`);
|
|
236
|
-
return null;
|
|
237
|
-
}
|
|
238
|
-
const { data } = yield request.json();
|
|
247
|
+
const { data } = yield fetcher(currentUserQuery, {});
|
|
239
248
|
return (_b = (_a = data === null || data === void 0 ? void 0 : data.Viewer) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null;
|
|
240
249
|
});
|
|
241
250
|
}
|
|
@@ -246,20 +255,7 @@ Statistics (Manga):
|
|
|
246
255
|
console.log(`\nUser not logged in.`);
|
|
247
256
|
return null;
|
|
248
257
|
}
|
|
249
|
-
const
|
|
250
|
-
const request = yield fetch(aniListEndpoint, {
|
|
251
|
-
method: "POST",
|
|
252
|
-
headers: {
|
|
253
|
-
"Content-Type": "application/json",
|
|
254
|
-
"Authorization": `Bearer ${token}`,
|
|
255
|
-
},
|
|
256
|
-
body: JSON.stringify({ query: currentUserQuery }),
|
|
257
|
-
});
|
|
258
|
-
if (!request.ok) {
|
|
259
|
-
console.error(`Failed to fetch user data. Status: ${request.status}`);
|
|
260
|
-
return null;
|
|
261
|
-
}
|
|
262
|
-
const { data } = yield request.json();
|
|
258
|
+
const { data } = yield fetcher(currentUserQuery, {});
|
|
263
259
|
return (_b = (_a = data === null || data === void 0 ? void 0 : data.Viewer) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : null;
|
|
264
260
|
});
|
|
265
261
|
}
|
|
@@ -267,72 +263,70 @@ Statistics (Manga):
|
|
|
267
263
|
return __awaiter(this, void 0, void 0, function* () {
|
|
268
264
|
var _a, _b, _c, _d, _e, _f;
|
|
269
265
|
try {
|
|
270
|
-
if (yield Auth.isLoggedIn()) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
// Ensure ID is present to avoid unintended errors
|
|
313
|
-
if (act === null || act === void 0 ? void 0 : act.id) {
|
|
314
|
-
const deleteResponse = yield fetcher(deleteActivityMutation, {
|
|
315
|
-
id: act === null || act === void 0 ? void 0 : act.id,
|
|
316
|
-
});
|
|
317
|
-
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;
|
|
318
|
-
count++;
|
|
319
|
-
totalCount++;
|
|
320
|
-
console.log(`[${count}/${activities.length}/${totalCount}]\t${act === null || act === void 0 ? void 0 : act.id} ${isDeleted ? "✅" : "❌"}`);
|
|
321
|
-
// Avoiding rate-limit
|
|
322
|
-
yield new Promise((resolve) => setTimeout(resolve, 1100));
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
266
|
+
if (!(yield Auth.isLoggedIn())) {
|
|
267
|
+
console.error(`\nPlease log in to delete your activities.`);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
const { activityType } = yield inquirer.prompt([
|
|
271
|
+
{
|
|
272
|
+
type: "list",
|
|
273
|
+
name: "activityType",
|
|
274
|
+
message: "What type of activity you want to delete?",
|
|
275
|
+
choices: [
|
|
276
|
+
{ name: "All Activity", value: 0 },
|
|
277
|
+
{ name: "Text Activity", value: 1 },
|
|
278
|
+
{ name: "Media List Activity", value: 2 },
|
|
279
|
+
{ name: "Anime List Activity", value: 3 },
|
|
280
|
+
{ name: "Manga List Activity", value: 4 },
|
|
281
|
+
{ name: "Message Activity", value: 5 },
|
|
282
|
+
],
|
|
283
|
+
},
|
|
284
|
+
]);
|
|
285
|
+
const queryMap = {
|
|
286
|
+
0: activityAllQuery,
|
|
287
|
+
1: activityTextQuery,
|
|
288
|
+
2: activityMediaList,
|
|
289
|
+
3: activityAnimeListQuery,
|
|
290
|
+
4: activityMangaListQuery,
|
|
291
|
+
5: activityMessageQuery,
|
|
292
|
+
};
|
|
293
|
+
const query = queryMap[activityType];
|
|
294
|
+
let hasMoreActivities = true;
|
|
295
|
+
let totalCount = 0;
|
|
296
|
+
while (hasMoreActivities) {
|
|
297
|
+
const response = yield fetcher(query, {
|
|
298
|
+
page: 1,
|
|
299
|
+
perPage: 50,
|
|
300
|
+
userId: yield Auth.MyUserId(),
|
|
301
|
+
});
|
|
302
|
+
if ((_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) {
|
|
303
|
+
let count = 0;
|
|
304
|
+
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;
|
|
305
|
+
if (!activities || activities.length === 0) {
|
|
306
|
+
console.log(`\nNo more activities available.`);
|
|
307
|
+
hasMoreActivities = false;
|
|
326
308
|
}
|
|
327
309
|
else {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
310
|
+
for (const act of activities) {
|
|
311
|
+
if (act === null || act === void 0 ? void 0 : act.id) {
|
|
312
|
+
const deleteResponse = yield fetcher(deleteActivityMutation, {
|
|
313
|
+
id: act === null || act === void 0 ? void 0 : act.id,
|
|
314
|
+
});
|
|
315
|
+
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;
|
|
316
|
+
count++;
|
|
317
|
+
totalCount++;
|
|
318
|
+
console.log(`[${count}/${activities.length}/${totalCount}]\t${act === null || act === void 0 ? void 0 : act.id} ${isDeleted ? "✅" : "❌"}`);
|
|
319
|
+
// Avoiding rate-limit
|
|
320
|
+
yield new Promise((resolve) => setTimeout(resolve, 1100));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
331
323
|
}
|
|
332
324
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
325
|
+
else {
|
|
326
|
+
// In case of an unexpected null response, exit the loop
|
|
327
|
+
console.log(`\nProbably deleted all the activities of this type.`);
|
|
328
|
+
hasMoreActivities = false;
|
|
329
|
+
}
|
|
336
330
|
}
|
|
337
331
|
}
|
|
338
332
|
catch (error) {
|
|
@@ -343,54 +337,51 @@ Statistics (Manga):
|
|
|
343
337
|
static DeleteMyAnimeList() {
|
|
344
338
|
return __awaiter(this, void 0, void 0, function* () {
|
|
345
339
|
var _a, _b, _c, _d;
|
|
346
|
-
if (yield Auth.isLoggedIn()) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}
|
|
340
|
+
if (!(yield Auth.isLoggedIn())) {
|
|
341
|
+
console.error(`\nPlease log in first to delete your lists.`);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (!(yield Auth.MyUserId())) {
|
|
345
|
+
console.log(`\nFailed getting current user Id.`);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const response = yield fetcher(currentUserAnimeList, { id: yield Auth.MyUserId() });
|
|
349
|
+
if (response !== null) {
|
|
350
|
+
const lists = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists;
|
|
351
|
+
if (lists.length > 0) {
|
|
352
|
+
const { selectedList } = yield inquirer.prompt([
|
|
353
|
+
{
|
|
354
|
+
type: "list",
|
|
355
|
+
name: "selectedList",
|
|
356
|
+
message: "Select an anime list:",
|
|
357
|
+
choices: lists.map((list) => list.name),
|
|
358
|
+
pageSize: 10,
|
|
359
|
+
},
|
|
360
|
+
]);
|
|
361
|
+
const selectedEntries = lists.find((list) => list.name === selectedList);
|
|
362
|
+
if (selectedEntries) {
|
|
363
|
+
console.log(`\nDeleting entries of '${selectedEntries.name}':`);
|
|
364
|
+
for (const [, entry] of selectedEntries.entries.entries()) {
|
|
365
|
+
if (entry === null || entry === void 0 ? void 0 : entry.id) {
|
|
366
|
+
yield Auth.DeleteAnimeById(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);
|
|
367
|
+
yield new Promise((resolve) => setTimeout(resolve, 1100));
|
|
375
368
|
}
|
|
376
369
|
else {
|
|
377
|
-
console.log(
|
|
370
|
+
console.log(`No id in entry.`);
|
|
371
|
+
console.log(entry);
|
|
378
372
|
}
|
|
379
373
|
}
|
|
380
|
-
else {
|
|
381
|
-
console.log(`\nNo anime(s) found in any list.`);
|
|
382
|
-
}
|
|
383
374
|
}
|
|
384
375
|
else {
|
|
385
|
-
console.log(
|
|
376
|
+
console.log("No entries found.");
|
|
386
377
|
}
|
|
387
378
|
}
|
|
388
379
|
else {
|
|
389
|
-
console.log(`\
|
|
380
|
+
console.log(`\nNo anime(s) found in any list.`);
|
|
390
381
|
}
|
|
391
382
|
}
|
|
392
383
|
else {
|
|
393
|
-
console.
|
|
384
|
+
console.log(`\nSomething went wrong. ${(_d = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _d === void 0 ? void 0 : _d.message}`);
|
|
394
385
|
}
|
|
395
386
|
});
|
|
396
387
|
}
|
|
@@ -417,54 +408,50 @@ Statistics (Manga):
|
|
|
417
408
|
return __awaiter(this, void 0, void 0, function* () {
|
|
418
409
|
var _a, _b, _c, _d;
|
|
419
410
|
try {
|
|
420
|
-
if (yield Auth.isLoggedIn()) {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
console.error("\nNo entries found.");
|
|
452
|
-
}
|
|
411
|
+
if (!(yield Auth.isLoggedIn())) {
|
|
412
|
+
console.error(`\nPlease log in first to delete your lists.`);
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
if (!(yield Auth.MyUserId())) {
|
|
416
|
+
console.error(`\nFailed getting current user Id.`);
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const response = yield fetcher(currentUserMangaList, { id: yield Auth.MyUserId() });
|
|
420
|
+
if (!(response === null || response === void 0 ? void 0 : response.data)) {
|
|
421
|
+
console.error(`\nSomething went wrong. ${(_a = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
const lists = (_c = (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.MediaListCollection) === null || _c === void 0 ? void 0 : _c.lists;
|
|
425
|
+
if (lists.length > 0) {
|
|
426
|
+
const { selectedList } = yield inquirer.prompt([
|
|
427
|
+
{
|
|
428
|
+
type: "list",
|
|
429
|
+
name: "selectedList",
|
|
430
|
+
message: "Select a manga list:",
|
|
431
|
+
choices: lists.map((list) => list.name),
|
|
432
|
+
pageSize: 10,
|
|
433
|
+
},
|
|
434
|
+
]);
|
|
435
|
+
const selectedEntries = lists.find((list) => list.name === selectedList);
|
|
436
|
+
if (selectedEntries) {
|
|
437
|
+
console.log(`\nDeleting entries of '${selectedEntries.name}':`);
|
|
438
|
+
for (const [, entry] of selectedEntries.entries.entries()) {
|
|
439
|
+
if (entry === null || entry === void 0 ? void 0 : entry.id) {
|
|
440
|
+
yield Auth.DeleteMangaById(entry === null || entry === void 0 ? void 0 : entry.id, (_d = entry === null || entry === void 0 ? void 0 : entry.media) === null || _d === void 0 ? void 0 : _d.title);
|
|
441
|
+
yield new Promise((resolve) => setTimeout(resolve, 1100));
|
|
453
442
|
}
|
|
454
443
|
else {
|
|
455
|
-
console.
|
|
444
|
+
console.log(`No id in entry.`);
|
|
445
|
+
console.log(entry);
|
|
456
446
|
}
|
|
457
447
|
}
|
|
458
|
-
else {
|
|
459
|
-
console.error(`\nSomething went wrong. ${(_d = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _d === void 0 ? void 0 : _d.message}`);
|
|
460
|
-
}
|
|
461
448
|
}
|
|
462
449
|
else {
|
|
463
|
-
console.error(
|
|
450
|
+
console.error("\nNo entries found.");
|
|
464
451
|
}
|
|
465
452
|
}
|
|
466
453
|
else {
|
|
467
|
-
console.error(`\
|
|
454
|
+
console.error(`\nNo manga(s) found in any list.`);
|
|
468
455
|
}
|
|
469
456
|
}
|
|
470
457
|
catch (error) {
|
|
@@ -493,23 +480,20 @@ Statistics (Manga):
|
|
|
493
480
|
}
|
|
494
481
|
static Write(status) {
|
|
495
482
|
return __awaiter(this, void 0, void 0, function* () {
|
|
496
|
-
var _a;
|
|
497
483
|
try {
|
|
498
484
|
if (!(yield Auth.isLoggedIn())) {
|
|
499
485
|
console.error(`\nPlease login to use this feature.`);
|
|
500
486
|
return;
|
|
501
487
|
}
|
|
502
|
-
const data = yield fetcher(saveTextActivityMutation, {
|
|
503
|
-
status: status
|
|
504
|
-
`<br><br><br><br>*Written using [@irfanshadikrishad/anilist](https://www.npmjs.com/package/@irfanshadikrishad/anilist).*`,
|
|
488
|
+
const { data } = yield fetcher(saveTextActivityMutation, {
|
|
489
|
+
status: status,
|
|
505
490
|
});
|
|
506
491
|
if (!data) {
|
|
507
492
|
console.error(`\nSomething went wrong. ${data}.`);
|
|
508
493
|
return;
|
|
509
494
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
console.log(`\n[${savedActivity.id}] status saved successfully!`);
|
|
495
|
+
if (data.SaveTextActivity.id) {
|
|
496
|
+
console.log(`\n[${data.SaveTextActivity.id}] status saved successfully!`);
|
|
513
497
|
}
|
|
514
498
|
}
|
|
515
499
|
catch (error) {
|
|
@@ -528,6 +512,7 @@ Statistics (Manga):
|
|
|
528
512
|
choices: [
|
|
529
513
|
{ name: "Exported JSON file.", value: 1 },
|
|
530
514
|
{ name: "MyAnimeList (XML)", value: 2 },
|
|
515
|
+
{ name: "AniDB (json-large)", value: 3 },
|
|
531
516
|
],
|
|
532
517
|
pageSize: 10,
|
|
533
518
|
},
|
|
@@ -539,6 +524,9 @@ Statistics (Manga):
|
|
|
539
524
|
case 2:
|
|
540
525
|
yield MyAnimeList.importAnime();
|
|
541
526
|
break;
|
|
527
|
+
case 3:
|
|
528
|
+
yield AniDB.importAnime();
|
|
529
|
+
break;
|
|
542
530
|
default:
|
|
543
531
|
console.log(`\nInvalid Choice.`);
|
|
544
532
|
break;
|
|
@@ -581,215 +569,125 @@ Statistics (Manga):
|
|
|
581
569
|
}
|
|
582
570
|
});
|
|
583
571
|
}
|
|
584
|
-
|
|
572
|
+
}
|
|
573
|
+
class Social {
|
|
574
|
+
/**
|
|
575
|
+
* Follow the users that follows you
|
|
576
|
+
*/
|
|
577
|
+
static follow() {
|
|
585
578
|
return __awaiter(this, void 0, void 0, function* () {
|
|
586
|
-
var _a, _b, _c, _d;
|
|
579
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
587
580
|
try {
|
|
588
|
-
let
|
|
589
|
-
let
|
|
590
|
-
let
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
581
|
+
let pager = 1;
|
|
582
|
+
let hasNextPage = true;
|
|
583
|
+
let allFollowerUsers = [];
|
|
584
|
+
let followedBack = 0;
|
|
585
|
+
spinner.start("Fetching all the followers...");
|
|
586
|
+
while (hasNextPage) {
|
|
587
|
+
const followerUsers = yield fetcher(userFollowersQuery, {
|
|
588
|
+
userId: yield Auth.MyUserId(),
|
|
589
|
+
page: pager,
|
|
596
590
|
});
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
for (let activ of activiti) {
|
|
601
|
-
if (!activ.isLiked && activ.id) {
|
|
602
|
-
try {
|
|
603
|
-
const like = yield fetcher(likeActivityMutation, {
|
|
604
|
-
activityId: activ.id,
|
|
605
|
-
});
|
|
606
|
-
console.info(`${activityBy(activ)} ${(like === null || like === void 0 ? void 0 : like.data) ? "✅" : "❌"}`);
|
|
607
|
-
}
|
|
608
|
-
catch (error) {
|
|
609
|
-
console.error(`Activity possibly deleted. ${error.message}`);
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
else {
|
|
613
|
-
console.log(`${activityBy(activ)} 🔵`);
|
|
614
|
-
}
|
|
615
|
-
// avoiding rate-limit
|
|
616
|
-
yield new Promise((resolve) => {
|
|
617
|
-
setTimeout(resolve, 2000);
|
|
618
|
-
});
|
|
619
|
-
}
|
|
620
|
-
page++;
|
|
621
|
-
}
|
|
622
|
-
else {
|
|
623
|
-
if (retryCount < maxRetries) {
|
|
624
|
-
retryCount++;
|
|
625
|
-
console.warn(`Empty activities returned. Retrying... (${retryCount}/${maxRetries})`);
|
|
626
|
-
yield new Promise((resolve) => setTimeout(resolve, 3000));
|
|
627
|
-
}
|
|
628
|
-
else {
|
|
629
|
-
console.log(`\nProbably the end of activities after ${maxRetries} retries.`);
|
|
630
|
-
console.info(activities);
|
|
631
|
-
hasMoreActivities = false;
|
|
632
|
-
}
|
|
591
|
+
spinner.update(`Fetched page ${pager} of ${(_c = (_b = (_a = followerUsers === null || followerUsers === void 0 ? void 0 : followerUsers.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.pageInfo) === null || _c === void 0 ? void 0 : _c.lastPage}...`);
|
|
592
|
+
if (!((_f = (_e = (_d = followerUsers === null || followerUsers === void 0 ? void 0 : followerUsers.data) === null || _d === void 0 ? void 0 : _d.Page) === null || _e === void 0 ? void 0 : _e.pageInfo) === null || _f === void 0 ? void 0 : _f.hasNextPage)) {
|
|
593
|
+
hasNextPage = false;
|
|
633
594
|
}
|
|
595
|
+
allFollowerUsers.push(...(((_h = (_g = followerUsers === null || followerUsers === void 0 ? void 0 : followerUsers.data) === null || _g === void 0 ? void 0 : _g.Page) === null || _h === void 0 ? void 0 : _h.followers) || []));
|
|
596
|
+
pager++;
|
|
634
597
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
if (activities && ((_b = (_a = activities === null || activities === void 0 ? void 0 : activities.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.activities.length) > 0) {
|
|
658
|
-
const activiti = (_d = (_c = activities === null || activities === void 0 ? void 0 : activities.data) === null || _c === void 0 ? void 0 : _c.Page) === null || _d === void 0 ? void 0 : _d.activities;
|
|
659
|
-
for (let activ of activiti) {
|
|
660
|
-
if (!activ.isLiked && activ.id) {
|
|
661
|
-
try {
|
|
662
|
-
const like = yield fetcher(likeActivityMutation, {
|
|
663
|
-
activityId: activ.id,
|
|
664
|
-
});
|
|
665
|
-
// const ToggleLike = like?.data?.ToggleLike
|
|
666
|
-
console.info(`${activityBy(activ)} ${(like === null || like === void 0 ? void 0 : like.data) ? "✅" : "❌"}`);
|
|
667
|
-
}
|
|
668
|
-
catch (error) {
|
|
669
|
-
console.error(`Activity possibly deleted. ${error.message}`);
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
else {
|
|
673
|
-
console.log(`${activityBy(activ)} 🔵`);
|
|
674
|
-
}
|
|
675
|
-
// avoiding rate-limit
|
|
676
|
-
yield new Promise((resolve) => {
|
|
677
|
-
setTimeout(resolve, 1500);
|
|
678
|
-
});
|
|
598
|
+
spinner.stop("Fetched all the followers. Starting follow back.");
|
|
599
|
+
// Filter users that do no follow me
|
|
600
|
+
const notFollowing = allFollowerUsers
|
|
601
|
+
.filter(({ isFollowing }) => !isFollowing)
|
|
602
|
+
.map(({ id, name }) => ({ id: id, name: name }));
|
|
603
|
+
console.log(`\nTotal follower ${allFollowerUsers.length}.\nNot followed back ${notFollowing.length}\n`);
|
|
604
|
+
if (notFollowing.length <= 0) {
|
|
605
|
+
console.log(`Probably followed back all the users.`);
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
// Traverse and follow back
|
|
609
|
+
const maxIdLength = Math.max(...notFollowing.map(({ id }) => String(id).length));
|
|
610
|
+
const maxNameLength = Math.max(...notFollowing.map(({ name }) => name.length));
|
|
611
|
+
for (let nf of notFollowing) {
|
|
612
|
+
try {
|
|
613
|
+
const follow = yield fetcher(toggleFollowMutation, { userId: nf.id });
|
|
614
|
+
console.log(`${String(`[${nf.id}]`).padEnd(maxIdLength)}` +
|
|
615
|
+
`\t${String(`[${(_k = (_j = follow === null || follow === void 0 ? void 0 : follow.data) === null || _j === void 0 ? void 0 : _j.ToggleFollow) === null || _k === void 0 ? void 0 : _k.name}]`).padEnd(maxNameLength)}` +
|
|
616
|
+
`\t${((_m = (_l = follow === null || follow === void 0 ? void 0 : follow.data) === null || _l === void 0 ? void 0 : _l.ToggleFollow) === null || _m === void 0 ? void 0 : _m.id) ? "✅" : "🈵"}`);
|
|
617
|
+
// Count the followed back users
|
|
618
|
+
if ((_p = (_o = follow === null || follow === void 0 ? void 0 : follow.data) === null || _o === void 0 ? void 0 : _o.ToggleFollow) === null || _p === void 0 ? void 0 : _p.id) {
|
|
619
|
+
followedBack++;
|
|
679
620
|
}
|
|
680
|
-
page++;
|
|
681
621
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
console.log(`\nProbably the end of activities.`);
|
|
685
|
-
console.info(activities);
|
|
686
|
-
hasMoreActivities = false;
|
|
622
|
+
catch (error) {
|
|
623
|
+
console.log(`automate_follow_toggle_follow: ${error.message}`);
|
|
687
624
|
}
|
|
688
625
|
}
|
|
626
|
+
console.log(`\n✅ Followed back ${followedBack} users.`);
|
|
689
627
|
}
|
|
690
628
|
catch (error) {
|
|
691
|
-
console.
|
|
629
|
+
console.log(`\nautomate_follow ${error.message}`);
|
|
692
630
|
}
|
|
693
631
|
});
|
|
694
632
|
}
|
|
695
|
-
|
|
633
|
+
/**
|
|
634
|
+
* Unfollow the users thats not following you
|
|
635
|
+
*/
|
|
636
|
+
static unfollow() {
|
|
696
637
|
return __awaiter(this, void 0, void 0, function* () {
|
|
697
|
-
var _a, _b, _c, _d;
|
|
638
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
698
639
|
try {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
while (true) {
|
|
713
|
-
const activities = yield fetcher(specificUserActivitiesQuery, {
|
|
714
|
-
page,
|
|
715
|
-
perPage,
|
|
716
|
-
userId,
|
|
717
|
-
});
|
|
718
|
-
const activiti = (_d = (_c = activities === null || activities === void 0 ? void 0 : activities.data) === null || _c === void 0 ? void 0 : _c.Page) === null || _d === void 0 ? void 0 : _d.activities;
|
|
719
|
-
// Break the loop if no more activities are found
|
|
720
|
-
if (!activiti || activiti.length === 0) {
|
|
721
|
-
console.log("No more activities found.");
|
|
722
|
-
break;
|
|
723
|
-
}
|
|
724
|
-
for (let activ of activiti) {
|
|
725
|
-
if (!activ.isLiked && activ.id) {
|
|
726
|
-
try {
|
|
727
|
-
const like = yield fetcher(likeActivityMutation, {
|
|
728
|
-
activityId: activ.id,
|
|
729
|
-
});
|
|
730
|
-
console.info(`${activityBy(activ)} ${(like === null || like === void 0 ? void 0 : like.data) ? "✅" : "❌"}`);
|
|
731
|
-
}
|
|
732
|
-
catch (error) {
|
|
733
|
-
console.error(`Activity possibly deleted. ${error.message}`);
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
else {
|
|
737
|
-
console.log(`${activityBy(activ)} 🔵`);
|
|
738
|
-
}
|
|
739
|
-
// Avoiding rate limit
|
|
740
|
-
yield new Promise((resolve) => {
|
|
741
|
-
setTimeout(resolve, 1500);
|
|
742
|
-
});
|
|
743
|
-
}
|
|
744
|
-
// Go to the next page
|
|
745
|
-
page += 1;
|
|
746
|
-
}
|
|
640
|
+
let pager = 1;
|
|
641
|
+
let hasNextPage = true;
|
|
642
|
+
let allFollowingUsers = [];
|
|
643
|
+
let unfollowedUsers = 0;
|
|
644
|
+
spinner.start("Fetching all following users...");
|
|
645
|
+
while (hasNextPage) {
|
|
646
|
+
const followingUsers = yield fetcher(userFollowingQuery, {
|
|
647
|
+
userId: yield Auth.MyUserId(),
|
|
648
|
+
page: pager,
|
|
649
|
+
});
|
|
650
|
+
spinner.update(`Fetched page ${pager} of ${(_c = (_b = (_a = followingUsers === null || followingUsers === void 0 ? void 0 : followingUsers.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.pageInfo) === null || _c === void 0 ? void 0 : _c.lastPage}...`);
|
|
651
|
+
if (!((_f = (_e = (_d = followingUsers === null || followingUsers === void 0 ? void 0 : followingUsers.data) === null || _d === void 0 ? void 0 : _d.Page) === null || _e === void 0 ? void 0 : _e.pageInfo) === null || _f === void 0 ? void 0 : _f.hasNextPage)) {
|
|
652
|
+
hasNextPage = false;
|
|
747
653
|
}
|
|
654
|
+
allFollowingUsers.push(...(((_h = (_g = followingUsers === null || followingUsers === void 0 ? void 0 : followingUsers.data) === null || _g === void 0 ? void 0 : _g.Page) === null || _h === void 0 ? void 0 : _h.following) || []));
|
|
655
|
+
pager++;
|
|
748
656
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
757
|
-
try {
|
|
758
|
-
if (!(yield Auth.isLoggedIn())) {
|
|
759
|
-
console.error(`\nPlease login to use this feature.`);
|
|
657
|
+
spinner.update(`Fetching complete. Total got ${allFollowingUsers.length} users.`);
|
|
658
|
+
// Filter users that do no follow me
|
|
659
|
+
const notFollowingMe = allFollowingUsers
|
|
660
|
+
.filter((user) => !user.isFollower)
|
|
661
|
+
.map((u3r) => ({ id: u3r.id, name: u3r.name }));
|
|
662
|
+
if (notFollowingMe.length <= 0) {
|
|
663
|
+
spinner.stop(`No users to unfollow. Exiting operation...`);
|
|
760
664
|
return;
|
|
761
665
|
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
]
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
yield this.Like(1);
|
|
781
|
-
break;
|
|
782
|
-
case 3:
|
|
783
|
-
yield this.LikeSpecificUser();
|
|
784
|
-
break;
|
|
785
|
-
default:
|
|
786
|
-
console.error(`\nInvalid choice. (${activityType})`);
|
|
666
|
+
spinner.stop(`Unfollow process activated with ${notFollowingMe.length} users.`);
|
|
667
|
+
let nfmCount = 0;
|
|
668
|
+
console.log(`\n`);
|
|
669
|
+
for (let nfm of notFollowingMe) {
|
|
670
|
+
nfmCount++;
|
|
671
|
+
try {
|
|
672
|
+
const unfollow = yield fetcher(toggleFollowMutation, {
|
|
673
|
+
userId: nfm.id,
|
|
674
|
+
});
|
|
675
|
+
console.log(`[${nfm.id}]\t[${(_k = (_j = unfollow === null || unfollow === void 0 ? void 0 : unfollow.data) === null || _j === void 0 ? void 0 : _j.ToggleFollow) === null || _k === void 0 ? void 0 : _k.name}]\t${((_m = (_l = unfollow === null || unfollow === void 0 ? void 0 : unfollow.data) === null || _l === void 0 ? void 0 : _l.ToggleFollow) === null || _m === void 0 ? void 0 : _m.id) ? "✅" : "🈵"}`);
|
|
676
|
+
// Count the unfollowed users
|
|
677
|
+
if ((_p = (_o = unfollow === null || unfollow === void 0 ? void 0 : unfollow.data) === null || _o === void 0 ? void 0 : _o.ToggleFollow) === null || _p === void 0 ? void 0 : _p.id) {
|
|
678
|
+
unfollowedUsers++;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
catch (error) {
|
|
682
|
+
console.log(`unfollow_toggle_follow. ${error.message}`);
|
|
683
|
+
}
|
|
787
684
|
}
|
|
685
|
+
console.log(`\nTotal Unfollowed: ${unfollowedUsers} of ${nfmCount} users.`);
|
|
788
686
|
}
|
|
789
687
|
catch (error) {
|
|
790
|
-
console.error(`\
|
|
688
|
+
console.error(`\nautomate_unfollow: ${error.message}`);
|
|
791
689
|
}
|
|
792
690
|
});
|
|
793
691
|
}
|
|
794
692
|
}
|
|
795
|
-
export { Auth };
|
|
693
|
+
export { Auth, Social };
|