Skip to content
This repository was archived by the owner on Mar 23, 2025. It is now read-only.

Commit e0cf022

Browse files
authored
Merge pull request #33 from MattTheHuman/master
Updated Manganelo plugin to Manganato and api version to 2
2 parents 4e28306 + 383c4c2 commit e0cf022

File tree

6 files changed

+147
-156
lines changed

6 files changed

+147
-156
lines changed

plugins/manganato/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Manganato Plugin
2+
3+
This is the Mango plugin for [Manganato](https://manganato.com/).
4+
5+
Note that
6+
7+
- All downloaded chapters will be placed in their respective series folder in your library.
8+
- Cloudflare rate limits extensive downloads. Adjust `wait_seconds` in `info.json` if you plan to download many chapters in one go (or chapters with many pages).
9+
- Manganelo seems to have changed name to Manganato.
10+
- Currently page count isn't supplied on the chapter list so gathering page count would require multiple calls and is expensive (code commented out).
11+
12+
Updated by [@MattTheHuman](https://github.com/MattTheHuman).
13+
14+
Thanks to [@TheBritishAccent](https://github.com/TheBritishAccent) for the base ideas.
15+
16+
Thanks to Alex Ling for the MangaDex v2 code as inspiration.

plugins/manganato/index.js

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
const SEARCH_URL = "https://manganato.com/search/story/";
2+
const MAIN_URL = "https://readmanganato.com/";
3+
const ALT_URL = "https://manganato.com/";
4+
5+
function searchManga(query) {
6+
const res = mango.get(SEARCH_URL + query.replace(" ", "_"));
7+
if (res.status_code !== 200)
8+
mango.raise('Failed to search for manga. Status ' + res.status_code);
9+
const manga = mango.css(res.body, "div.search-story-item");
10+
11+
return JSON.stringify(manga.map(function (m) {
12+
const ch = {
13+
id: mango.attribute(mango.css(m, "a.item-title")[0], "href").split("/").pop(),
14+
title: mango.text(mango.css(m, "a.item-title")[0]),
15+
cover_url: mango.attribute(mango.css(m, "img.img-loading")[0], "src")
16+
};
17+
return ch;
18+
}));
19+
}
20+
21+
function getManga(id) {
22+
var res = mango.get(MAIN_URL + id);
23+
if (res.status_code !== 200)
24+
res = mango.get(ALT_URL + id);
25+
if (res.status_code !== 200)
26+
mango.raise('Failed to get item from ' + MAIN_URL + ' & ' + ALT_URL + '.');
27+
return res;
28+
}
29+
30+
function listChapters(id) {
31+
const res = getManga(id);
32+
if (res.status_code !== 200)
33+
mango.raise('Failed to get chapters. Status ' + res.status_code);
34+
const mangaTitle = mango.text(mango.css(res.body, "div.story-info-right h1")[0]);
35+
const manga = mango.css(res.body, "div.panel-story-chapter-list li.a-h");
36+
37+
return JSON.stringify(manga.map(function (m) {
38+
//const chapter = getManga(id + '/' + mango.attribute(mango.css(m, "a.chapter-name")[0], "href").split("/").pop());
39+
//const pages = mango.css(chapter.body, "div.container-chapter-reader img");
40+
41+
const obj = {
42+
id: id + '/' + mango.attribute(mango.css(m, "a.chapter-name")[0], "href").split("/").pop(),
43+
title: mango.text(mango.css(m, "a.chapter-name")[0]),
44+
manga_title: mangaTitle,
45+
//pages: pages.length,
46+
pages: 0,
47+
chapter: mango.attribute(mango.css(m, "a.chapter-name")[0], "href").split("-").pop(),
48+
language: "en",
49+
group_id: id,
50+
published_at: Date.parse(parseTime(mango.css(m, "span.chapter-time")[0]))
51+
};
52+
return obj;
53+
}));
54+
}
55+
56+
function parseTime(time) {
57+
const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
58+
const date = mango.attribute(time, "title");
59+
const month = date.split(" ")[0];
60+
const day = date.split(" ")[1].split(",")[0];
61+
const year = date.split(" ")[1].split(",")[1];
62+
return year + "-" + months.indexOf(month) + "-" + day;
63+
}
64+
65+
function selectChapter(id) {
66+
var mangaId = id.split("/")[0].toString();
67+
const manga = getManga(mangaId);
68+
if (manga.status_code !== 200)
69+
mango.raise('Failed to get the manger.');
70+
const mangaTitle = mango.text(mango.css(manga.body, "div.story-info-right h1")[0]);
71+
const chapters = mango.css(manga.body, "div.panel-story-chapter-list li.a-h");
72+
73+
const chapter = getManga(id);
74+
if (chapter.status_code !== 200)
75+
mango.raise('Failed to get chapter. Status ' + res.status_code);
76+
const imageUrls = mango.css(chapter.body, "div.container-chapter-reader img").map(function (img) {
77+
return mango.attribute(img, "src");
78+
});
79+
mango.storage("manga-image-data", JSON.stringify(imageUrls));
80+
mango.storage("manga-title", mangaTitle);
81+
mango.storage("page", "0");
82+
83+
const obj = chapters.map(function (c) {
84+
return obj = {
85+
id: mangaId + "/" + mango.attribute(mango.css(c, "a.chapter-name")[0], "href").split("/").pop(),
86+
title: mangaTitle + " - " + mango.text(mango.css(c, "a.chapter-name")[0]),
87+
manga_title: mangaTitle,
88+
pages: imageUrls.length,
89+
chapter: id.split("-").pop(),
90+
language: "en",
91+
group_id: mangaId,
92+
published_at: Date.parse(parseTime(mango.css(c, "span.chapter-time")[0]))
93+
};
94+
});
95+
96+
return JSON.stringify(obj.filter(function (f) {
97+
return f.id == id;
98+
}).pop());
99+
}
100+
101+
function nextPage() {
102+
const page = parseInt(mango.storage("page"));
103+
const urls = JSON.parse(mango.storage("manga-image-data"));
104+
const filename = page + '.jpg';
105+
if (page >= urls.length) return JSON.stringify({});
106+
107+
const len = urls.length.toString().length;
108+
const pageNum = Array(Math.max(len - String(page + 1).length + 1, 0)).join(0) + (page + 1);
109+
const finalFilename = pageNum + '.' + filename.split('.').pop();
110+
mango.storage('page', (page + 1).toString());
111+
112+
return JSON.stringify({
113+
url: urls[page],
114+
filename: finalFilename,
115+
headers: {
116+
authority: 'v13.mkklcdnv6tempv4.com',
117+
accept: 'image/avif,image/webp,image/apng,image/svg+xml,image',
118+
pragma: 'no-cache',
119+
referer: 'https://readmanganato.com/'
120+
}
121+
});
122+
}

plugins/manganato/info.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"id": "Manganato",
3+
"title": "Manganato",
4+
"author": "MattTheHuman - [email protected]",
5+
"version": "v2.0",
6+
"placeholder": "Search Manganato",
7+
"wait_seconds": 5,
8+
"api_version": 2
9+
}

plugins/manganelo/README.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

plugins/manganelo/index.js

Lines changed: 0 additions & 138 deletions
This file was deleted.

plugins/manganelo/info.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)