mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-21 13:16:21 +01:00
Update comix/comix.js
This commit is contained in:
parent
6658673165
commit
363a942e85
1 changed files with 24 additions and 15 deletions
|
|
@ -71,20 +71,24 @@ async function getChapters(url) {
|
|||
|
||||
allItems.reverse();
|
||||
|
||||
const chaptersMap = new Map();
|
||||
allItems.forEach(item => {
|
||||
results.push([
|
||||
String(item.number),
|
||||
[{
|
||||
id: url + "/" + item.chapter_id + "-chapter-" + item.number,
|
||||
title: item.name || `Chapter ${item.number}`,
|
||||
chapter: item.number,
|
||||
scanlation_group: item.scanlation_group?.name || "Comix"
|
||||
}]
|
||||
]);
|
||||
const chapterNum = String(item.number);
|
||||
if (!chaptersMap.has(chapterNum)) {
|
||||
chaptersMap.set(chapterNum, [
|
||||
chapterNum,
|
||||
[{
|
||||
id: url + "/" + item.chapter_id + "-chapter-" + item.number,
|
||||
title: item.name || `Chapter ${item.number}`,
|
||||
chapter: item.number,
|
||||
scanlation_group: item.scanlation_group?.name || "Comix"
|
||||
}]
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
en: results
|
||||
en: Array.from(chaptersMap.values())
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
|
|
@ -94,6 +98,7 @@ async function getChapters(url) {
|
|||
}
|
||||
|
||||
async function getChapterImages(url) {
|
||||
const results = [];
|
||||
try {
|
||||
const response = await fetch("https://comix.to/title/" + url);
|
||||
const html = await response.text();
|
||||
|
|
@ -101,12 +106,16 @@ async function getChapterImages(url) {
|
|||
const match = html.match(/\\"images\\":\[([^\]]+)\]/);
|
||||
if (match) {
|
||||
const imagesJson = '[' + match[1].replace(/\\"/g, '"') + ']';
|
||||
const urls = JSON.parse(imagesJson);
|
||||
return urls;
|
||||
const images = JSON.parse(imagesJson);
|
||||
const imageUrls = images.map(img => img.url);
|
||||
results.push(...imageUrls);
|
||||
return results;
|
||||
} else {
|
||||
console.error("Invalid response from server");
|
||||
return [];
|
||||
}
|
||||
return [];
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} catch (error) {
|
||||
console.error("Error fetching chapters: " + error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue