@irfanshadikrishad/anilist 1.0.8 → 1.1.0-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 +232 -232
- package/bin/helpers/auth.d.ts +26 -10
- package/bin/helpers/auth.js +747 -192
- package/bin/helpers/fetcher.d.ts +1 -1
- package/bin/helpers/fetcher.js +25 -24
- package/bin/helpers/lists.d.ts +22 -8
- package/bin/helpers/lists.js +915 -536
- package/bin/helpers/mutations.d.ts +2 -1
- package/bin/helpers/mutations.js +37 -32
- package/bin/helpers/queries.d.ts +6 -3
- package/bin/helpers/queries.js +157 -128
- package/bin/helpers/types.d.ts +3 -3
- package/bin/helpers/workers.d.ts +9 -11
- package/bin/helpers/workers.js +72 -371
- package/bin/index.js +31 -25
- package/package.json +73 -72
- package/bin/helpers/more.d.ts +0 -11
- package/bin/helpers/more.js +0 -500
package/bin/helpers/auth.js
CHANGED
|
@@ -14,214 +14,769 @@ import open from "open";
|
|
|
14
14
|
import os from "os";
|
|
15
15
|
import path from "path";
|
|
16
16
|
import { fetcher } from "./fetcher.js";
|
|
17
|
-
import {
|
|
17
|
+
import { AniList, MyAnimeList } from "./lists.js";
|
|
18
|
+
import { deleteActivityMutation, likeActivityMutation, saveTextActivityMutation, } from "./mutations.js";
|
|
19
|
+
import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, followingActivitiesQuery, globalActivitiesQuery, specificUserActivitiesQuery, userActivityQuery, userQuery, } from "./queries.js";
|
|
18
20
|
import { aniListEndpoint, getTitle, redirectUri } from "./workers.js";
|
|
19
21
|
const home_dir = os.homedir();
|
|
20
22
|
const save_path = path.join(home_dir, ".anilist_token");
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
fs.writeFileSync(save_path, token, { encoding: "utf8" });
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
console.error(`\nError storing acess-token. ${error.message}`);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
function retriveAccessToken() {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
if (fs.existsSync(save_path)) {
|
|
46
|
-
return fs.readFileSync(save_path, { encoding: "utf8" });
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
function anilistUserLogin(clientId, clientSecret) {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
console.log("Starting AniList login...");
|
|
56
|
-
const authUrl = `https://anilist.co/api/v2/oauth/authorize?client_id=${clientId}&redirect_uri=${redirectUri}&response_type=code`;
|
|
57
|
-
console.log("Opening browser for AniList login...");
|
|
58
|
-
open(authUrl);
|
|
59
|
-
const authCode = yield getAccessTokenFromUser();
|
|
60
|
-
const tokenResponse = yield fetch("https://anilist.co/api/v2/oauth/token", {
|
|
61
|
-
method: "POST",
|
|
62
|
-
headers: {
|
|
63
|
-
"Content-Type": "application/json",
|
|
64
|
-
},
|
|
65
|
-
body: JSON.stringify({
|
|
66
|
-
grant_type: "authorization_code",
|
|
67
|
-
client_id: String(clientId),
|
|
68
|
-
client_secret: clientSecret,
|
|
69
|
-
redirect_uri: redirectUri,
|
|
70
|
-
code: authCode,
|
|
71
|
-
}),
|
|
72
|
-
});
|
|
73
|
-
const token_Data = yield tokenResponse.json();
|
|
74
|
-
if (token_Data === null || token_Data === void 0 ? void 0 : token_Data.access_token) {
|
|
75
|
-
yield storeAccessToken(token_Data === null || token_Data === void 0 ? void 0 : token_Data.access_token);
|
|
76
|
-
const name = yield currentUsersName();
|
|
77
|
-
if (name) {
|
|
78
|
-
console.log(`\nWelcome Back, ${name}!`);
|
|
23
|
+
class Auth {
|
|
24
|
+
/**
|
|
25
|
+
* Get access-token from user
|
|
26
|
+
*/
|
|
27
|
+
static GetAccessToken() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
try {
|
|
30
|
+
const { token } = yield inquirer.prompt([
|
|
31
|
+
{
|
|
32
|
+
type: "password",
|
|
33
|
+
name: "token",
|
|
34
|
+
message: "Please enter your AniList access token:",
|
|
35
|
+
},
|
|
36
|
+
]);
|
|
37
|
+
return token;
|
|
79
38
|
}
|
|
80
|
-
|
|
81
|
-
console.
|
|
39
|
+
catch (error) {
|
|
40
|
+
console.error(`\nSomething went wrong. ${error.message}`);
|
|
82
41
|
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
static StoreAccessToken(token) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
try {
|
|
47
|
+
fs.writeFileSync(save_path, token, { encoding: "utf8" });
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error(`\nError storing acess-token. ${error.message}`);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
static RetriveAccessToken() {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
try {
|
|
57
|
+
if (fs.existsSync(save_path)) {
|
|
58
|
+
return fs.readFileSync(save_path, { encoding: "utf8" });
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.error(`\nError retriving acess-token. ${error.message}`);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
static Login(clientId, clientSecret) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
try {
|
|
72
|
+
console.log("Starting AniList login...");
|
|
73
|
+
const authUrl = `https://anilist.co/api/v2/oauth/authorize?client_id=${clientId}&redirect_uri=${redirectUri}&response_type=code`;
|
|
74
|
+
console.log("Opening browser for AniList login...");
|
|
75
|
+
open(authUrl);
|
|
76
|
+
const authCode = yield Auth.GetAccessToken();
|
|
77
|
+
const tokenResponse = yield fetch("https://anilist.co/api/v2/oauth/token", {
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: {
|
|
80
|
+
"Content-Type": "application/json",
|
|
81
|
+
},
|
|
82
|
+
body: JSON.stringify({
|
|
83
|
+
grant_type: "authorization_code",
|
|
84
|
+
client_id: String(clientId),
|
|
85
|
+
client_secret: clientSecret,
|
|
86
|
+
redirect_uri: redirectUri,
|
|
87
|
+
code: authCode,
|
|
88
|
+
}),
|
|
89
|
+
});
|
|
90
|
+
const token_Data = yield tokenResponse.json();
|
|
91
|
+
if (token_Data === null || token_Data === void 0 ? void 0 : token_Data.access_token) {
|
|
92
|
+
yield Auth.StoreAccessToken(token_Data === null || token_Data === void 0 ? void 0 : token_Data.access_token);
|
|
93
|
+
const name = yield Auth.MyUserName();
|
|
94
|
+
if (name) {
|
|
95
|
+
console.log(`\nWelcome Back, ${name}!`);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
console.log(`\nLogged in successfull!`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
console.error("\nFailed to get access token:", token_Data);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
console.error(`\nFailed logging in. ${error.message}`);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
static Myself() {
|
|
111
|
+
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;
|
|
113
|
+
try {
|
|
114
|
+
if (yield Auth.isLoggedIn()) {
|
|
115
|
+
const headers = {
|
|
116
|
+
"Content-Type": "application/json",
|
|
117
|
+
"Authorization": `Bearer ${yield Auth.RetriveAccessToken()}`,
|
|
118
|
+
};
|
|
119
|
+
const request = yield fetch(aniListEndpoint, {
|
|
120
|
+
method: "POST",
|
|
121
|
+
headers: headers,
|
|
122
|
+
body: JSON.stringify({ query: currentUserQuery }),
|
|
123
|
+
});
|
|
124
|
+
const { data, errors } = yield request.json();
|
|
125
|
+
if (request.status === 200) {
|
|
126
|
+
const user = data === null || data === void 0 ? void 0 : data.Viewer;
|
|
127
|
+
const activiResponse = yield fetcher(userActivityQuery, {
|
|
128
|
+
id: user === null || user === void 0 ? void 0 : user.id,
|
|
129
|
+
page: 1,
|
|
130
|
+
perPage: 10,
|
|
131
|
+
});
|
|
132
|
+
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
|
+
console.log(`
|
|
134
|
+
ID: ${user === null || user === void 0 ? void 0 : user.id}
|
|
135
|
+
Name: ${user === null || user === void 0 ? void 0 : user.name}
|
|
136
|
+
siteUrl: ${user === null || user === void 0 ? void 0 : user.siteUrl}
|
|
137
|
+
profileColor: ${(_c = user === null || user === void 0 ? void 0 : user.options) === null || _c === void 0 ? void 0 : _c.profileColor}
|
|
138
|
+
timeZone: ${(_d = user === null || user === void 0 ? void 0 : user.options) === null || _d === void 0 ? void 0 : _d.timezone}
|
|
139
|
+
activityMergeTime: ${(_e = user === null || user === void 0 ? void 0 : user.options) === null || _e === void 0 ? void 0 : _e.activityMergeTime}
|
|
140
|
+
donatorTier: ${user === null || user === void 0 ? void 0 : user.donatorTier}
|
|
141
|
+
donatorBadge: ${user === null || user === void 0 ? void 0 : user.donatorBadge}
|
|
142
|
+
unreadNotificationCount:${user === null || user === void 0 ? void 0 : user.unreadNotificationCount}
|
|
143
|
+
Account Created: ${new Date((user === null || user === void 0 ? void 0 : user.createdAt) * 1000).toUTCString()}
|
|
144
|
+
Account Updated: ${new Date((user === null || user === void 0 ? void 0 : user.updatedAt) * 1000).toUTCString()}
|
|
145
|
+
|
|
146
|
+
Statistics (Anime):
|
|
147
|
+
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}
|
|
148
|
+
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}
|
|
149
|
+
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}
|
|
150
|
+
|
|
151
|
+
Statistics (Manga):
|
|
152
|
+
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}
|
|
153
|
+
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}
|
|
154
|
+
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}
|
|
155
|
+
`);
|
|
156
|
+
console.log(`\nRecent Activities:`);
|
|
157
|
+
if (activities.length > 0) {
|
|
158
|
+
activities.map(({ status, progress, media }) => {
|
|
159
|
+
console.log(`${status} ${progress ? `${progress} of ` : ""}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
return user;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
console.error(`\nSomething went wrong. Please log in again. ${errors[0].message}`);
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
console.error(`\nPlease login first to use this feature.`);
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
console.error(`\nError from Myself. ${error.message}`);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
static isLoggedIn() {
|
|
180
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
+
try {
|
|
182
|
+
if ((yield Auth.RetriveAccessToken()) !== null) {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
console.error(`\nError getting isLoggedIn. ${error.message}`);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
static Logout() {
|
|
195
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
196
|
+
try {
|
|
197
|
+
const username = yield Auth.MyUserName();
|
|
198
|
+
if (fs.existsSync(save_path)) {
|
|
199
|
+
try {
|
|
200
|
+
fs.unlinkSync(save_path);
|
|
201
|
+
console.log(`\nLogout successful. See you soon, ${username}.`);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
console.error("\nError logging out:", error);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
console.error("\nYou may already be logged out.");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
console.error(`\nError logging out. ${error.message}`);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
static MyUserId() {
|
|
217
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
218
|
+
var _a, _b;
|
|
219
|
+
if (!(yield Auth.isLoggedIn())) {
|
|
220
|
+
console.log(`\nUser not logged in.`);
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
const token = yield Auth.RetriveAccessToken();
|
|
97
224
|
const request = yield fetch(aniListEndpoint, {
|
|
98
225
|
method: "POST",
|
|
99
|
-
headers:
|
|
226
|
+
headers: {
|
|
227
|
+
"Content-Type": "application/json",
|
|
228
|
+
"Authorization": `Bearer ${token}`,
|
|
229
|
+
},
|
|
100
230
|
body: JSON.stringify({ query: currentUserQuery }),
|
|
101
231
|
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
232
|
+
if (!(request.status === 200)) {
|
|
233
|
+
console.error(`Failed to fetch user data. Status: ${request.status}`);
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
const { data } = yield request.json();
|
|
237
|
+
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;
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
static MyUserName() {
|
|
241
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
242
|
+
var _a, _b;
|
|
243
|
+
if (!(yield Auth.isLoggedIn())) {
|
|
244
|
+
console.log(`\nUser not logged in.`);
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
const token = yield Auth.RetriveAccessToken();
|
|
248
|
+
const request = yield fetch(aniListEndpoint, {
|
|
249
|
+
method: "POST",
|
|
250
|
+
headers: {
|
|
251
|
+
"Content-Type": "application/json",
|
|
252
|
+
"Authorization": `Bearer ${token}`,
|
|
253
|
+
},
|
|
254
|
+
body: JSON.stringify({ query: currentUserQuery }),
|
|
255
|
+
});
|
|
256
|
+
if (!request.ok) {
|
|
257
|
+
console.error(`Failed to fetch user data. Status: ${request.status}`);
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
const { data } = yield request.json();
|
|
261
|
+
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;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
static DeleteMyActivities() {
|
|
265
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
266
|
+
var _a, _b, _c, _d, _e, _f;
|
|
267
|
+
try {
|
|
268
|
+
if (yield Auth.isLoggedIn()) {
|
|
269
|
+
const { activityType } = yield inquirer.prompt([
|
|
270
|
+
{
|
|
271
|
+
type: "list",
|
|
272
|
+
name: "activityType",
|
|
273
|
+
message: "What type of activity you want to delete?",
|
|
274
|
+
choices: [
|
|
275
|
+
{ name: "All Activity", value: 0 },
|
|
276
|
+
{ name: "Text Activity", value: 1 },
|
|
277
|
+
{ name: "Media List Activity", value: 2 },
|
|
278
|
+
{ name: "Anime List Activity", value: 3 },
|
|
279
|
+
{ name: "Manga List Activity", value: 4 },
|
|
280
|
+
{ name: "Message Activity", value: 5 },
|
|
281
|
+
],
|
|
282
|
+
},
|
|
283
|
+
]);
|
|
284
|
+
const userId = yield Auth.MyUserId();
|
|
285
|
+
const variables = { page: 1, perPage: 100, userId };
|
|
286
|
+
const queryMap = {
|
|
287
|
+
0: activityAllQuery,
|
|
288
|
+
1: activityTextQuery,
|
|
289
|
+
2: activityMediaList,
|
|
290
|
+
3: activityAnimeListQuery,
|
|
291
|
+
4: activityMangaListQuery,
|
|
292
|
+
5: activityMessageQuery,
|
|
293
|
+
};
|
|
294
|
+
const query = queryMap[activityType];
|
|
295
|
+
let hasMoreActivities = true;
|
|
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;
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
for (const act of activities) {
|
|
311
|
+
// Ensure ID is present to avoid unintended errors
|
|
312
|
+
if (act === null || act === void 0 ? void 0 : act.id) {
|
|
313
|
+
const deleteResponse = yield fetcher(deleteActivityMutation, {
|
|
314
|
+
id: act === null || act === void 0 ? void 0 : act.id,
|
|
315
|
+
});
|
|
316
|
+
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;
|
|
317
|
+
count++;
|
|
318
|
+
console.log(`[${count}/${activities.length}] ${act === null || act === void 0 ? void 0 : act.id} ${isDeleted ? "✅" : "❌"}`);
|
|
319
|
+
// Avoiding rate-limit
|
|
320
|
+
yield new Promise((resolve) => setTimeout(resolve, 1100));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
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
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
console.error(`\nPlease log in to delete your activities.`);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
console.error(`\nSomething went wrong. ${error.message}`);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
static DeleteMyAnimeList() {
|
|
342
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
343
|
+
var _a, _b, _c, _d;
|
|
344
|
+
if (yield Auth.isLoggedIn()) {
|
|
345
|
+
const userID = yield Auth.MyUserId();
|
|
346
|
+
if (userID) {
|
|
347
|
+
const request = yield fetch(aniListEndpoint, {
|
|
348
|
+
method: "POST",
|
|
349
|
+
headers: {
|
|
350
|
+
"content-type": "application/json",
|
|
351
|
+
"Authorization": `Bearer ${yield Auth.RetriveAccessToken()}`,
|
|
352
|
+
},
|
|
353
|
+
body: JSON.stringify({
|
|
354
|
+
query: currentUserAnimeList,
|
|
355
|
+
variables: { id: userID },
|
|
356
|
+
}),
|
|
138
357
|
});
|
|
358
|
+
const response = yield request.json();
|
|
359
|
+
if (request.status === 200) {
|
|
360
|
+
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;
|
|
361
|
+
if (lists.length > 0) {
|
|
362
|
+
const { selectedList } = yield inquirer.prompt([
|
|
363
|
+
{
|
|
364
|
+
type: "list",
|
|
365
|
+
name: "selectedList",
|
|
366
|
+
message: "Select an anime list:",
|
|
367
|
+
choices: lists.map((list) => list.name),
|
|
368
|
+
pageSize: 10,
|
|
369
|
+
},
|
|
370
|
+
]);
|
|
371
|
+
const selectedEntries = lists.find((list) => list.name === selectedList);
|
|
372
|
+
if (selectedEntries) {
|
|
373
|
+
console.log(`\nDeleting entries of '${selectedEntries.name}':`);
|
|
374
|
+
for (const [_, entry] of selectedEntries.entries.entries()) {
|
|
375
|
+
if (entry === null || entry === void 0 ? void 0 : entry.id) {
|
|
376
|
+
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);
|
|
377
|
+
yield new Promise((resolve) => setTimeout(resolve, 1100));
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
console.log(`No id in entry.`);
|
|
381
|
+
console.log(entry);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
console.log("No entries found.");
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
console.log(`\nNo anime(s) found in any list.`);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
console.log(`\nSomething went wrong. ${(_d = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _d === void 0 ? void 0 : _d.message}`);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
console.log(`\nFailed getting current user Id.`);
|
|
139
399
|
}
|
|
140
|
-
return user;
|
|
141
400
|
}
|
|
142
401
|
else {
|
|
143
|
-
console.error(`\
|
|
144
|
-
return null;
|
|
402
|
+
console.error(`\nPlease log in first to delete your lists.`);
|
|
145
403
|
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
function isLoggedIn() {
|
|
154
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
-
if ((yield retriveAccessToken()) !== null) {
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
function logoutUser() {
|
|
164
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
-
if (fs.existsSync(save_path)) {
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
static DeleteAnimeById(id, title) {
|
|
407
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
408
|
+
var _a, _b, _c;
|
|
166
409
|
try {
|
|
167
|
-
|
|
168
|
-
|
|
410
|
+
const request = yield fetch(aniListEndpoint, {
|
|
411
|
+
method: "POST",
|
|
412
|
+
headers: {
|
|
413
|
+
"content-type": "application/json",
|
|
414
|
+
"Authorization": `Bearer ${yield Auth.RetriveAccessToken()}`,
|
|
415
|
+
},
|
|
416
|
+
body: JSON.stringify({
|
|
417
|
+
query: deleteMediaEntryMutation,
|
|
418
|
+
variables: { id },
|
|
419
|
+
}),
|
|
420
|
+
});
|
|
421
|
+
const response = yield request.json();
|
|
422
|
+
if (request.status === 200) {
|
|
423
|
+
const deleted = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.DeleteMediaListEntry) === null || _b === void 0 ? void 0 : _b.deleted;
|
|
424
|
+
console.log(`del ${title ? getTitle(title) : ""} ${deleted ? "✅" : "❌"}`);
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
console.log(`\nError deleting anime. ${(_c = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _c === void 0 ? void 0 : _c.message}`);
|
|
428
|
+
console.log(response);
|
|
429
|
+
}
|
|
169
430
|
}
|
|
170
431
|
catch (error) {
|
|
171
|
-
console.
|
|
432
|
+
console.log(`\nError deleting anime. ${id} ${error.message}`);
|
|
172
433
|
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
static DeleteMyMangaList() {
|
|
437
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
438
|
+
var _a, _b, _c, _d;
|
|
439
|
+
try {
|
|
440
|
+
if (yield Auth.isLoggedIn()) {
|
|
441
|
+
const userID = yield Auth.MyUserId();
|
|
442
|
+
if (userID) {
|
|
443
|
+
const request = yield fetch(aniListEndpoint, {
|
|
444
|
+
method: "POST",
|
|
445
|
+
headers: {
|
|
446
|
+
"content-type": "application/json",
|
|
447
|
+
"Authorization": `Bearer ${yield Auth.RetriveAccessToken()}`,
|
|
448
|
+
},
|
|
449
|
+
body: JSON.stringify({
|
|
450
|
+
query: currentUserMangaList,
|
|
451
|
+
variables: { id: userID },
|
|
452
|
+
}),
|
|
453
|
+
});
|
|
454
|
+
const response = yield request.json();
|
|
455
|
+
if (request.status === 200) {
|
|
456
|
+
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;
|
|
457
|
+
if (lists.length > 0) {
|
|
458
|
+
const { selectedList } = yield inquirer.prompt([
|
|
459
|
+
{
|
|
460
|
+
type: "list",
|
|
461
|
+
name: "selectedList",
|
|
462
|
+
message: "Select a manga list:",
|
|
463
|
+
choices: lists.map((list) => list.name),
|
|
464
|
+
pageSize: 10,
|
|
465
|
+
},
|
|
466
|
+
]);
|
|
467
|
+
const selectedEntries = lists.find((list) => list.name === selectedList);
|
|
468
|
+
if (selectedEntries) {
|
|
469
|
+
console.log(`\nDeleting entries of '${selectedEntries.name}':`);
|
|
470
|
+
for (const [_, entry] of selectedEntries.entries.entries()) {
|
|
471
|
+
if (entry === null || entry === void 0 ? void 0 : entry.id) {
|
|
472
|
+
yield Auth.DeleteMangaById(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);
|
|
473
|
+
yield new Promise((resolve) => setTimeout(resolve, 1100));
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
console.log(`No id in entry.`);
|
|
477
|
+
console.log(entry);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
console.error("\nNo entries found.");
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
console.error(`\nNo manga(s) found in any list.`);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
console.error(`\nSomething went wrong. ${(_d = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _d === void 0 ? void 0 : _d.message}`);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
console.error(`\nFailed getting current user Id.`);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
console.error(`\nPlease log in first to delete your lists.`);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
catch (error) {
|
|
502
|
+
console.error(`\nError deleting manga.`);
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
static DeleteMangaById(id, title) {
|
|
507
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
508
|
+
var _a, _b;
|
|
509
|
+
try {
|
|
510
|
+
const request = yield fetch(aniListEndpoint, {
|
|
511
|
+
method: "POST",
|
|
512
|
+
headers: {
|
|
513
|
+
"Content-Type": "application/json",
|
|
514
|
+
"Authorization": `Bearer ${yield Auth.RetriveAccessToken()}`,
|
|
515
|
+
},
|
|
516
|
+
body: JSON.stringify({
|
|
517
|
+
query: deleteMangaEntryMutation,
|
|
518
|
+
variables: { id },
|
|
519
|
+
}),
|
|
520
|
+
});
|
|
521
|
+
const { data, errors } = yield request.json();
|
|
522
|
+
const statusMessage = title ? getTitle(title) : "";
|
|
523
|
+
if (request.ok) {
|
|
524
|
+
const deleted = (_a = data === null || data === void 0 ? void 0 : data.DeleteMediaListEntry) === null || _a === void 0 ? void 0 : _a.deleted;
|
|
525
|
+
console.log(`del ${statusMessage} ${deleted ? "✅" : "❌"}`);
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
console.error(`Error deleting manga. ${(_b = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _b === void 0 ? void 0 : _b.message}`);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
catch (error) {
|
|
532
|
+
console.error(`Error deleting manga. ${id} ${error instanceof Error ? error.message : error}`);
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
static Write(status) {
|
|
537
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
538
|
+
var _a;
|
|
539
|
+
try {
|
|
540
|
+
if (!(yield Auth.isLoggedIn())) {
|
|
541
|
+
console.error(`\nPlease login to use this feature.`);
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
const query = saveTextActivityMutation;
|
|
545
|
+
const variables = {
|
|
546
|
+
status: status +
|
|
547
|
+
`<br><br><br><br>*Written using [@irfanshadikrishad/anilist](https://www.npmjs.com/package/@irfanshadikrishad/anilist).*`,
|
|
548
|
+
};
|
|
549
|
+
const data = yield fetcher(query, variables);
|
|
550
|
+
if (!data) {
|
|
551
|
+
console.error(`\nSomething went wrong. ${data}.`);
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
const savedActivity = (_a = data.data) === null || _a === void 0 ? void 0 : _a.SaveTextActivity;
|
|
555
|
+
if (savedActivity === null || savedActivity === void 0 ? void 0 : savedActivity.id) {
|
|
556
|
+
console.log(`\n[${savedActivity.id}] status saved successfully!`);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
catch (error) {
|
|
560
|
+
console.error(`\n${error.message}`);
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
static callAnimeImporter() {
|
|
565
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
566
|
+
try {
|
|
567
|
+
const { source } = yield inquirer.prompt([
|
|
568
|
+
{
|
|
569
|
+
type: "list",
|
|
570
|
+
name: "source",
|
|
571
|
+
message: "Select a source:",
|
|
572
|
+
choices: [
|
|
573
|
+
{ name: "Exported JSON file.", value: 1 },
|
|
574
|
+
{ name: "MyAnimeList (XML)", value: 2 },
|
|
575
|
+
],
|
|
576
|
+
pageSize: 10,
|
|
577
|
+
},
|
|
578
|
+
]);
|
|
579
|
+
switch (source) {
|
|
580
|
+
case 1:
|
|
581
|
+
yield AniList.importAnime();
|
|
582
|
+
break;
|
|
583
|
+
case 2:
|
|
584
|
+
yield MyAnimeList.importAnime();
|
|
585
|
+
break;
|
|
586
|
+
default:
|
|
587
|
+
console.log(`\nInvalid Choice.`);
|
|
588
|
+
break;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
catch (error) {
|
|
592
|
+
console.error(`\n${error.message}`);
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
static callMangaImporter() {
|
|
597
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
598
|
+
try {
|
|
599
|
+
const { source } = yield inquirer.prompt([
|
|
600
|
+
{
|
|
601
|
+
type: "list",
|
|
602
|
+
name: "source",
|
|
603
|
+
message: "Select a source:",
|
|
604
|
+
choices: [
|
|
605
|
+
{ name: "Exported JSON file.", value: 1 },
|
|
606
|
+
{ name: "MyAnimeList (XML)", value: 2 },
|
|
607
|
+
],
|
|
608
|
+
pageSize: 10,
|
|
609
|
+
},
|
|
610
|
+
]);
|
|
611
|
+
switch (source) {
|
|
612
|
+
case 1:
|
|
613
|
+
yield AniList.importManga();
|
|
614
|
+
break;
|
|
615
|
+
case 2:
|
|
616
|
+
yield MyAnimeList.importManga();
|
|
617
|
+
break;
|
|
618
|
+
default:
|
|
619
|
+
console.log(`\nInvalid Choice.`);
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
catch (error) {
|
|
624
|
+
console.error(`\n${error.message}`);
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
static Like(type) {
|
|
629
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
630
|
+
var _a, _b, _c, _d;
|
|
631
|
+
try {
|
|
632
|
+
let page = 1;
|
|
633
|
+
let hasMoreActivities = true;
|
|
634
|
+
let activity = type === 0
|
|
635
|
+
? followingActivitiesQuery
|
|
636
|
+
: type === 1
|
|
637
|
+
? globalActivitiesQuery
|
|
638
|
+
: followingActivitiesQuery;
|
|
639
|
+
while (hasMoreActivities) {
|
|
640
|
+
const activities = yield fetcher(activity, {
|
|
641
|
+
page,
|
|
642
|
+
perPage: 50,
|
|
643
|
+
});
|
|
644
|
+
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) {
|
|
645
|
+
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;
|
|
646
|
+
for (let activ of activiti) {
|
|
647
|
+
if (!activ.isLiked && activ.id) {
|
|
648
|
+
try {
|
|
649
|
+
const like = yield fetcher(likeActivityMutation, {
|
|
650
|
+
activityId: activ.id,
|
|
651
|
+
});
|
|
652
|
+
// const ToggleLike = like?.data?.ToggleLike
|
|
653
|
+
console.info(`[${activ.id}] liked ${activ.user.name}`);
|
|
654
|
+
}
|
|
655
|
+
catch (error) {
|
|
656
|
+
console.error(`Activity possibly deleted.`);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
660
|
+
console.log(`[${activ === null || activ === void 0 ? void 0 : activ.id}] ${activ.user.name} already-liked`);
|
|
661
|
+
}
|
|
662
|
+
// avoiding rate-limit
|
|
663
|
+
yield new Promise((resolve) => {
|
|
664
|
+
setTimeout(resolve, 2000);
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
page++;
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
// No more activities to like
|
|
671
|
+
console.log(`\nProbably the end of activities.`);
|
|
672
|
+
console.info(activities);
|
|
673
|
+
hasMoreActivities = false;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
catch (error) {
|
|
678
|
+
console.error(`\nError from likeFollowing. ${error.message}`);
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
static LikeSpecificUser() {
|
|
683
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
684
|
+
var _a, _b, _c, _d, _e, _f;
|
|
685
|
+
try {
|
|
686
|
+
const { username } = yield inquirer.prompt([
|
|
687
|
+
{
|
|
688
|
+
type: "input",
|
|
689
|
+
name: "username",
|
|
690
|
+
message: "Username of the user:",
|
|
691
|
+
},
|
|
692
|
+
]);
|
|
693
|
+
const userDetails = yield fetcher(userQuery, { username: username });
|
|
694
|
+
if (userDetails) {
|
|
695
|
+
let page = 1;
|
|
696
|
+
const perPage = 50;
|
|
697
|
+
const userId = (_b = (_a = userDetails === null || userDetails === void 0 ? void 0 : userDetails.data) === null || _a === void 0 ? void 0 : _a.User) === null || _b === void 0 ? void 0 : _b.id;
|
|
698
|
+
if (userId) {
|
|
699
|
+
while (true) {
|
|
700
|
+
const activities = yield fetcher(specificUserActivitiesQuery, {
|
|
701
|
+
page,
|
|
702
|
+
perPage,
|
|
703
|
+
userId,
|
|
704
|
+
});
|
|
705
|
+
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;
|
|
706
|
+
// Break the loop if no more activities are found
|
|
707
|
+
if (!activiti || activiti.length === 0) {
|
|
708
|
+
console.log("No more activities found.");
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
for (let activ of activiti) {
|
|
712
|
+
if (!activ.isLiked && activ.id) {
|
|
713
|
+
try {
|
|
714
|
+
const like = yield fetcher(likeActivityMutation, {
|
|
715
|
+
activityId: activ.id,
|
|
716
|
+
});
|
|
717
|
+
console.info(`[${activ.id}] liked ${(_e = activ.user) === null || _e === void 0 ? void 0 : _e.name}`);
|
|
718
|
+
}
|
|
719
|
+
catch (error) {
|
|
720
|
+
console.error(`Activity possibly deleted.`);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
else {
|
|
724
|
+
console.log(`[${activ === null || activ === void 0 ? void 0 : activ.id}] ${(_f = activ.user) === null || _f === void 0 ? void 0 : _f.name} already liked`);
|
|
725
|
+
}
|
|
726
|
+
// Avoiding rate limit
|
|
727
|
+
yield new Promise((resolve) => {
|
|
728
|
+
setTimeout(resolve, 2000);
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
// Go to the next page
|
|
732
|
+
page += 1;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
catch (error) {
|
|
738
|
+
console.error(`\nError from LikeSpecificUser. ${error.message}`);
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
static AutoLike() {
|
|
743
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
744
|
+
try {
|
|
745
|
+
if (!(yield Auth.isLoggedIn())) {
|
|
746
|
+
console.error(`\nPlease login to use this feature.`);
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
const { activityType } = yield inquirer.prompt([
|
|
750
|
+
{
|
|
751
|
+
type: "list",
|
|
752
|
+
name: "activityType",
|
|
753
|
+
message: "Select activity type:",
|
|
754
|
+
choices: [
|
|
755
|
+
{ name: "Following", value: 1 },
|
|
756
|
+
{ name: "Global", value: 2 },
|
|
757
|
+
{ name: "Specific User", value: 3 },
|
|
758
|
+
],
|
|
759
|
+
pageSize: 10,
|
|
760
|
+
},
|
|
761
|
+
]);
|
|
762
|
+
switch (activityType) {
|
|
763
|
+
case 1:
|
|
764
|
+
yield this.Like(0);
|
|
765
|
+
break;
|
|
766
|
+
case 2:
|
|
767
|
+
yield this.Like(1);
|
|
768
|
+
break;
|
|
769
|
+
case 3:
|
|
770
|
+
yield this.LikeSpecificUser();
|
|
771
|
+
break;
|
|
772
|
+
default:
|
|
773
|
+
console.error(`\nInvalid choice. (${activityType})`);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
catch (error) {
|
|
777
|
+
console.error(`\nError from autolike. ${error.message}`);
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
}
|
|
226
781
|
}
|
|
227
|
-
export {
|
|
782
|
+
export { Auth };
|