mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-22 13:46:29 +01:00
Add mangacloud/mangacloud.js
This commit is contained in:
parent
868a4c2605
commit
7453e63d36
1 changed files with 92 additions and 0 deletions
92
mangacloud/mangacloud.js
Normal file
92
mangacloud/mangacloud.js
Normal file
|
|
@ -0,0 +1,92 @@
|
||||||
|
async function searchContent(keyword,page=0){
|
||||||
|
const results = [];
|
||||||
|
try {
|
||||||
|
const headers = {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36",
|
||||||
|
"Origin": "https://mangacloud.org",
|
||||||
|
"Referer": "https://mangacloud.org/",
|
||||||
|
"Accept": "application/json"
|
||||||
|
};
|
||||||
|
const postData = `{"terms":"${keyword}"}`;
|
||||||
|
|
||||||
|
const response = await fetch(`https://api.mangacloud.org/search`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: headers,
|
||||||
|
body: postData
|
||||||
|
});
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
for (const item of data.data) {
|
||||||
|
results.push({
|
||||||
|
id: item.id,
|
||||||
|
imageURL: `https://pika.mangacloud.org/${item.id}/${item.cover.id}.${item.cover.f}`,
|
||||||
|
title: item.title
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
} catch (err) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getContentData(ID) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`https://api.mangacloud.org/comic/${ID}`);
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
return {
|
||||||
|
description: data.data.description,
|
||||||
|
tags: data.data.tags.map(tag => tag.name)
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
return {
|
||||||
|
description: "Error",
|
||||||
|
tags: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getChapters(ID) {
|
||||||
|
const results = [];
|
||||||
|
try {
|
||||||
|
const response = await fetch(`https://api.mangacloud.org/comic/${ID}`);
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
const chapters = data.data.chapters;
|
||||||
|
for (const chap of chapters) {
|
||||||
|
results.push([
|
||||||
|
String(chap.number),
|
||||||
|
[{
|
||||||
|
id: ID + "/" + chap.id,
|
||||||
|
title: chap.name || `Chapter ${chap.number}`,
|
||||||
|
chapter: chap.number,
|
||||||
|
scanlation_group: chap.name || ""
|
||||||
|
}]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return { en: results.reverse() };
|
||||||
|
} catch (err) {
|
||||||
|
return { en: [] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getChapterImages(url) {
|
||||||
|
const chapterID = url.split("/").pop();
|
||||||
|
const ID = url.split("/").slice(-2, -1)[0];
|
||||||
|
const results = [];
|
||||||
|
try {
|
||||||
|
const response = await fetch(`https://api.mangacloud.org/chapter/${chapterID}`);
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
for (const img of data.data.images) {
|
||||||
|
results.push(`https://pika.mangacloud.org/${ID}/${chapterID}/${img.id}.${img.f}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
} catch (err) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue