@irfanshadikrishad/anilist 1.3.3-forbidden.1 → 1.4.1
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 +266 -243
- package/bin/helpers/auth.d.ts +13 -7
- package/bin/helpers/auth.js +282 -400
- package/bin/helpers/lists.d.ts +1 -0
- package/bin/helpers/lists.js +175 -127
- package/bin/helpers/mutations.d.ts +1 -2
- package/bin/helpers/mutations.js +32 -37
- package/bin/helpers/queries.d.ts +9 -10
- package/bin/helpers/queries.js +150 -167
- package/bin/helpers/truncate.d.ts +6 -0
- package/bin/helpers/truncate.js +10 -0
- package/bin/helpers/types.d.ts +119 -68
- package/bin/helpers/validation.d.ts +29 -0
- package/bin/helpers/validation.js +117 -0
- package/bin/helpers/workers.d.ts +15 -7
- package/bin/helpers/workers.js +132 -99
- package/bin/index.js +30 -6
- package/package.json +85 -81
|
@@ -0,0 +1,117 @@
|
|
|
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 { parseStringPromise } from "xml2js";
|
|
11
|
+
class Validate {
|
|
12
|
+
/**
|
|
13
|
+
* Validate importable JSON file
|
|
14
|
+
* @param data string
|
|
15
|
+
* @returns boolean
|
|
16
|
+
*/
|
|
17
|
+
static Import_JSON(data) {
|
|
18
|
+
return (Array.isArray(data) &&
|
|
19
|
+
data.every((item) => typeof item === "object" && item !== null && "id" in item));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Validate if MyAnimeList Anime XML file is valid or not
|
|
23
|
+
* @param xmlData string
|
|
24
|
+
* @returns boolean
|
|
25
|
+
*/
|
|
26
|
+
static Import_AnimeXML(xmlData) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
try {
|
|
29
|
+
const result = yield parseStringPromise(xmlData, { explicitArray: false });
|
|
30
|
+
if (!result || !result.myanimelist) {
|
|
31
|
+
console.error("Invalid XML structure: Missing 'myanimelist' root element.");
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const animeList = result.myanimelist.anime;
|
|
35
|
+
if (!animeList) {
|
|
36
|
+
console.error("Invalid XML structure: Missing 'anime' elements.");
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const animeArray = Array.isArray(animeList) ? animeList : [animeList];
|
|
40
|
+
const isValid = animeArray.every((anime) => {
|
|
41
|
+
const isValidId = anime.series_animedb_id && !isNaN(Number(anime.series_animedb_id));
|
|
42
|
+
const hasRequiredFields = anime.series_title && anime.my_status;
|
|
43
|
+
return isValidId && hasRequiredFields;
|
|
44
|
+
});
|
|
45
|
+
if (!isValid) {
|
|
46
|
+
console.error("Validation failed: Some anime entries are missing required fields or have invalid IDs.");
|
|
47
|
+
}
|
|
48
|
+
return isValid;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.error("Error parsing or validating XML:", error);
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Validate if MyAnimeList Anime XML file is valid or not
|
|
58
|
+
* @param xmlData string
|
|
59
|
+
* @returns boolean
|
|
60
|
+
*/
|
|
61
|
+
static Import_MangaXML(xmlData) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
try {
|
|
64
|
+
const result = yield parseStringPromise(xmlData, { explicitArray: false });
|
|
65
|
+
if (!result || !result.myanimelist) {
|
|
66
|
+
console.error("Invalid XML structure: Missing 'myanimelist' root element.");
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const mangaList = result.myanimelist.manga;
|
|
70
|
+
if (!mangaList) {
|
|
71
|
+
console.error("Invalid XML structure: Missing 'manga' elements.");
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
const mangaArray = Array.isArray(mangaList) ? mangaList : [mangaList];
|
|
75
|
+
const isValid = mangaArray.every((manga) => {
|
|
76
|
+
const isValidId = manga.manga_mangadb_id && !isNaN(Number(manga.manga_mangadb_id));
|
|
77
|
+
const hasRequiredFields = manga.manga_title && manga.my_status;
|
|
78
|
+
return isValidId && hasRequiredFields;
|
|
79
|
+
});
|
|
80
|
+
if (!isValid) {
|
|
81
|
+
console.error("Validation failed: Some manga entries are missing required fields or have invalid IDs.");
|
|
82
|
+
}
|
|
83
|
+
return isValid;
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
console.error("Error parsing or validating XML:", error);
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Validate AniDB json-large file
|
|
93
|
+
* @param file string of anidb json-large
|
|
94
|
+
* @returns boolean
|
|
95
|
+
*/
|
|
96
|
+
static Import_AniDBJSONLarge(file) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
try {
|
|
99
|
+
if (!(file === null || file === void 0 ? void 0 : file.trim())) {
|
|
100
|
+
console.error("File content is empty or invalid.");
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
const obj3ct = JSON.parse(file);
|
|
104
|
+
if (!obj3ct || !Array.isArray(obj3ct.anime)) {
|
|
105
|
+
console.error("Invalid JSON structure: Missing or malformed 'anime' array.");
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
console.error("Failed to parse JSON file:", error);
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export { Validate };
|
package/bin/helpers/workers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MALAnimeStatus, MALMangaStatus, MediaWithProgress
|
|
1
|
+
import { DateMonthYear, MALAnimeStatus, MALMangaStatus, MediaWithProgress } from "./types.js";
|
|
2
2
|
declare const aniListEndpoint = "https://graphql.anilist.co";
|
|
3
3
|
declare const redirectUri = "https://anilist.co/api/v2/oauth/pin";
|
|
4
4
|
declare function getTitle(title: {
|
|
@@ -20,22 +20,30 @@ declare function getFormattedDate(): string;
|
|
|
20
20
|
/**
|
|
21
21
|
* Export JSON as JSON
|
|
22
22
|
* @param js0n
|
|
23
|
-
* @param dataType (eg: anime
|
|
23
|
+
* @param dataType (eg: anime|manga)
|
|
24
24
|
*/
|
|
25
25
|
declare function saveJSONasJSON(js0n: object, dataType: string): Promise<void>;
|
|
26
26
|
/**
|
|
27
27
|
* Export JSON as CSV
|
|
28
28
|
* @param js0n
|
|
29
|
-
* @param dataType (eg: anime
|
|
29
|
+
* @param dataType (eg: anime|manga)
|
|
30
30
|
*/
|
|
31
|
-
declare function saveJSONasCSV(js0n:
|
|
31
|
+
declare function saveJSONasCSV(js0n: MediaWithProgress[], dataType: string): Promise<void>;
|
|
32
|
+
declare function saveJSONasXML(js0n: MediaWithProgress[], data_type: 0 | 1): Promise<void>;
|
|
32
33
|
declare function selectFile(fileType: string): Promise<string>;
|
|
33
|
-
declare function createAnimeXML(malId: number, progress: number, status: MALAnimeStatus, episodes: number, title: string): string;
|
|
34
|
+
declare function createAnimeXML(malId: number, progress: number, status: MALAnimeStatus, episodes: number, title: string, format: string): string;
|
|
34
35
|
declare function createMangaXML(malId: number, progress: number, status: MALMangaStatus, chapters: number, title: string): string;
|
|
35
36
|
declare function createAnimeListXML(mediaWithProgress: MediaWithProgress[]): Promise<string>;
|
|
36
37
|
declare function createMangaListXML(mediaWithProgress: MediaWithProgress[]): Promise<string>;
|
|
37
38
|
declare function getCurrentPackageVersion(): string | null;
|
|
38
39
|
declare function timestampToTimeAgo(timestamp: number): string;
|
|
39
|
-
declare function activityBy(activity: TheActivity): string;
|
|
40
40
|
declare const anidbToanilistMapper: (romanjiName: string, year: number, englishName?: string) => Promise<number | null>;
|
|
41
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Extract the save file path
|
|
43
|
+
* @param data_type - anime|manga
|
|
44
|
+
* @param file_format - save format (eg: .json|.csv)
|
|
45
|
+
* @returns string of file path
|
|
46
|
+
*/
|
|
47
|
+
declare function saveToPath(data_type: string, file_format: string): Promise<string>;
|
|
48
|
+
declare function simpleDateFormat(date: DateMonthYear): string;
|
|
49
|
+
export { anidbToanilistMapper, aniListEndpoint, createAnimeListXML, createAnimeXML, createMangaListXML, createMangaXML, formatDateObject, getCurrentPackageVersion, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, saveJSONasXML, saveToPath, selectFile, simpleDateFormat, timestampToTimeAgo, };
|
package/bin/helpers/workers.js
CHANGED
|
@@ -7,13 +7,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
10
21
|
import fs from "fs";
|
|
11
22
|
import { readdir, writeFile } from "fs/promises";
|
|
12
23
|
import inquirer from "inquirer";
|
|
13
|
-
import { parse } from "json2csv";
|
|
14
24
|
import { createRequire } from "module";
|
|
15
25
|
import open from "open";
|
|
16
26
|
import { homedir } from "os";
|
|
27
|
+
import Papa from "papaparse";
|
|
17
28
|
import { join } from "path";
|
|
18
29
|
import process from "process";
|
|
19
30
|
import { Auth } from "./auth.js";
|
|
@@ -97,13 +108,13 @@ function getFormattedDate() {
|
|
|
97
108
|
/**
|
|
98
109
|
* Export JSON as JSON
|
|
99
110
|
* @param js0n
|
|
100
|
-
* @param dataType (eg: anime
|
|
111
|
+
* @param dataType (eg: anime|manga)
|
|
101
112
|
*/
|
|
102
113
|
function saveJSONasJSON(js0n, dataType) {
|
|
103
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
115
|
try {
|
|
105
116
|
const jsonData = JSON.stringify(js0n, null, 2);
|
|
106
|
-
const path =
|
|
117
|
+
const path = yield saveToPath(dataType, ".json");
|
|
107
118
|
yield writeFile(path, jsonData, "utf8");
|
|
108
119
|
console.log(`\nSaved as JSON successfully.`);
|
|
109
120
|
open(getDownloadFolderPath());
|
|
@@ -116,13 +127,17 @@ function saveJSONasJSON(js0n, dataType) {
|
|
|
116
127
|
/**
|
|
117
128
|
* Export JSON as CSV
|
|
118
129
|
* @param js0n
|
|
119
|
-
* @param dataType (eg: anime
|
|
130
|
+
* @param dataType (eg: anime|manga)
|
|
120
131
|
*/
|
|
121
132
|
function saveJSONasCSV(js0n, dataType) {
|
|
122
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
123
134
|
try {
|
|
124
|
-
const
|
|
125
|
-
|
|
135
|
+
const js0n_WTAS = js0n.map((_a) => {
|
|
136
|
+
var { title } = _a, rest = __rest(_a, ["title"]);
|
|
137
|
+
return (Object.assign(Object.assign({}, rest), { title: getTitle(title) }));
|
|
138
|
+
});
|
|
139
|
+
const csvData = Papa.unparse(js0n_WTAS);
|
|
140
|
+
const path = yield saveToPath(dataType, ".csv");
|
|
126
141
|
yield writeFile(path, csvData, "utf8");
|
|
127
142
|
console.log(`\nSaved as CSV successfully.`);
|
|
128
143
|
open(getDownloadFolderPath());
|
|
@@ -132,6 +147,20 @@ function saveJSONasCSV(js0n, dataType) {
|
|
|
132
147
|
}
|
|
133
148
|
});
|
|
134
149
|
}
|
|
150
|
+
function saveJSONasXML(js0n, data_type) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
try {
|
|
153
|
+
const xmlContent = data_type === 0 ? createAnimeListXML(js0n) : createMangaListXML(js0n);
|
|
154
|
+
const path = yield saveToPath(data_type === 0 ? "anime" : "manga", ".xml");
|
|
155
|
+
yield writeFile(path, yield xmlContent, "utf8");
|
|
156
|
+
console.log(`\nGenerated XML for MyAnimeList.`);
|
|
157
|
+
open(getDownloadFolderPath());
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
console.error(`Error saving XML data:`, error);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
135
164
|
function listFilesInDownloadFolder() {
|
|
136
165
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
166
|
const downloadFolderPath = getDownloadFolderPath();
|
|
@@ -162,59 +191,60 @@ function selectFile(fileType) {
|
|
|
162
191
|
return answers.fileName;
|
|
163
192
|
}
|
|
164
193
|
else {
|
|
165
|
-
|
|
194
|
+
console.error(`\nNo importable ${fileType} file(s) found in download folder.`);
|
|
195
|
+
return null;
|
|
166
196
|
}
|
|
167
197
|
}
|
|
168
198
|
catch (error) {
|
|
169
199
|
console.error("\nError selecting file:", error);
|
|
170
|
-
|
|
200
|
+
return null;
|
|
171
201
|
}
|
|
172
202
|
});
|
|
173
203
|
}
|
|
174
|
-
function createAnimeXML(malId, progress, status, episodes, title) {
|
|
175
|
-
return `
|
|
176
|
-
<anime>
|
|
177
|
-
<series_animedb_id>${malId}</series_animedb_id>
|
|
178
|
-
<series_title><![CDATA[${title}]]></series_title>
|
|
179
|
-
<series_type
|
|
180
|
-
<series_episodes>${episodes}</series_episodes>
|
|
181
|
-
<my_id>0</my_id>
|
|
182
|
-
<my_watched_episodes>${progress}</my_watched_episodes>
|
|
183
|
-
<my_start_date>0000-00-00</my_start_date>
|
|
184
|
-
<my_finish_date>0000-00-00</my_finish_date>
|
|
185
|
-
<my_score>0</my_score>
|
|
186
|
-
<my_storage_value>0.00</my_storage_value>
|
|
187
|
-
<my_status>${status}</my_status>
|
|
188
|
-
<my_comments><![CDATA[]]></my_comments>
|
|
189
|
-
<my_times_watched>0</my_times_watched>
|
|
190
|
-
<my_rewatch_value></my_rewatch_value>
|
|
191
|
-
<my_priority>LOW</my_priority>
|
|
192
|
-
<my_tags><![CDATA[]]></my_tags>
|
|
193
|
-
<my_rewatching>0</my_rewatching>
|
|
194
|
-
<my_rewatching_ep>0</my_rewatching_ep>
|
|
195
|
-
<my_discuss>0</my_discuss>
|
|
196
|
-
<my_sns>default</my_sns>
|
|
197
|
-
<update_on_import>1</update_on_import>
|
|
204
|
+
function createAnimeXML(malId, progress, status, episodes, title, format) {
|
|
205
|
+
return `
|
|
206
|
+
<anime>
|
|
207
|
+
<series_animedb_id>${malId}</series_animedb_id>
|
|
208
|
+
<series_title><![CDATA[${title}]]></series_title>
|
|
209
|
+
<series_type>${format}</series_type>
|
|
210
|
+
<series_episodes>${episodes}</series_episodes>
|
|
211
|
+
<my_id>0</my_id>
|
|
212
|
+
<my_watched_episodes>${progress}</my_watched_episodes>
|
|
213
|
+
<my_start_date>0000-00-00</my_start_date>
|
|
214
|
+
<my_finish_date>0000-00-00</my_finish_date>
|
|
215
|
+
<my_score>0</my_score>
|
|
216
|
+
<my_storage_value>0.00</my_storage_value>
|
|
217
|
+
<my_status>${status}</my_status>
|
|
218
|
+
<my_comments><![CDATA[]]></my_comments>
|
|
219
|
+
<my_times_watched>0</my_times_watched>
|
|
220
|
+
<my_rewatch_value></my_rewatch_value>
|
|
221
|
+
<my_priority>LOW</my_priority>
|
|
222
|
+
<my_tags><![CDATA[]]></my_tags>
|
|
223
|
+
<my_rewatching>0</my_rewatching>
|
|
224
|
+
<my_rewatching_ep>0</my_rewatching_ep>
|
|
225
|
+
<my_discuss>0</my_discuss>
|
|
226
|
+
<my_sns>default</my_sns>
|
|
227
|
+
<update_on_import>1</update_on_import>
|
|
198
228
|
</anime>`;
|
|
199
229
|
}
|
|
200
230
|
function createMangaXML(malId, progress, status, chapters, title) {
|
|
201
|
-
return `
|
|
202
|
-
<manga>
|
|
203
|
-
<manga_mangadb_id>${malId}</manga_mangadb_id>
|
|
204
|
-
<manga_title><![CDATA[${title ? title : "unknown"}]]></manga_title>
|
|
205
|
-
<manga_volumes>0</manga_volumes>
|
|
206
|
-
<manga_chapters>${chapters ? chapters : 0}</manga_chapters>
|
|
207
|
-
<my_id>0</my_id>
|
|
208
|
-
<my_read_chapters>${progress}</my_read_chapters>
|
|
209
|
-
<my_start_date>0000-00-00</my_start_date>
|
|
210
|
-
<my_finish_date>0000-00-00</my_finish_date>
|
|
211
|
-
<my_score>0</my_score>
|
|
212
|
-
<my_status>${status}</my_status>
|
|
213
|
-
<my_reread_value></my_reread_value>
|
|
214
|
-
<my_priority>LOW</my_priority>
|
|
215
|
-
<my_rereading>0</my_rereading>
|
|
216
|
-
<my_discuss>0</my_discuss>
|
|
217
|
-
<update_on_import>1</update_on_import>
|
|
231
|
+
return `
|
|
232
|
+
<manga>
|
|
233
|
+
<manga_mangadb_id>${malId}</manga_mangadb_id>
|
|
234
|
+
<manga_title><![CDATA[${title ? title : "unknown"}]]></manga_title>
|
|
235
|
+
<manga_volumes>0</manga_volumes>
|
|
236
|
+
<manga_chapters>${chapters ? chapters : 0}</manga_chapters>
|
|
237
|
+
<my_id>0</my_id>
|
|
238
|
+
<my_read_chapters>${progress}</my_read_chapters>
|
|
239
|
+
<my_start_date>0000-00-00</my_start_date>
|
|
240
|
+
<my_finish_date>0000-00-00</my_finish_date>
|
|
241
|
+
<my_score>0</my_score>
|
|
242
|
+
<my_status>${status}</my_status>
|
|
243
|
+
<my_reread_value></my_reread_value>
|
|
244
|
+
<my_priority>LOW</my_priority>
|
|
245
|
+
<my_rereading>0</my_rereading>
|
|
246
|
+
<my_discuss>0</my_discuss>
|
|
247
|
+
<update_on_import>1</update_on_import>
|
|
218
248
|
</manga>`;
|
|
219
249
|
}
|
|
220
250
|
function createAnimeListXML(mediaWithProgress) {
|
|
@@ -226,27 +256,31 @@ function createAnimeListXML(mediaWithProgress) {
|
|
|
226
256
|
PAUSED: MALAnimeStatus.ON_HOLD,
|
|
227
257
|
DROPPED: MALAnimeStatus.DROPPED,
|
|
228
258
|
};
|
|
229
|
-
|
|
259
|
+
// Filter out anime without malId
|
|
260
|
+
const filteredMedia = mediaWithProgress.filter((anime) => anime.malId);
|
|
261
|
+
const xmlEntries = filteredMedia.map((anime) => {
|
|
262
|
+
console.log(anime);
|
|
230
263
|
const malId = anime.malId;
|
|
231
264
|
const progress = anime.progress;
|
|
232
265
|
const episodes = anime.episodes;
|
|
233
266
|
const title = getTitle(anime.title);
|
|
234
267
|
const status = statusMap[anime.status];
|
|
235
|
-
|
|
268
|
+
const format = anime.format ? anime.format : "";
|
|
269
|
+
return createAnimeXML(malId, progress, status, episodes, title, format);
|
|
236
270
|
});
|
|
237
|
-
return `<myanimelist>
|
|
238
|
-
<myinfo>
|
|
239
|
-
<user_id/>
|
|
240
|
-
<user_name>${yield Auth.MyUserName()}</user_name>
|
|
241
|
-
<user_export_type>1</user_export_type>
|
|
242
|
-
<user_total_anime>0</user_total_anime>
|
|
243
|
-
<user_total_watching>0</user_total_watching>
|
|
244
|
-
<user_total_completed>0</user_total_completed>
|
|
245
|
-
<user_total_onhold>0</user_total_onhold>
|
|
246
|
-
<user_total_dropped>0</user_total_dropped>
|
|
247
|
-
<user_total_plantowatch>0</user_total_plantowatch>
|
|
248
|
-
</myinfo>
|
|
249
|
-
\n${xmlEntries.join("\n")}\n
|
|
271
|
+
return `<myanimelist>
|
|
272
|
+
<myinfo>
|
|
273
|
+
<user_id/>
|
|
274
|
+
<user_name>${yield Auth.MyUserName()}</user_name>
|
|
275
|
+
<user_export_type>1</user_export_type>
|
|
276
|
+
<user_total_anime>0</user_total_anime>
|
|
277
|
+
<user_total_watching>0</user_total_watching>
|
|
278
|
+
<user_total_completed>0</user_total_completed>
|
|
279
|
+
<user_total_onhold>0</user_total_onhold>
|
|
280
|
+
<user_total_dropped>0</user_total_dropped>
|
|
281
|
+
<user_total_plantowatch>0</user_total_plantowatch>
|
|
282
|
+
</myinfo>
|
|
283
|
+
\n${xmlEntries.join("\n")}\n
|
|
250
284
|
</myanimelist>`;
|
|
251
285
|
});
|
|
252
286
|
}
|
|
@@ -259,7 +293,9 @@ function createMangaListXML(mediaWithProgress) {
|
|
|
259
293
|
PAUSED: MALMangaStatus.ON_HOLD,
|
|
260
294
|
DROPPED: MALMangaStatus.DROPPED,
|
|
261
295
|
};
|
|
262
|
-
|
|
296
|
+
// Filter out manga without malId
|
|
297
|
+
const filteredMedia = mediaWithProgress.filter((manga) => manga.malId);
|
|
298
|
+
const xmlEntries = filteredMedia.map((manga) => {
|
|
263
299
|
const malId = manga.malId;
|
|
264
300
|
const progress = manga.progress;
|
|
265
301
|
const chapters = manga.chapters;
|
|
@@ -267,19 +303,19 @@ function createMangaListXML(mediaWithProgress) {
|
|
|
267
303
|
const status = statusMap[manga.status];
|
|
268
304
|
return createMangaXML(malId, progress, status, chapters, title);
|
|
269
305
|
});
|
|
270
|
-
return `<myanimelist>
|
|
271
|
-
<myinfo>
|
|
272
|
-
<user_id/>
|
|
273
|
-
<user_name>${yield Auth.MyUserName()}</user_name>
|
|
274
|
-
<user_export_type>2</user_export_type>
|
|
275
|
-
<user_total_manga>5</user_total_manga>
|
|
276
|
-
<user_total_reading>1</user_total_reading>
|
|
277
|
-
<user_total_completed>1</user_total_completed>
|
|
278
|
-
<user_total_onhold>1</user_total_onhold>
|
|
279
|
-
<user_total_dropped>1</user_total_dropped>
|
|
280
|
-
<user_total_plantoread>1</user_total_plantoread>
|
|
281
|
-
</myinfo>
|
|
282
|
-
\n${xmlEntries.join("\n")}\n
|
|
306
|
+
return `<myanimelist>
|
|
307
|
+
<myinfo>
|
|
308
|
+
<user_id/>
|
|
309
|
+
<user_name>${yield Auth.MyUserName()}</user_name>
|
|
310
|
+
<user_export_type>2</user_export_type>
|
|
311
|
+
<user_total_manga>5</user_total_manga>
|
|
312
|
+
<user_total_reading>1</user_total_reading>
|
|
313
|
+
<user_total_completed>1</user_total_completed>
|
|
314
|
+
<user_total_onhold>1</user_total_onhold>
|
|
315
|
+
<user_total_dropped>1</user_total_dropped>
|
|
316
|
+
<user_total_plantoread>1</user_total_plantoread>
|
|
317
|
+
</myinfo>
|
|
318
|
+
\n${xmlEntries.join("\n")}\n
|
|
283
319
|
</myanimelist>`;
|
|
284
320
|
});
|
|
285
321
|
}
|
|
@@ -316,26 +352,6 @@ function timestampToTimeAgo(timestamp) {
|
|
|
316
352
|
return `${years} year${years === 1 ? "" : "s"} ago`;
|
|
317
353
|
}
|
|
318
354
|
}
|
|
319
|
-
function activityBy(activity) {
|
|
320
|
-
var _a, _b, _c, _d;
|
|
321
|
-
if ((_a = activity === null || activity === void 0 ? void 0 : activity.messenger) === null || _a === void 0 ? void 0 : _a.name) {
|
|
322
|
-
return `[${activity.id}]\t${activity.messenger.name} messaged ${activity.recipient.name}`;
|
|
323
|
-
}
|
|
324
|
-
else if ((_c = (_b = activity === null || activity === void 0 ? void 0 : activity.media) === null || _b === void 0 ? void 0 : _b.title) === null || _c === void 0 ? void 0 : _c.userPreferred) {
|
|
325
|
-
if (activity.progress) {
|
|
326
|
-
return `[${activity.id}]\t${activity.user.name} ${activity.status} ${activity.progress} of ${activity.media.title.userPreferred}`;
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
return `[${activity.id}]\t${activity.user.name} ${activity.status} ${activity.media.title.userPreferred}`;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
else if ((_d = activity === null || activity === void 0 ? void 0 : activity.user) === null || _d === void 0 ? void 0 : _d.name) {
|
|
333
|
-
return `[${activity.id}]\t${activity.user.name}`;
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
return `[${activity === null || activity === void 0 ? void 0 : activity.id}] ???`;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
355
|
const anidbToanilistMapper = (romanjiName, year, englishName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
340
356
|
const fetchAnime = (search) => __awaiter(void 0, void 0, void 0, function* () {
|
|
341
357
|
var _a;
|
|
@@ -365,4 +381,21 @@ const anidbToanilistMapper = (romanjiName, year, englishName) => __awaiter(void
|
|
|
365
381
|
}
|
|
366
382
|
return null;
|
|
367
383
|
});
|
|
368
|
-
|
|
384
|
+
/**
|
|
385
|
+
* Extract the save file path
|
|
386
|
+
* @param data_type - anime|manga
|
|
387
|
+
* @param file_format - save format (eg: .json|.csv)
|
|
388
|
+
* @returns string of file path
|
|
389
|
+
*/
|
|
390
|
+
function saveToPath(data_type, file_format) {
|
|
391
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
392
|
+
return join(getDownloadFolderPath(), `${yield Auth.MyUserName()}@irfanshadikrishad-anilist-${data_type}-${getFormattedDate()}.${file_format}`);
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
function simpleDateFormat(date) {
|
|
396
|
+
if (!date.day && !date.month && !date.year) {
|
|
397
|
+
return `null`;
|
|
398
|
+
}
|
|
399
|
+
return `${date === null || date === void 0 ? void 0 : date.day}/${date === null || date === void 0 ? void 0 : date.month}/${date === null || date === void 0 ? void 0 : date.year}`;
|
|
400
|
+
}
|
|
401
|
+
export { anidbToanilistMapper, aniListEndpoint, createAnimeListXML, createAnimeXML, createMangaListXML, createMangaXML, formatDateObject, getCurrentPackageVersion, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, saveJSONasXML, saveToPath, selectFile, simpleDateFormat, timestampToTimeAgo, };
|
package/bin/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
import { Command } from "commander";
|
|
12
12
|
import process from "process";
|
|
13
|
-
import { Auth } from "./helpers/auth.js";
|
|
13
|
+
import { Auth, Social } from "./helpers/auth.js";
|
|
14
14
|
import { AniList } from "./helpers/lists.js";
|
|
15
15
|
import { getCurrentPackageVersion } from "./helpers/workers.js";
|
|
16
16
|
const cli = new Command();
|
|
@@ -128,6 +128,13 @@ cli
|
|
|
128
128
|
console.error(`\nInvalid or missing ID (${id}). Please provide a valid numeric ID.`);
|
|
129
129
|
}
|
|
130
130
|
}));
|
|
131
|
+
cli
|
|
132
|
+
.command("manga <id>")
|
|
133
|
+
.description("Get manga details by their ID")
|
|
134
|
+
.option("-c, --count <number>", "Number of items to get", "10")
|
|
135
|
+
.action((id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
|
+
yield AniList.getMangaDetailsByID(id);
|
|
137
|
+
}));
|
|
131
138
|
cli
|
|
132
139
|
.command("search <query>")
|
|
133
140
|
.alias("srch")
|
|
@@ -204,10 +211,27 @@ cli
|
|
|
204
211
|
}
|
|
205
212
|
}));
|
|
206
213
|
cli
|
|
207
|
-
.command("
|
|
208
|
-
.alias("
|
|
209
|
-
.description("
|
|
210
|
-
.
|
|
211
|
-
|
|
214
|
+
.command("social")
|
|
215
|
+
.alias("sol")
|
|
216
|
+
.description("Automate your process")
|
|
217
|
+
.option("-f, --follow", "Follow the user whos following you.", false)
|
|
218
|
+
.option("-u, --unfollow", "Unfollow the user whos not following you.", false)
|
|
219
|
+
.action((_a) => __awaiter(void 0, [_a], void 0, function* ({ follow, unfollow }) {
|
|
220
|
+
if (!follow && !unfollow) {
|
|
221
|
+
console.error(`\nMust select an option, either --follow or --unfollow`);
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
if (yield Auth.isLoggedIn()) {
|
|
225
|
+
if (follow) {
|
|
226
|
+
yield Social.follow();
|
|
227
|
+
}
|
|
228
|
+
else if (unfollow) {
|
|
229
|
+
yield Social.unfollow();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
console.error(`\nPlease login to use this feature.`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
212
236
|
}));
|
|
213
237
|
cli.parse(process.argv);
|