mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-22 05:36:32 +01:00
Add mangabuddy/mangabuddy.js
This commit is contained in:
parent
6d914aa202
commit
934a52eab8
1 changed files with 100 additions and 0 deletions
100
mangabuddy/mangabuddy.js
Normal file
100
mangabuddy/mangabuddy.js
Normal file
|
|
@ -0,0 +1,100 @@
|
||||||
|
async function searchContent(keyword, page=0) {
|
||||||
|
const results = [];
|
||||||
|
try {
|
||||||
|
const response = await fetch("https://mangabuddy.com/api/manga/search?q=" + encodeURIComponent(keyword));
|
||||||
|
const html = await response.text();
|
||||||
|
|
||||||
|
const regex = /href="([^"]*)"[^>]*>[\s\S]*?<img src="([^"]*)"[\s\S]*?<h3><a[^>]*>([\s\S]*?)<\/a><\/h3>/g;
|
||||||
|
|
||||||
|
let match;
|
||||||
|
while ((match = regex.exec(html)) !== null) {
|
||||||
|
results.push({
|
||||||
|
id: "https://mangabuddy.com" + match[1].trim(),
|
||||||
|
imageURL: match[2].trim(),
|
||||||
|
title: match[3].replace(/<[^>]+>/g, '').trim()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
} catch (err) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getContentData(url) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(url);
|
||||||
|
const html = await response.text();
|
||||||
|
|
||||||
|
const descRegex = /<meta name="description" content="([^"]+)"/i;
|
||||||
|
const descMatch = descRegex.exec(html);
|
||||||
|
const description = descMatch ? descMatch[1].trim() : "";
|
||||||
|
return {
|
||||||
|
description: description.replace(" - not found...", "").trim(),
|
||||||
|
tags: []
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
return {
|
||||||
|
description: "Error",
|
||||||
|
tags: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getChapters(url) {
|
||||||
|
const results = [];
|
||||||
|
try {
|
||||||
|
const response = await fetch(url);
|
||||||
|
const html = await response.text();
|
||||||
|
const idRegex = /var bookId = (\d+);/;
|
||||||
|
const idMatch = idRegex.exec(html);
|
||||||
|
if (!idMatch) return { en: [] };
|
||||||
|
const manga_id = idMatch[1];
|
||||||
|
|
||||||
|
const chapUrl = `https://mangabuddy.com/api/manga/${manga_id}/chapters?source=detail`;
|
||||||
|
const chapResponse = await fetch(chapUrl);
|
||||||
|
const chapHtml = await chapResponse.text();
|
||||||
|
|
||||||
|
const regex = /<li id="c-\d+">\s*<a href="([^"]*)"[^>]*>\s*<div>\s*<strong class="chapter-title">Chapter (\d+)<\/strong>/g;
|
||||||
|
|
||||||
|
let match;
|
||||||
|
|
||||||
|
while ((match = regex.exec(chapHtml)) !== null) {
|
||||||
|
const chapterUrl = "https://mangabuddy.com" + match[1];
|
||||||
|
const chapterNum = match[2];
|
||||||
|
results.push([
|
||||||
|
String(chapterNum),
|
||||||
|
[{
|
||||||
|
id: chapterUrl,
|
||||||
|
chapter: parseInt(chapterNum),
|
||||||
|
scanlation_group: `Chapter ${chapterNum}`
|
||||||
|
}]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
results.reverse();
|
||||||
|
|
||||||
|
return { en: results };
|
||||||
|
} catch (err) {
|
||||||
|
return { en: [] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getChapterImages(url) {
|
||||||
|
const results = [];
|
||||||
|
try {
|
||||||
|
const response = await fetch(url);
|
||||||
|
const html = await response.text();
|
||||||
|
const regex = /var chapImages = '([^']*)'/;
|
||||||
|
const match = regex.exec(html);
|
||||||
|
if (match) {
|
||||||
|
const imagesString = match[1];
|
||||||
|
const images = imagesString.split(',');
|
||||||
|
results.push(...images);
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
} catch (err) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue