@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/package.json CHANGED
@@ -1,72 +1,73 @@
1
- {
2
- "name": "@irfanshadikrishad/anilist",
3
- "description": "Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts",
4
- "author": "Irfan Shadik Rishad",
5
- "version": "1.0.8",
6
- "main": "./bin/index.js",
7
- "type": "module",
8
- "types": "./bin/index.d.ts",
9
- "bin": {
10
- "anilist": "./bin/index.js"
11
- },
12
- "publishConfig": {
13
- "access": "public"
14
- },
15
- "scripts": {
16
- "build": "rm -rf ./bin && tsc -w",
17
- "format": "prettier . --write",
18
- "format:check": "prettier . --check",
19
- "lint": "eslint ./dist",
20
- "lint:fix": "eslint ./dist --fix"
21
- },
22
- "keywords": [
23
- "anilist",
24
- "CLI",
25
- "anime",
26
- "manga",
27
- "anime list",
28
- "manga list",
29
- "anime tracker",
30
- "manga tracker",
31
- "anilist API",
32
- "anime progress",
33
- "manga progress",
34
- "media list",
35
- "export anime",
36
- "import anime",
37
- "export manga",
38
- "import manga",
39
- "status tracker",
40
- "watchlist",
41
- "reading list",
42
- "graphql"
43
- ],
44
- "repository": {
45
- "type": "git",
46
- "url": "https://github.com/irfanshadikrishad/anilist"
47
- },
48
- "homepage": "https://github.com/irfanshadikrishad/anilist",
49
- "bugs": {
50
- "url": "https://github.com/irfanshadikrishad/anilist/issues"
51
- },
52
- "license": "MPL-2.0",
53
- "devDependencies": {
54
- "@eslint/js": "^9.13.0",
55
- "@types/json2csv": "^5.0.7",
56
- "@types/node": "^22.7.9",
57
- "eslint": "^9.13.0",
58
- "globals": "^15.11.0",
59
- "prettier": "^3.3.3",
60
- "prettier-plugin-organize-imports": "^4.1.0",
61
- "typescript": "^5.6.3",
62
- "typescript-eslint": "^8.11.0"
63
- },
64
- "dependencies": {
65
- "commander": "^12.1.0",
66
- "fast-xml-parser": "^4.5.0",
67
- "inquirer": "^12.0.0",
68
- "json2csv": "^6.0.0-alpha.2",
69
- "node-fetch": "^3.3.2",
70
- "open": "^10.1.0"
71
- }
72
- }
1
+ {
2
+ "name": "@irfanshadikrishad/anilist",
3
+ "description": "Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts",
4
+ "author": "Irfan Shadik Rishad",
5
+ "version": "1.1.0-forbidden.0",
6
+ "main": "./bin/index.js",
7
+ "type": "module",
8
+ "types": "./bin/index.d.ts",
9
+ "bin": {
10
+ "anilist": "./bin/index.js"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "scripts": {
16
+ "build": "rm -rf ./bin && tsc -w",
17
+ "format": "prettier . --write",
18
+ "format:check": "prettier . --check",
19
+ "lint": "eslint ./dist",
20
+ "lint:fix": "eslint ./dist --fix",
21
+ "all": "npm run lint && npm run lint:fix && npm run format"
22
+ },
23
+ "keywords": [
24
+ "anilist",
25
+ "CLI",
26
+ "anime",
27
+ "manga",
28
+ "anime list",
29
+ "manga list",
30
+ "anime tracker",
31
+ "manga tracker",
32
+ "anilist API",
33
+ "anime progress",
34
+ "manga progress",
35
+ "media list",
36
+ "export anime",
37
+ "import anime",
38
+ "export manga",
39
+ "import manga",
40
+ "status tracker",
41
+ "watchlist",
42
+ "reading list",
43
+ "graphql"
44
+ ],
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "https://github.com/irfanshadikrishad/anilist"
48
+ },
49
+ "homepage": "https://github.com/irfanshadikrishad/anilist",
50
+ "bugs": {
51
+ "url": "https://github.com/irfanshadikrishad/anilist/issues"
52
+ },
53
+ "license": "MPL-2.0",
54
+ "devDependencies": {
55
+ "@eslint/js": "^9.13.0",
56
+ "@types/json2csv": "^5.0.7",
57
+ "@types/node": "^22.8.1",
58
+ "eslint": "^9.13.0",
59
+ "globals": "^15.11.0",
60
+ "prettier": "^3.3.3",
61
+ "prettier-plugin-organize-imports": "^4.1.0",
62
+ "typescript": "^5.6.3",
63
+ "typescript-eslint": "^8.11.0"
64
+ },
65
+ "dependencies": {
66
+ "commander": "^12.1.0",
67
+ "fast-xml-parser": "^4.5.0",
68
+ "inquirer": "^12.0.1",
69
+ "json2csv": "^6.0.0-alpha.2",
70
+ "node-fetch": "^3.3.2",
71
+ "open": "^10.1.0"
72
+ }
73
+ }
@@ -1,11 +0,0 @@
1
- declare function getUserInfoByUsername(username: string): Promise<void>;
2
- declare function getAnimeDetailsByID(anilistID: number): Promise<void>;
3
- declare function getAnimeSearchResults(search: string, count: number): Promise<void>;
4
- declare function getMangaSearchResults(search: string, count: number): Promise<void>;
5
- declare function deleteUserActivities(): Promise<void>;
6
- declare function writeTextActivity(status: string): Promise<void>;
7
- declare function exportAnimeList(): Promise<void>;
8
- declare function exportMangaList(): Promise<void>;
9
- declare function importAnimeList(): Promise<void>;
10
- declare function importMangaList(): Promise<void>;
11
- export { deleteUserActivities, exportAnimeList, exportMangaList, getAnimeDetailsByID, getAnimeSearchResults, getMangaSearchResults, getUserInfoByUsername, importAnimeList, importMangaList, writeTextActivity, };
@@ -1,500 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import inquirer from "inquirer";
11
- import fetch from "node-fetch";
12
- import { currentUsersId, isLoggedIn, retriveAccessToken } from "./auth.js";
13
- import { fetcher } from "./fetcher.js";
14
- import { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, saveTextActivityMutation, } from "./mutations.js";
15
- import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, mangaSearchQuery, userActivityQuery, userQuery, } from "./queries.js";
16
- import { aniListEndpoint, formatDateObject, getTitle, importAnimeListFromExportedJSON, importMangaListFromExportedJSON, MALexport, MALimport, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, } from "./workers.js";
17
- function getUserInfoByUsername(username) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
20
- try {
21
- const headers = {
22
- "content-type": "application/json",
23
- };
24
- if (yield isLoggedIn()) {
25
- headers["Authorization"] = `Bearer ${yield retriveAccessToken()}`;
26
- }
27
- const request = yield fetch(aniListEndpoint, {
28
- method: "POST",
29
- headers: headers,
30
- body: JSON.stringify({ query: userQuery, variables: { username } }),
31
- });
32
- const response = yield request.json();
33
- if (request.status === 200) {
34
- const user = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.User;
35
- const responseUserActivity = yield fetcher(userActivityQuery, {
36
- id: user === null || user === void 0 ? void 0 : user.id,
37
- page: 1,
38
- perPage: 10,
39
- });
40
- const activities = ((_c = (_b = responseUserActivity === null || responseUserActivity === void 0 ? void 0 : responseUserActivity.data) === null || _b === void 0 ? void 0 : _b.Page) === null || _c === void 0 ? void 0 : _c.activities) || [];
41
- console.log(`\nID:\t\t${user === null || user === void 0 ? void 0 : user.id}`);
42
- console.log(`Name:\t\t${user === null || user === void 0 ? void 0 : user.name}`);
43
- console.log(`siteUrl:\t${user === null || user === void 0 ? void 0 : user.siteUrl}`);
44
- console.log(`Donator Tier:\t${user === null || user === void 0 ? void 0 : user.donatorTier}`);
45
- console.log(`Donator Badge:\t${user === null || user === void 0 ? void 0 : user.donatorBadge}`);
46
- if (user === null || user === void 0 ? void 0 : user.createdAt) {
47
- console.log(`Account Created: ${new Date(user.createdAt * 1000).toUTCString()}`);
48
- }
49
- console.log(`Account Updated:${new Date((user === null || user === void 0 ? void 0 : user.updatedAt) * 1000).toUTCString()}`);
50
- console.log(`I blocked?\t${user === null || user === void 0 ? void 0 : user.isBlocked}`);
51
- console.log(`My follower:\t${user === null || user === void 0 ? void 0 : user.isFollower}`);
52
- console.log(`I'm following:\t${user === null || user === void 0 ? void 0 : user.isFollowing}`);
53
- console.log(`Color:\t${(_d = user === null || user === void 0 ? void 0 : user.options) === null || _d === void 0 ? void 0 : _d.profileColor}`);
54
- console.log(`Timezone:\t${(_e = user === null || user === void 0 ? void 0 : user.options) === null || _e === void 0 ? void 0 : _e.timezone}`);
55
- console.log(`\nStatistics (Anime)\nCount: ${(_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} episodesWatched: ${(_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.episodesWatched} minutesWatched: ${(_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}`);
56
- console.log(`Statistics (Manga)\nCount: ${(_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} Chapter 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} 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}`);
57
- console.log(`\nRecent Activities:`);
58
- if (activities.length > 0) {
59
- activities.map(({ status, progress, media }) => {
60
- console.log(`${status} ${progress ? `${progress} of ` : ""}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
61
- });
62
- }
63
- }
64
- else {
65
- console.error(`\n${request.status} ${(_t = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _t === void 0 ? void 0 : _t.message}`);
66
- }
67
- }
68
- catch (error) {
69
- console.error(`\nSomething went wrong. ${error.message}`);
70
- }
71
- });
72
- }
73
- function getAnimeDetailsByID(anilistID) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- var _a;
76
- const query = animeDetailsQuery;
77
- const variables = { id: anilistID };
78
- const details = yield fetcher(query, variables);
79
- if ((_a = details === null || details === void 0 ? void 0 : details.data) === null || _a === void 0 ? void 0 : _a.Media) {
80
- const { id, title, description, duration, startDate, endDate, countryOfOrigin, isAdult, status, season, format, genres, siteUrl, } = details.data.Media;
81
- console.log(`\nID: ${id}`);
82
- console.log(`Title: ${(title === null || title === void 0 ? void 0 : title.userPreffered) || getTitle(title)}`);
83
- console.log(`Description: ${removeHtmlAndMarkdown(description)}`);
84
- console.log(`Episode Duration: ${duration}min`);
85
- console.log(`Origin: ${countryOfOrigin}`);
86
- console.log(`Status: ${String(status)}`);
87
- console.log(`Format: ${format}`);
88
- console.log(`Genres: ${genres.join(", ")}`);
89
- console.log(`Season: ${season}`);
90
- console.log(`Url: `, siteUrl);
91
- console.log(`isAdult: ${isAdult}`);
92
- console.log(`Released: ${formatDateObject(startDate)}`);
93
- console.log(`Finished: ${formatDateObject(endDate)}`);
94
- }
95
- });
96
- }
97
- function getAnimeSearchResults(search, count) {
98
- return __awaiter(this, void 0, void 0, function* () {
99
- var _a, _b, _c;
100
- const query = animeSearchQuery;
101
- const variables = { search, page: 1, perPage: count };
102
- const searchResults = yield fetcher(query, variables);
103
- if (searchResults) {
104
- const results = (_b = (_a = searchResults === null || searchResults === void 0 ? void 0 : searchResults.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.media;
105
- if (results.length > 0) {
106
- const { selectedList } = yield inquirer.prompt([
107
- {
108
- type: "list",
109
- name: "selectedList",
110
- message: "Select anime to add to your list:",
111
- choices: results.map((res, idx) => ({
112
- name: `[${idx + 1}] ${getTitle(res === null || res === void 0 ? void 0 : res.title)}`,
113
- value: res === null || res === void 0 ? void 0 : res.id,
114
- })),
115
- pageSize: 10,
116
- },
117
- ]);
118
- // Where to save
119
- const { selectedListType } = yield inquirer.prompt([
120
- {
121
- type: "list",
122
- name: "selectedListType",
123
- message: "Select the list where you want to save this anime:",
124
- choices: [
125
- { name: "Planning", value: "PLANNING" },
126
- { name: "Watching", value: "CURRENT" },
127
- { name: "Completed", value: "COMPLETED" },
128
- { name: "Paused", value: "PAUSED" },
129
- { name: "Dropped", value: "DROPPED" },
130
- ],
131
- },
132
- ]);
133
- // Lets save to the list now
134
- if (yield isLoggedIn()) {
135
- const query = addAnimeToListMutation;
136
- const variables = { mediaId: selectedList, status: selectedListType };
137
- const response = yield fetcher(query, variables);
138
- if (response) {
139
- const saved = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
140
- console.log(`\nEntry ${saved === null || saved === void 0 ? void 0 : saved.id}. Saved as ${saved === null || saved === void 0 ? void 0 : saved.status}.`);
141
- }
142
- }
143
- else {
144
- console.error(`\nPlease log in first to use this feature.`);
145
- }
146
- }
147
- else {
148
- console.log(`\nNo search results!`);
149
- }
150
- }
151
- else {
152
- console.error(`\nSomething went wrong.`);
153
- }
154
- });
155
- }
156
- function getMangaSearchResults(search, count) {
157
- return __awaiter(this, void 0, void 0, function* () {
158
- var _a, _b, _c;
159
- const query = mangaSearchQuery;
160
- const variables = { search, page: 1, perPage: count };
161
- const mangaSearchResult = yield fetcher(query, variables);
162
- if (mangaSearchResult) {
163
- const results = (_b = (_a = mangaSearchResult === null || mangaSearchResult === void 0 ? void 0 : mangaSearchResult.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.media;
164
- // List of manga search results
165
- const { selectedMangaId } = yield inquirer.prompt([
166
- {
167
- type: "list",
168
- name: "selectedMangaId",
169
- message: "Select manga to add to your list:",
170
- choices: results.map((res, idx) => ({
171
- name: `[${idx + 1}] ${getTitle(res === null || res === void 0 ? void 0 : res.title)}`,
172
- value: res === null || res === void 0 ? void 0 : res.id,
173
- })),
174
- pageSize: 10,
175
- },
176
- ]);
177
- // Options to save to the list
178
- const { selectedListType } = yield inquirer.prompt([
179
- {
180
- type: "list",
181
- name: "selectedListType",
182
- message: "Select the list where you want to save this manga:",
183
- choices: [
184
- { name: "Planning", value: "PLANNING" },
185
- { name: "Reading", value: "CURRENT" },
186
- { name: "Completed", value: "COMPLETED" },
187
- { name: "Paused", value: "PAUSED" },
188
- { name: "Dropped", value: "DROPPED" },
189
- ],
190
- },
191
- ]);
192
- // If logged in save to the list
193
- if (yield isLoggedIn()) {
194
- const mutation = addMangaToListMutation;
195
- const variables = { mediaId: selectedMangaId, status: selectedListType };
196
- const response = yield fetcher(mutation, variables);
197
- if (response) {
198
- const saved = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
199
- console.log(`\nEntry ${saved === null || saved === void 0 ? void 0 : saved.id}. Saved as ${saved === null || saved === void 0 ? void 0 : saved.status}.`);
200
- }
201
- }
202
- else {
203
- console.error(`\nPlease log in first to use this feature.`);
204
- }
205
- }
206
- else {
207
- console.error(`\nSomething went wrong.`);
208
- }
209
- });
210
- }
211
- function deleteUserActivities() {
212
- return __awaiter(this, void 0, void 0, function* () {
213
- var _a, _b, _c, _d, _e, _f;
214
- if (yield isLoggedIn()) {
215
- const { activityType } = yield inquirer.prompt([
216
- {
217
- type: "list",
218
- name: "activityType",
219
- message: "What type of activity you want to delete?",
220
- choices: [
221
- { name: "All Activity", value: 0 },
222
- { name: "Text Activity", value: 1 },
223
- { name: "Media List Activity", value: 2 },
224
- { name: "Anime List Activity", value: 3 },
225
- { name: "Manga List Activity", value: 4 },
226
- { name: "Message Activity", value: 5 },
227
- ],
228
- },
229
- ]);
230
- const userId = yield currentUsersId();
231
- const variables = { page: 1, perPage: 100, userId };
232
- const queryMap = {
233
- 0: activityAllQuery,
234
- 1: activityTextQuery,
235
- 2: activityMediaList,
236
- 3: activityAnimeListQuery,
237
- 4: activityMangaListQuery,
238
- 5: activityMessageQuery,
239
- };
240
- const query = queryMap[activityType];
241
- let hasMoreActivities = true;
242
- while (hasMoreActivities) {
243
- const response = yield fetcher(query, {
244
- page: 1,
245
- perPage: 50,
246
- userId: yield currentUsersId(),
247
- });
248
- 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) {
249
- let count = 0;
250
- 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;
251
- if (!activities || activities.length === 0) {
252
- console.log(`\nNo more activities available.`);
253
- hasMoreActivities = false;
254
- }
255
- else {
256
- for (const act of activities) {
257
- // Ensure ID is present to avoid unintended errors
258
- if (act === null || act === void 0 ? void 0 : act.id) {
259
- const deleteResponse = yield fetcher(deleteActivityMutation, {
260
- id: act === null || act === void 0 ? void 0 : act.id,
261
- });
262
- 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;
263
- count++;
264
- console.log(`[${count}/${activities.length}] ${act === null || act === void 0 ? void 0 : act.id} ${isDeleted ? "✅" : "❌"}`);
265
- // Avoiding rate-limit
266
- yield new Promise((resolve) => setTimeout(resolve, 2000));
267
- }
268
- }
269
- }
270
- }
271
- else {
272
- // In case of an unexpected null response, exit the loop
273
- console.log(`\nProbably deleted all the activities of this type.`);
274
- hasMoreActivities = false;
275
- }
276
- }
277
- }
278
- else {
279
- console.error(`\nPlease log in to delete your activities.`);
280
- }
281
- });
282
- }
283
- function writeTextActivity(status) {
284
- return __awaiter(this, void 0, void 0, function* () {
285
- var _a;
286
- try {
287
- if (!(yield isLoggedIn())) {
288
- console.error(`\nPlease login to use this feature.`);
289
- return;
290
- }
291
- const query = saveTextActivityMutation;
292
- const variables = {
293
- status: status +
294
- `<br><br><br><br>*Written using [@irfanshadikrishad/anilist](https://www.npmjs.com/package/@irfanshadikrishad/anilist).*`,
295
- };
296
- const data = yield fetcher(query, variables);
297
- if (!data) {
298
- console.error(`\nSomething went wrong. ${data}.`);
299
- return;
300
- }
301
- const savedActivity = (_a = data.data) === null || _a === void 0 ? void 0 : _a.SaveTextActivity;
302
- if (savedActivity === null || savedActivity === void 0 ? void 0 : savedActivity.id) {
303
- console.log(`\n[${savedActivity.id}] status saved successfully!`);
304
- }
305
- }
306
- catch (error) {
307
- console.error(`\n${error.message}`);
308
- }
309
- });
310
- }
311
- function exportAnimeList() {
312
- return __awaiter(this, void 0, void 0, function* () {
313
- var _a, _b, _c;
314
- if (yield isLoggedIn()) {
315
- const { exportType } = yield inquirer.prompt([
316
- {
317
- type: "list",
318
- name: "exportType",
319
- message: "Choose export type:",
320
- choices: [
321
- { name: "CSV", value: 1 },
322
- { name: "JSON", value: 2 },
323
- { name: "XML (MyAnimeList)", value: 3 },
324
- ],
325
- pageSize: 10,
326
- },
327
- ]);
328
- const animeList = yield fetcher(currentUserAnimeList, {
329
- id: yield currentUsersId(),
330
- });
331
- if (animeList) {
332
- const lists = (_c = (_b = (_a = animeList === null || animeList === void 0 ? void 0 : animeList.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists) !== null && _c !== void 0 ? _c : [];
333
- const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => {
334
- var _a, _b, _c, _d, _e;
335
- return ({
336
- id: (_a = entry === null || entry === void 0 ? void 0 : entry.media) === null || _a === void 0 ? void 0 : _a.id,
337
- title: exportType === 1
338
- ? getTitle((_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.title)
339
- : (_c = entry === null || entry === void 0 ? void 0 : entry.media) === null || _c === void 0 ? void 0 : _c.title,
340
- episodes: (_d = entry === null || entry === void 0 ? void 0 : entry.media) === null || _d === void 0 ? void 0 : _d.episodes,
341
- siteUrl: (_e = entry === null || entry === void 0 ? void 0 : entry.media) === null || _e === void 0 ? void 0 : _e.siteUrl,
342
- progress: entry.progress,
343
- status: entry === null || entry === void 0 ? void 0 : entry.status,
344
- hiddenFromStatusLists: entry.hiddenFromStatusLists,
345
- });
346
- }));
347
- switch (exportType) {
348
- case 1:
349
- yield saveJSONasCSV(mediaWithProgress, "anime");
350
- break;
351
- case 2:
352
- yield saveJSONasJSON(mediaWithProgress, "anime");
353
- break;
354
- case 3:
355
- yield MALexport.Anime();
356
- break;
357
- default:
358
- console.log(`\nInvalid export type. ${exportType}`);
359
- break;
360
- }
361
- }
362
- else {
363
- console.error(`\nNo anime(s) found in your lists.`);
364
- }
365
- }
366
- else {
367
- console.error(`\nMust login to use this feature.`);
368
- }
369
- });
370
- }
371
- function exportMangaList() {
372
- return __awaiter(this, void 0, void 0, function* () {
373
- var _a, _b;
374
- if (yield isLoggedIn()) {
375
- const mangaLists = yield fetcher(currentUserMangaList, {
376
- id: yield currentUsersId(),
377
- });
378
- if (mangaLists) {
379
- const lists = ((_b = (_a = mangaLists === null || mangaLists === void 0 ? void 0 : mangaLists.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists) || [];
380
- if (lists.length > 0) {
381
- const { exportType } = yield inquirer.prompt([
382
- {
383
- type: "list",
384
- name: "exportType",
385
- message: "Choose export type:",
386
- choices: [
387
- { name: "CSV", value: 1 },
388
- { name: "JSON", value: 2 },
389
- { name: "XML (MyAnimeList)", value: 3 },
390
- ],
391
- pageSize: 10,
392
- },
393
- ]);
394
- const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => {
395
- var _a, _b, _c;
396
- return ({
397
- id: (_a = entry === null || entry === void 0 ? void 0 : entry.media) === null || _a === void 0 ? void 0 : _a.id,
398
- title: exportType === 1
399
- ? getTitle((_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.title)
400
- : (_c = entry === null || entry === void 0 ? void 0 : entry.media) === null || _c === void 0 ? void 0 : _c.title,
401
- private: entry.private,
402
- chapters: entry.media.chapters,
403
- progress: entry.progress,
404
- status: entry === null || entry === void 0 ? void 0 : entry.status,
405
- hiddenFromStatusLists: entry.hiddenFromStatusLists,
406
- });
407
- }));
408
- switch (exportType) {
409
- case 1:
410
- yield saveJSONasCSV(mediaWithProgress, "manga");
411
- break;
412
- case 2:
413
- yield saveJSONasJSON(mediaWithProgress, "manga");
414
- break;
415
- case 3:
416
- yield MALexport.Manga();
417
- break;
418
- default:
419
- console.log(`\nInvalid export type. ${exportType}`);
420
- break;
421
- }
422
- }
423
- else {
424
- console.log(`\nList seems to be empty.`);
425
- }
426
- }
427
- else {
428
- console.error(`\nCould not get manga list.`);
429
- }
430
- }
431
- else {
432
- console.error(`\nPlease login to use this feature.`);
433
- }
434
- });
435
- }
436
- function importAnimeList() {
437
- return __awaiter(this, void 0, void 0, function* () {
438
- try {
439
- const { source } = yield inquirer.prompt([
440
- {
441
- type: "list",
442
- name: "source",
443
- message: "Select a source:",
444
- choices: [
445
- { name: "Exported JSON file.", value: 1 },
446
- { name: "MyAnimeList (XML)", value: 2 },
447
- ],
448
- pageSize: 10,
449
- },
450
- ]);
451
- switch (source) {
452
- case 1:
453
- yield importAnimeListFromExportedJSON();
454
- break;
455
- case 2:
456
- yield MALimport.Anime();
457
- break;
458
- default:
459
- console.log(`\nInvalid Choice.`);
460
- break;
461
- }
462
- }
463
- catch (error) {
464
- console.error(`\n${error.message}`);
465
- }
466
- });
467
- }
468
- function importMangaList() {
469
- return __awaiter(this, void 0, void 0, function* () {
470
- try {
471
- const { source } = yield inquirer.prompt([
472
- {
473
- type: "list",
474
- name: "source",
475
- message: "Select a source:",
476
- choices: [
477
- { name: "Exported JSON file.", value: 1 },
478
- { name: "MyAnimeList (XML)", value: 2 },
479
- ],
480
- pageSize: 10,
481
- },
482
- ]);
483
- switch (source) {
484
- case 1:
485
- yield importMangaListFromExportedJSON();
486
- break;
487
- case 2:
488
- yield MALimport.Manga();
489
- break;
490
- default:
491
- console.log(`\nInvalid Choice.`);
492
- break;
493
- }
494
- }
495
- catch (error) {
496
- console.error(`\n${error.message}`);
497
- }
498
- });
499
- }
500
- export { deleteUserActivities, exportAnimeList, exportMangaList, getAnimeDetailsByID, getAnimeSearchResults, getMangaSearchResults, getUserInfoByUsername, importAnimeList, importMangaList, writeTextActivity, };