@irfanshadikrishad/anilist 1.0.7 → 1.0.9
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 +23 -10
- package/bin/helpers/auth.js +597 -196
- package/bin/helpers/fetcher.js +3 -3
- package/bin/helpers/lists.d.ts +22 -8
- package/bin/helpers/lists.js +916 -538
- package/bin/helpers/mutations.d.ts +1 -1
- package/bin/helpers/mutations.js +1 -1
- package/bin/helpers/queries.d.ts +5 -3
- package/bin/helpers/queries.js +13 -3
- package/bin/helpers/types.d.ts +101 -1
- package/bin/helpers/types.js +26 -1
- package/bin/helpers/workers.d.ts +9 -3
- package/bin/helpers/workers.js +125 -99
- package/bin/index.js +24 -25
- package/package.json +7 -3
- package/CHANGELOG.md +0 -18
- package/CODE_OF_CONDUCT.md +0 -43
- package/CONTRIBUTING.md +0 -75
- package/bin/helpers/more.d.ts +0 -11
- package/bin/helpers/more.js +0 -474
|
@@ -4,4 +4,4 @@ declare const deleteActivityMutation = "\nmutation($id: Int!) {\n DeleteActivit
|
|
|
4
4
|
declare const saveTextActivityMutation = "\nmutation SaveTextActivity($status: String!) {\n SaveTextActivity(text: $status) { id text userId createdAt }\n}\n";
|
|
5
5
|
declare const saveAnimeWithProgressMutation = "\nmutation ($mediaId: Int, $progress: Int, $status: MediaListStatus, $hiddenFromStatusLists: Boolean) {\n SaveMediaListEntry(mediaId: $mediaId, progress: $progress, status: $status, hiddenFromStatusLists: $hiddenFromStatusLists) {\n id progress hiddenFromStatusLists\n }\n}\n";
|
|
6
6
|
declare const saveMangaWithProgressMutation = "\nmutation ($mediaId: Int, $progress: Int, $status: MediaListStatus, $hiddenFromStatusLists: Boolean, $private: Boolean) {\n SaveMediaListEntry( mediaId: $mediaId, progress: $progress, status: $status, hiddenFromStatusLists: $hiddenFromStatusLists, private: $private\n ) { id progress hiddenFromStatusLists private }\n}\n";
|
|
7
|
-
export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation,
|
|
7
|
+
export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, saveTextActivityMutation, };
|
package/bin/helpers/mutations.js
CHANGED
|
@@ -35,4 +35,4 @@ mutation ($mediaId: Int, $progress: Int, $status: MediaListStatus, $hiddenFromSt
|
|
|
35
35
|
) { id progress hiddenFromStatusLists private }
|
|
36
36
|
}
|
|
37
37
|
`;
|
|
38
|
-
export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation,
|
|
38
|
+
export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, saveTextActivityMutation, };
|
package/bin/helpers/queries.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ declare const currentUserQuery = "{\n Viewer {\n id name about bans siteUrl
|
|
|
2
2
|
declare const trendingQuery = "query ($page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n media(sort: TRENDING_DESC, type: ANIME) { id title { romaji english } }\n }\n}";
|
|
3
3
|
declare const popularQuery = "query ($page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n media(sort: POPULARITY_DESC, type: ANIME) { id title { romaji english } }\n }\n}";
|
|
4
4
|
declare const userQuery = "query ($username: String) {\n User(name: $username) {\n id name siteUrl donatorTier donatorBadge createdAt updatedAt previousNames { name createdAt updatedAt }\n isBlocked isFollower isFollowing options { profileColor timezone activityMergeTime }\n statistics { anime { count episodesWatched minutesWatched } manga { count chaptersRead volumesRead } }\n }\n}";
|
|
5
|
-
declare const currentUserAnimeList = "query ($id: Int) {\n MediaListCollection(userId: $id, type: ANIME) {\n lists { name entries { id progress hiddenFromStatusLists status media { id title { romaji english } status episodes siteUrl } } }\n }\n}\n";
|
|
6
|
-
declare const currentUserMangaList = "query ($id: Int) {\n MediaListCollection(userId: $id, type: MANGA) {\n lists { name entries { id progress hiddenFromStatusLists private status media { id title { romaji english } status chapters } } }\n }\n}\n";
|
|
5
|
+
declare const currentUserAnimeList = "query ($id: Int) {\n MediaListCollection(userId: $id, type: ANIME) {\n lists { name entries { id progress hiddenFromStatusLists status media { id idMal title { romaji english } status episodes siteUrl } } }\n }\n}\n";
|
|
6
|
+
declare const currentUserMangaList = "query ($id: Int) {\n MediaListCollection(userId: $id, type: MANGA) {\n lists { name entries { id progress hiddenFromStatusLists private status media { id idMal title { romaji english } status chapters } } }\n }\n}\n";
|
|
7
7
|
declare const deleteMediaEntryMutation = "mutation($id: Int!) {\n DeleteMediaListEntry(id: $id) { deleted }\n}";
|
|
8
8
|
declare const deleteMangaEntryMutation = "mutation($id: Int) {\n DeleteMediaListEntry(id: $id) { deleted }\n}";
|
|
9
9
|
declare const upcomingAnimesQuery = "query GetNextSeasonAnime($nextSeason: MediaSeason, $nextYear: Int, $perPage: Int) {\n Page(perPage: $perPage) {\n media(season: $nextSeason, seasonYear: $nextYear, type: ANIME, sort: POPULARITY_DESC) {\n id title { romaji english native userPreferred } season seasonYear startDate { year month day }\n episodes description genres\n }\n }\n}";
|
|
@@ -17,4 +17,6 @@ declare const activityMangaListQuery = "query ($userId: Int, $page: Int, $perPag
|
|
|
17
17
|
declare const activityMessageQuery = "query ($userId: Int, $page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(userId: $userId, type: MESSAGE, sort: ID_DESC) {\n ... on MessageActivity { id type message recipient { id name } createdAt }\n }\n }\n}";
|
|
18
18
|
declare const activityAllQuery = "query ($userId: Int, $page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(userId: $userId, sort: ID_DESC) {\n ... on TextActivity { id type text createdAt user { id name } }\n ... on ListActivity { id type status progress createdAt media { id title { romaji english native } } }\n ... on MessageActivity { id type message recipient { id name } createdAt }\n }\n }\n}";
|
|
19
19
|
declare const activityMediaList = "query ($userId: Int, $page: Int, $perPage: Int, $type: ActivityType) {\n Page(page: $page, perPage: $perPage) {\n pageInfo { total currentPage lastPage hasNextPage perPage }\n activities(userId: $userId, type: $type, sort: ID_DESC) {\n ... on ListActivity { id type status progress media { id title { romaji english native } format } createdAt }\n }\n }\n}";
|
|
20
|
-
|
|
20
|
+
declare const malIdToAnilistAnimeId = "query ($malId: Int) {\n Media(idMal: $malId, type: ANIME) {\n id title { romaji english } } \n}\n";
|
|
21
|
+
declare const malIdToAnilistMangaId = "query ($malId: Int) {\n Media(idMal: $malId, type: MANGA) {\n id title { romaji english } } \n}\n";
|
|
22
|
+
export { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, malIdToAnilistAnimeId, malIdToAnilistMangaId, mangaSearchQuery, popularQuery, trendingQuery, upcomingAnimesQuery, userActivityQuery, userQuery, };
|
package/bin/helpers/queries.js
CHANGED
|
@@ -26,13 +26,13 @@ const userQuery = `query ($username: String) {
|
|
|
26
26
|
}`;
|
|
27
27
|
const currentUserAnimeList = `query ($id: Int) {
|
|
28
28
|
MediaListCollection(userId: $id, type: ANIME) {
|
|
29
|
-
lists { name entries { id progress hiddenFromStatusLists status media { id title { romaji english } status episodes siteUrl } } }
|
|
29
|
+
lists { name entries { id progress hiddenFromStatusLists status media { id idMal title { romaji english } status episodes siteUrl } } }
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
`;
|
|
33
33
|
const currentUserMangaList = `query ($id: Int) {
|
|
34
34
|
MediaListCollection(userId: $id, type: MANGA) {
|
|
35
|
-
lists { name entries { id progress hiddenFromStatusLists private status media { id title { romaji english } status chapters } } }
|
|
35
|
+
lists { name entries { id progress hiddenFromStatusLists private status media { id idMal title { romaji english } status chapters } } }
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
`;
|
|
@@ -119,4 +119,14 @@ const activityMediaList = `query ($userId: Int, $page: Int, $perPage: Int, $type
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
}`;
|
|
122
|
-
|
|
122
|
+
const malIdToAnilistAnimeId = `query ($malId: Int) {
|
|
123
|
+
Media(idMal: $malId, type: ANIME) {
|
|
124
|
+
id title { romaji english } }
|
|
125
|
+
}
|
|
126
|
+
`;
|
|
127
|
+
const malIdToAnilistMangaId = `query ($malId: Int) {
|
|
128
|
+
Media(idMal: $malId, type: MANGA) {
|
|
129
|
+
id title { romaji english } }
|
|
130
|
+
}
|
|
131
|
+
`;
|
|
132
|
+
export { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, currentUserQuery, deleteMangaEntryMutation, deleteMediaEntryMutation, malIdToAnilistAnimeId, malIdToAnilistMangaId, mangaSearchQuery, popularQuery, trendingQuery, upcomingAnimesQuery, userActivityQuery, userQuery, };
|
package/bin/helpers/types.d.ts
CHANGED
|
@@ -8,4 +8,104 @@ interface DeleteMangaResponse {
|
|
|
8
8
|
message: string;
|
|
9
9
|
}[];
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
declare enum AniListMediaStatus {
|
|
12
|
+
CURRENT = "CURRENT",
|
|
13
|
+
PLANNING = "PLANNING",
|
|
14
|
+
COMPLETED = "COMPLETED",
|
|
15
|
+
DROPPED = "DROPPED",
|
|
16
|
+
PAUSED = "PAUSED",
|
|
17
|
+
REPEATING = "REPEATING"
|
|
18
|
+
}
|
|
19
|
+
interface MALAnimeXML {
|
|
20
|
+
series_animedb_id: number;
|
|
21
|
+
series_title: string;
|
|
22
|
+
series_type: string;
|
|
23
|
+
series_episodes: number;
|
|
24
|
+
my_id: number;
|
|
25
|
+
my_watched_episodes: number;
|
|
26
|
+
my_start_date: string;
|
|
27
|
+
my_finish_date: string;
|
|
28
|
+
my_rated: string;
|
|
29
|
+
my_score: number;
|
|
30
|
+
my_storage: string;
|
|
31
|
+
my_storage_value: number;
|
|
32
|
+
my_status: string;
|
|
33
|
+
my_comments: string;
|
|
34
|
+
my_times_watched: number;
|
|
35
|
+
my_rewatch_value: string;
|
|
36
|
+
my_priority: string;
|
|
37
|
+
my_tags: string;
|
|
38
|
+
my_rewatching: number;
|
|
39
|
+
my_rewatching_ep: number;
|
|
40
|
+
my_discuss: number;
|
|
41
|
+
my_sns: string;
|
|
42
|
+
update_on_import: number;
|
|
43
|
+
}
|
|
44
|
+
interface MalIdToAnilistIdResponse {
|
|
45
|
+
data?: {
|
|
46
|
+
Media: {
|
|
47
|
+
id: number;
|
|
48
|
+
title: {
|
|
49
|
+
english?: string;
|
|
50
|
+
romaji?: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
errors?: {
|
|
55
|
+
message: string;
|
|
56
|
+
}[];
|
|
57
|
+
}
|
|
58
|
+
interface saveAnimeWithProgressResponse {
|
|
59
|
+
data?: {
|
|
60
|
+
SaveMediaListEntry: {
|
|
61
|
+
id: number;
|
|
62
|
+
progress: number;
|
|
63
|
+
hiddenFromStatusLists: boolean;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
errors?: {
|
|
67
|
+
message: string;
|
|
68
|
+
}[];
|
|
69
|
+
}
|
|
70
|
+
declare enum MALAnimeStatus {
|
|
71
|
+
ON_HOLD = "On-Hold",
|
|
72
|
+
DROPPED = "Dropped",
|
|
73
|
+
COMPLETED = "Completed",
|
|
74
|
+
WATCHING = "Watching",
|
|
75
|
+
PLAN_TO_WATCH = "Plan to Watch"
|
|
76
|
+
}
|
|
77
|
+
declare enum MALMangaStatus {
|
|
78
|
+
ON_HOLD = "On-Hold",
|
|
79
|
+
DROPPED = "Dropped",
|
|
80
|
+
COMPLETED = "Completed",
|
|
81
|
+
READING = "Reading",
|
|
82
|
+
PLAN_TO_READ = "Plan to Read"
|
|
83
|
+
}
|
|
84
|
+
interface AnimeList {
|
|
85
|
+
data?: {
|
|
86
|
+
MediaListCollection: {
|
|
87
|
+
lists: {
|
|
88
|
+
name: string;
|
|
89
|
+
entries: {
|
|
90
|
+
id: number;
|
|
91
|
+
progress: number;
|
|
92
|
+
}[];
|
|
93
|
+
}[];
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
errors?: {
|
|
97
|
+
message: string;
|
|
98
|
+
}[];
|
|
99
|
+
}
|
|
100
|
+
interface MediaWithProgress {
|
|
101
|
+
malId: number;
|
|
102
|
+
progress: number;
|
|
103
|
+
status: string;
|
|
104
|
+
episodes?: number;
|
|
105
|
+
chapters?: number;
|
|
106
|
+
title: {
|
|
107
|
+
english?: string;
|
|
108
|
+
romaji?: string;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export { AniListMediaStatus, AnimeList, DeleteMangaResponse, MALAnimeStatus, MALAnimeXML, MALMangaStatus, MalIdToAnilistIdResponse, MediaWithProgress, saveAnimeWithProgressResponse, };
|
package/bin/helpers/types.js
CHANGED
|
@@ -1 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
var AniListMediaStatus;
|
|
2
|
+
(function (AniListMediaStatus) {
|
|
3
|
+
AniListMediaStatus["CURRENT"] = "CURRENT";
|
|
4
|
+
AniListMediaStatus["PLANNING"] = "PLANNING";
|
|
5
|
+
AniListMediaStatus["COMPLETED"] = "COMPLETED";
|
|
6
|
+
AniListMediaStatus["DROPPED"] = "DROPPED";
|
|
7
|
+
AniListMediaStatus["PAUSED"] = "PAUSED";
|
|
8
|
+
AniListMediaStatus["REPEATING"] = "REPEATING";
|
|
9
|
+
})(AniListMediaStatus || (AniListMediaStatus = {}));
|
|
10
|
+
var MALAnimeStatus;
|
|
11
|
+
(function (MALAnimeStatus) {
|
|
12
|
+
MALAnimeStatus["ON_HOLD"] = "On-Hold";
|
|
13
|
+
MALAnimeStatus["DROPPED"] = "Dropped";
|
|
14
|
+
MALAnimeStatus["COMPLETED"] = "Completed";
|
|
15
|
+
MALAnimeStatus["WATCHING"] = "Watching";
|
|
16
|
+
MALAnimeStatus["PLAN_TO_WATCH"] = "Plan to Watch";
|
|
17
|
+
})(MALAnimeStatus || (MALAnimeStatus = {}));
|
|
18
|
+
var MALMangaStatus;
|
|
19
|
+
(function (MALMangaStatus) {
|
|
20
|
+
MALMangaStatus["ON_HOLD"] = "On-Hold";
|
|
21
|
+
MALMangaStatus["DROPPED"] = "Dropped";
|
|
22
|
+
MALMangaStatus["COMPLETED"] = "Completed";
|
|
23
|
+
MALMangaStatus["READING"] = "Reading";
|
|
24
|
+
MALMangaStatus["PLAN_TO_READ"] = "Plan to Read";
|
|
25
|
+
})(MALMangaStatus || (MALMangaStatus = {}));
|
|
26
|
+
export { AniListMediaStatus, MALAnimeStatus, MALMangaStatus, };
|
package/bin/helpers/workers.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MALAnimeStatus, MALMangaStatus, MediaWithProgress } from "./types.js";
|
|
1
2
|
declare const aniListEndpoint = "https://graphql.anilist.co";
|
|
2
3
|
declare const redirectUri = "https://anilist.co/api/v2/oauth/pin";
|
|
3
4
|
declare function getTitle(title: {
|
|
@@ -14,6 +15,8 @@ declare function getNextSeasonAndYear(): {
|
|
|
14
15
|
nextYear: number;
|
|
15
16
|
};
|
|
16
17
|
declare function removeHtmlAndMarkdown(input: string): string;
|
|
18
|
+
declare function getDownloadFolderPath(): string;
|
|
19
|
+
declare function getFormattedDate(): string;
|
|
17
20
|
/**
|
|
18
21
|
* Export JSON as JSON
|
|
19
22
|
* @param js0n
|
|
@@ -26,6 +29,9 @@ declare function saveJSONasJSON(js0n: object, dataType: string): Promise<void>;
|
|
|
26
29
|
* @param dataType (eg: anime/manga)
|
|
27
30
|
*/
|
|
28
31
|
declare function saveJSONasCSV(js0n: object, dataType: string): Promise<void>;
|
|
29
|
-
declare function
|
|
30
|
-
declare function
|
|
31
|
-
|
|
32
|
+
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 createMangaXML(malId: number, progress: number, status: MALMangaStatus, chapters: number, title: string): string;
|
|
35
|
+
declare function createAnimeListXML(mediaWithProgress: MediaWithProgress[]): Promise<string>;
|
|
36
|
+
declare function createMangaListXML(mediaWithProgress: MediaWithProgress[]): Promise<string>;
|
|
37
|
+
export { aniListEndpoint, createAnimeListXML, createAnimeXML, createMangaListXML, createMangaXML, formatDateObject, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, selectFile, };
|
package/bin/helpers/workers.js
CHANGED
|
@@ -7,16 +7,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import fs from "fs";
|
|
11
|
+
import { readdir, writeFile } from "fs/promises";
|
|
10
12
|
import inquirer from "inquirer";
|
|
13
|
+
import { parse } from "json2csv";
|
|
11
14
|
import open from "open";
|
|
12
|
-
import { join } from "path";
|
|
13
15
|
import { homedir } from "os";
|
|
16
|
+
import { join } from "path";
|
|
14
17
|
import process from "process";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { currentUsersName } from "./auth.js";
|
|
18
|
-
import { saveAnimeWithProgressMutation, saveMangaWithProgressMutation, } from "./mutations.js";
|
|
19
|
-
import { fetcher } from "./fetcher.js";
|
|
18
|
+
import { Auth } from "./auth.js";
|
|
19
|
+
import { MALAnimeStatus, MALMangaStatus } from "./types.js";
|
|
20
20
|
const aniListEndpoint = `https://graphql.anilist.co`;
|
|
21
21
|
const redirectUri = "https://anilist.co/api/v2/oauth/pin";
|
|
22
22
|
function getTitle(title) {
|
|
@@ -100,7 +100,7 @@ function saveJSONasJSON(js0n, dataType) {
|
|
|
100
100
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
101
|
try {
|
|
102
102
|
const jsonData = JSON.stringify(js0n, null, 2);
|
|
103
|
-
const path = join(getDownloadFolderPath(), `${yield
|
|
103
|
+
const path = join(getDownloadFolderPath(), `${yield Auth.MyUserName()}@irfanshadikrishad-anilist-${dataType}-${getFormattedDate()}.json`);
|
|
104
104
|
yield writeFile(path, jsonData, "utf8");
|
|
105
105
|
console.log(`\nSaved as JSON successfully.`);
|
|
106
106
|
open(getDownloadFolderPath());
|
|
@@ -119,7 +119,7 @@ function saveJSONasCSV(js0n, dataType) {
|
|
|
119
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
120
|
try {
|
|
121
121
|
const csvData = parse(js0n);
|
|
122
|
-
const path = join(getDownloadFolderPath(), `${yield
|
|
122
|
+
const path = join(getDownloadFolderPath(), `${yield Auth.MyUserName()}@irfanshadikrishad-anilist-${dataType}-${getFormattedDate()}.csv`);
|
|
123
123
|
yield writeFile(path, csvData, "utf8");
|
|
124
124
|
console.log(`\nSaved as CSV successfully.`);
|
|
125
125
|
open(getDownloadFolderPath());
|
|
@@ -136,24 +136,29 @@ function listFilesInDownloadFolder() {
|
|
|
136
136
|
return files;
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
-
function selectFile() {
|
|
139
|
+
function selectFile(fileType) {
|
|
140
140
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
141
|
try {
|
|
142
142
|
const files = yield listFilesInDownloadFolder();
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
// Filter to include only files, not directories, with the specified extension
|
|
144
|
+
const onlyFiles = files.filter((file) => {
|
|
145
|
+
const filePath = `./downloads/${file}`; // Adjust this to the correct path
|
|
146
|
+
const isFile = fs.lstatSync(filePath).isFile(); // Check if it's a file
|
|
147
|
+
return isFile && file.endsWith(fileType);
|
|
148
|
+
});
|
|
149
|
+
if (onlyFiles.length > 0) {
|
|
145
150
|
const answers = yield inquirer.prompt([
|
|
146
151
|
{
|
|
147
152
|
type: "list",
|
|
148
153
|
name: "fileName",
|
|
149
154
|
message: "Select a file to import:",
|
|
150
|
-
choices:
|
|
155
|
+
choices: onlyFiles,
|
|
151
156
|
},
|
|
152
157
|
]);
|
|
153
158
|
return answers.fileName;
|
|
154
159
|
}
|
|
155
160
|
else {
|
|
156
|
-
throw new Error(`\nNo importable
|
|
161
|
+
throw new Error(`\nNo importable ${fileType} file(s) found in download folder.`);
|
|
157
162
|
}
|
|
158
163
|
}
|
|
159
164
|
catch (error) {
|
|
@@ -162,95 +167,116 @@ function selectFile() {
|
|
|
162
167
|
}
|
|
163
168
|
});
|
|
164
169
|
}
|
|
165
|
-
function
|
|
170
|
+
function createAnimeXML(malId, progress, status, episodes, title) {
|
|
171
|
+
return `
|
|
172
|
+
<anime>
|
|
173
|
+
<series_animedb_id>${malId}</series_animedb_id>
|
|
174
|
+
<series_title><![CDATA[${title}]]></series_title>
|
|
175
|
+
<series_type>""</series_type>
|
|
176
|
+
<series_episodes>${episodes}</series_episodes>
|
|
177
|
+
<my_id>0</my_id>
|
|
178
|
+
<my_watched_episodes>${progress}</my_watched_episodes>
|
|
179
|
+
<my_start_date>0000-00-00</my_start_date>
|
|
180
|
+
<my_finish_date>0000-00-00</my_finish_date>
|
|
181
|
+
<my_score>0</my_score>
|
|
182
|
+
<my_storage_value>0.00</my_storage_value>
|
|
183
|
+
<my_status>${status}</my_status>
|
|
184
|
+
<my_comments><![CDATA[]]></my_comments>
|
|
185
|
+
<my_times_watched>0</my_times_watched>
|
|
186
|
+
<my_rewatch_value></my_rewatch_value>
|
|
187
|
+
<my_priority>LOW</my_priority>
|
|
188
|
+
<my_tags><![CDATA[]]></my_tags>
|
|
189
|
+
<my_rewatching>0</my_rewatching>
|
|
190
|
+
<my_rewatching_ep>0</my_rewatching_ep>
|
|
191
|
+
<my_discuss>0</my_discuss>
|
|
192
|
+
<my_sns>default</my_sns>
|
|
193
|
+
<update_on_import>1</update_on_import>
|
|
194
|
+
</anime>`;
|
|
195
|
+
}
|
|
196
|
+
function createMangaXML(malId, progress, status, chapters, title) {
|
|
197
|
+
return `
|
|
198
|
+
<manga>
|
|
199
|
+
<manga_mangadb_id>${malId}</manga_mangadb_id>
|
|
200
|
+
<manga_title><![CDATA[${title ? title : "unknown"}]]></manga_title>
|
|
201
|
+
<manga_volumes>0</manga_volumes>
|
|
202
|
+
<manga_chapters>${chapters ? chapters : 0}</manga_chapters>
|
|
203
|
+
<my_id>0</my_id>
|
|
204
|
+
<my_read_chapters>${progress}</my_read_chapters>
|
|
205
|
+
<my_start_date>0000-00-00</my_start_date>
|
|
206
|
+
<my_finish_date>0000-00-00</my_finish_date>
|
|
207
|
+
<my_score>0</my_score>
|
|
208
|
+
<my_status>${status}</my_status>
|
|
209
|
+
<my_reread_value></my_reread_value>
|
|
210
|
+
<my_priority>LOW</my_priority>
|
|
211
|
+
<my_rereading>0</my_rereading>
|
|
212
|
+
<my_discuss>0</my_discuss>
|
|
213
|
+
<update_on_import>1</update_on_import>
|
|
214
|
+
</manga>`;
|
|
215
|
+
}
|
|
216
|
+
function createAnimeListXML(mediaWithProgress) {
|
|
166
217
|
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
catch (error) {
|
|
198
|
-
console.error(`\nError saving ${anime === null || anime === void 0 ? void 0 : anime.id}: ${error.message}`);
|
|
199
|
-
}
|
|
200
|
-
})));
|
|
201
|
-
// Avoid rate-limiting: Wait before sending the next batch
|
|
202
|
-
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
203
|
-
}
|
|
204
|
-
console.log(`\nTotal ${count} anime(s) imported successfully.`);
|
|
205
|
-
}
|
|
206
|
-
catch (error) {
|
|
207
|
-
console.error(`\n${error.message}`);
|
|
208
|
-
}
|
|
218
|
+
const statusMap = {
|
|
219
|
+
PLANNING: MALAnimeStatus.PLAN_TO_WATCH,
|
|
220
|
+
COMPLETED: MALAnimeStatus.COMPLETED,
|
|
221
|
+
CURRENT: MALAnimeStatus.WATCHING,
|
|
222
|
+
PAUSED: MALAnimeStatus.ON_HOLD,
|
|
223
|
+
DROPPED: MALAnimeStatus.DROPPED,
|
|
224
|
+
};
|
|
225
|
+
const xmlEntries = mediaWithProgress.map((anime) => {
|
|
226
|
+
const malId = anime.malId;
|
|
227
|
+
const progress = anime.progress;
|
|
228
|
+
const episodes = anime.episodes;
|
|
229
|
+
const title = getTitle(anime.title);
|
|
230
|
+
const status = statusMap[anime.status];
|
|
231
|
+
return createAnimeXML(malId, progress, status, episodes, title);
|
|
232
|
+
});
|
|
233
|
+
return `<myanimelist>
|
|
234
|
+
<myinfo>
|
|
235
|
+
<user_id/>
|
|
236
|
+
<user_name>${yield Auth.MyUserName()}</user_name>
|
|
237
|
+
<user_export_type>1</user_export_type>
|
|
238
|
+
<user_total_anime>0</user_total_anime>
|
|
239
|
+
<user_total_watching>0</user_total_watching>
|
|
240
|
+
<user_total_completed>0</user_total_completed>
|
|
241
|
+
<user_total_onhold>0</user_total_onhold>
|
|
242
|
+
<user_total_dropped>0</user_total_dropped>
|
|
243
|
+
<user_total_plantowatch>0</user_total_plantowatch>
|
|
244
|
+
</myinfo>
|
|
245
|
+
\n${xmlEntries.join("\n")}\n
|
|
246
|
+
</myanimelist>`;
|
|
209
247
|
});
|
|
210
248
|
}
|
|
211
|
-
function
|
|
249
|
+
function createMangaListXML(mediaWithProgress) {
|
|
212
250
|
return __awaiter(this, void 0, void 0, function* () {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
catch (err) {
|
|
243
|
-
console.error(`\nError saving ${manga === null || manga === void 0 ? void 0 : manga.id}: ${err.message}`);
|
|
244
|
-
}
|
|
245
|
-
})));
|
|
246
|
-
// Avoid rate-limit by adding delay after processing each batch
|
|
247
|
-
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
248
|
-
}
|
|
249
|
-
console.log(`\nTotal ${count} manga(s) imported successfully.`);
|
|
250
|
-
}
|
|
251
|
-
catch (error) {
|
|
252
|
-
console.error(`\nError: ${error.message}`);
|
|
253
|
-
}
|
|
251
|
+
const statusMap = {
|
|
252
|
+
PLANNING: MALMangaStatus.PLAN_TO_READ,
|
|
253
|
+
COMPLETED: MALMangaStatus.COMPLETED,
|
|
254
|
+
CURRENT: MALMangaStatus.READING,
|
|
255
|
+
PAUSED: MALMangaStatus.ON_HOLD,
|
|
256
|
+
DROPPED: MALMangaStatus.DROPPED,
|
|
257
|
+
};
|
|
258
|
+
const xmlEntries = mediaWithProgress.map((manga) => {
|
|
259
|
+
const malId = manga.malId;
|
|
260
|
+
const progress = manga.progress;
|
|
261
|
+
const chapters = manga.chapters;
|
|
262
|
+
const title = getTitle(manga.title);
|
|
263
|
+
const status = statusMap[manga.status];
|
|
264
|
+
return createMangaXML(malId, progress, status, chapters, title);
|
|
265
|
+
});
|
|
266
|
+
return `<myanimelist>
|
|
267
|
+
<myinfo>
|
|
268
|
+
<user_id/>
|
|
269
|
+
<user_name>${yield Auth.MyUserName()}</user_name>
|
|
270
|
+
<user_export_type>2</user_export_type>
|
|
271
|
+
<user_total_manga>5</user_total_manga>
|
|
272
|
+
<user_total_reading>1</user_total_reading>
|
|
273
|
+
<user_total_completed>1</user_total_completed>
|
|
274
|
+
<user_total_onhold>1</user_total_onhold>
|
|
275
|
+
<user_total_dropped>1</user_total_dropped>
|
|
276
|
+
<user_total_plantoread>1</user_total_plantoread>
|
|
277
|
+
</myinfo>
|
|
278
|
+
\n${xmlEntries.join("\n")}\n
|
|
279
|
+
</myanimelist>`;
|
|
254
280
|
});
|
|
255
281
|
}
|
|
256
|
-
export { aniListEndpoint,
|
|
282
|
+
export { aniListEndpoint, createAnimeListXML, createAnimeXML, createMangaListXML, createMangaXML, formatDateObject, getDownloadFolderPath, getFormattedDate, getNextSeasonAndYear, getTitle, redirectUri, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, selectFile, };
|