mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-21 21:26:19 +01:00
Update mangafire/mangafire.js
This commit is contained in:
parent
f44e29009c
commit
f004a1ff3a
1 changed files with 56 additions and 42 deletions
|
|
@ -25,30 +25,44 @@ async function getContentData(url) {
|
|||
const genreRegex = /<a href="\/genre\/[^"]*">([^<]+)<\/a>/g;
|
||||
const tags = [];
|
||||
let match;
|
||||
|
||||
|
||||
while ((match = genreRegex.exec(htmlContent)) !== null) {
|
||||
tags.push(match[1]);
|
||||
if (match[1].trim()) tags.push(match[1].trim());
|
||||
}
|
||||
|
||||
|
||||
const uniqueTags = [...new Set(tags)];
|
||||
|
||||
const ogDescriptionRegex = /<meta property="og:description" content="([^"]*)"/;
|
||||
const ogDescriptionMatch = htmlContent.match(ogDescriptionRegex);
|
||||
let description = ogDescriptionMatch ? ogDescriptionMatch[1] : "";
|
||||
|
||||
|
||||
const ogDescriptionRegex =
|
||||
/<meta property="og:description" content=['"]([^'"]*)['"]/i;
|
||||
const ogMatch = htmlContent.match(ogDescriptionRegex);
|
||||
|
||||
let description = ogMatch ? ogMatch[1] : "";
|
||||
|
||||
if (!description) {
|
||||
const metaDescriptionRegex = /<meta name="description" content="([^"]*)"/;
|
||||
const metaMatch = htmlContent.match(metaDescriptionRegex);
|
||||
description = metaMatch ? metaMatch[1] : "";
|
||||
const metaDescriptionRegex =
|
||||
/<meta name="description" content=['"]([^'"]*)['"]/i;
|
||||
const metaMatch = htmlContent.match(metaDescriptionRegex);
|
||||
description = metaMatch ? metaMatch[1] : "";
|
||||
}
|
||||
|
||||
description = description.replace(/READ NOW!!\s*$/, "").trim();
|
||||
|
||||
|
||||
description = description
|
||||
.replace(/(")/g, '"')
|
||||
.replace(/(&)/g, '&')
|
||||
.replace(/(<)/g, '<')
|
||||
.replace(/(>)/g, '>')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
|
||||
if (uniqueTags.length === 0) {
|
||||
uniqueTags.push("Unknown");
|
||||
}
|
||||
|
||||
return {
|
||||
tags: uniqueTags,
|
||||
description: description
|
||||
description: description,
|
||||
tags: uniqueTags
|
||||
};
|
||||
}
|
||||
|
||||
const response = await fetch(`https://mangafire.to${url}`);
|
||||
const data = await response.text();
|
||||
console.log(JSON.stringify(parseHtmlData(data)));
|
||||
|
|
@ -65,38 +79,38 @@ async function getChapters(url) {
|
|||
return null;
|
||||
}
|
||||
|
||||
function parseChapters(htmlContent) {
|
||||
function parseChapters(htmlContent) {
|
||||
const chapters = {};
|
||||
|
||||
const chapterRegex = /<a href="\/read\/[^"]+\/([^/]+)\/chapter-[^"]*" data-number="([^"]+)" data-id="([^"]+)"[^>]*>([^<]+)<\/a>/g;
|
||||
|
||||
|
||||
const chapterRegex =
|
||||
/<a href="\/read\/[^"]+\/([^/]+)\/chapter-[^"]*" data-number="([^"]+)" data-id="([^"]+)"[^>]*>(.*?)<\/a>/gs;
|
||||
|
||||
let match;
|
||||
while ((match = chapterRegex.exec(htmlContent)) !== null) {
|
||||
const langCode = match[1];
|
||||
const chapterNumber = match[2];
|
||||
const chapterId = match[3];
|
||||
const title = match[4].trim();
|
||||
|
||||
if (!chapters[langCode]) {
|
||||
chapters[langCode] = [];
|
||||
}
|
||||
|
||||
chapters[langCode].push([
|
||||
const langCode = match[1];
|
||||
const chapterNumber = match[2];
|
||||
const chapterId = match[3];
|
||||
const title = match[4].replace(/<[^>]*>/g, '').trim();
|
||||
|
||||
if (!chapters[langCode]) chapters[langCode] = [];
|
||||
|
||||
chapters[langCode].push([
|
||||
chapterNumber,
|
||||
{
|
||||
id: chapterId,
|
||||
scanlation_group: "Mangafire",
|
||||
title: title
|
||||
}
|
||||
]);
|
||||
[
|
||||
{
|
||||
id: chapterId,
|
||||
title: title,
|
||||
chapter: Number(chapterNumber),
|
||||
scanlation_group: "Mangafire"
|
||||
}
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
Object.keys(chapters).forEach(lang => {
|
||||
chapters[lang].reverse();
|
||||
});
|
||||
|
||||
|
||||
Object.keys(chapters).forEach(lang => chapters[lang].reverse());
|
||||
|
||||
return chapters;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`https://mangafire.to/ajax/read/${mangaId}/chapter/en?vrf=${vrf}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue