mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-21 21:26:19 +01:00
Update mangapark/mangapark.js
This commit is contained in:
parent
30dceced0e
commit
d7eede087a
1 changed files with 54 additions and 24 deletions
|
|
@ -87,23 +87,44 @@ async function getChapters(url) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
const html = await response.text();
|
const html = await response.text();
|
||||||
const regex = /<a href="([^"]+)"[^>]*>Chapter (\d+(?:\.\d+)?)[^<]*<\/a>/g;
|
|
||||||
|
const regex = /<a href="(\/title\/[^"]+)"[^>]*class="link-hover link-primary[^"]*"[^>]*>([^<]+)<\/a>/g;
|
||||||
let match;
|
let match;
|
||||||
let index = 0;
|
|
||||||
while ((match = regex.exec(html)) !== null) {
|
while ((match = regex.exec(html)) !== null) {
|
||||||
|
const href = match[1];
|
||||||
|
const title = match[2].trim();
|
||||||
|
|
||||||
|
let chapterNum = null;
|
||||||
|
|
||||||
|
let chapterMatch = title.match(/Chapter\s+([\d.]+)/i);
|
||||||
|
if (chapterMatch) {
|
||||||
|
chapterNum = parseFloat(chapterMatch[1]);
|
||||||
|
} else {
|
||||||
|
chapterMatch = title.match(/Ch\.([\d.]+)/i);
|
||||||
|
if (chapterMatch) {
|
||||||
|
chapterNum = parseFloat(chapterMatch[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chapterNum === null) continue;
|
||||||
|
|
||||||
results.push([
|
results.push([
|
||||||
String(index),
|
String(chapterNum),
|
||||||
[{
|
[{
|
||||||
id: "https://mangapark.net" + match[1].trim(),
|
id: "https://mangapark.net" + href,
|
||||||
title: `Chapter ${match[2].trim()}`,
|
title: title,
|
||||||
chapter: index,
|
chapter: chapterNum,
|
||||||
scanlation_group: "MangaPark"
|
scanlation_group: title
|
||||||
}]
|
}]
|
||||||
]);
|
]);
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
return { en: results.reverse() };
|
|
||||||
|
results.sort((a, b) => parseFloat(a[0]) - parseFloat(b[0]));
|
||||||
|
|
||||||
|
return { en: results };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error('Error fetching chapters:', err);
|
||||||
return { en: [] };
|
return { en: [] };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -115,25 +136,34 @@ async function getChapterImages(url) {
|
||||||
const html = await response.text();
|
const html = await response.text();
|
||||||
|
|
||||||
const jsonMatch = html.match(/<script type="qwik\/json">([\s\S]*?)<\/script>/);
|
const jsonMatch = html.match(/<script type="qwik\/json">([\s\S]*?)<\/script>/);
|
||||||
if (jsonMatch) {
|
if (!jsonMatch) {
|
||||||
|
console.error('No JSON found');
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
const jsonData = JSON.parse(jsonMatch[1]);
|
const jsonData = JSON.parse(jsonMatch[1]);
|
||||||
|
|
||||||
const findImages = (obj) => {
|
if (jsonData.objs && Array.isArray(jsonData.objs)) {
|
||||||
if (typeof obj === 'string' && /^https:\/\/s\d+\.mp[a-z]+\.org\/media\/mpup\/[^"]+\.jpeg$/.test(obj)) {
|
jsonData.objs.forEach(item => {
|
||||||
results.push(obj);
|
if (typeof item === 'string' &&
|
||||||
} else if (Array.isArray(obj)) {
|
item.startsWith('https://s') &&
|
||||||
obj.forEach(findImages);
|
item.includes('.mp') &&
|
||||||
} else if (obj && typeof obj === 'object') {
|
item.endsWith('.jpeg')) {
|
||||||
Object.values(obj).forEach(findImages);
|
results.push(item);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
findImages(jsonData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error('Error:', err);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const output = await getChapterImages("https://mangapark.net/title/233952-en-the-fragrant-flower-blooms-with-dignity/6789412-ch-001-2-rintaro-and-kaoruko");
|
||||||
|
console.log(JSON.stringify(output, null, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue