updated marketplace and extensions
This commit is contained in:
@@ -2,7 +2,7 @@ class asmhentai {
|
||||
constructor() {
|
||||
this.baseUrl = "https://asmhentai.com";
|
||||
this.type = "book-board";
|
||||
this.version = "1.0"
|
||||
this.version = "1.1"
|
||||
this.mediaType = "manga";
|
||||
}
|
||||
|
||||
@@ -47,10 +47,9 @@ class asmhentai {
|
||||
|
||||
if (image.startsWith("//")) image = "https:" + image;
|
||||
|
||||
const genres = $(".tags .tag_list .badge.tag")
|
||||
.map((_, el) => $(el).clone().children().remove().end().text().trim())
|
||||
const genres = $(".tags a.tag")
|
||||
.map((_, el) => $(el).text().trim())
|
||||
.get()
|
||||
.join(", ");
|
||||
|
||||
return {
|
||||
id,
|
||||
@@ -67,38 +66,64 @@ class asmhentai {
|
||||
}
|
||||
|
||||
async findChapters(mangaId) {
|
||||
const html = await fetch(`${this.baseUrl}/g/${mangaId}/`).then(r => r.text());
|
||||
const $ = this.cheerio.load(html);
|
||||
|
||||
const title = $("h1").first().text().trim() || "Chapter 1";
|
||||
|
||||
let thumb = $(".gallery img").first().attr("data-src") || "";
|
||||
if (thumb.startsWith("//")) thumb = "https:" + thumb;
|
||||
|
||||
const base = thumb.match(/https:\/\/[^\/]+\/\d+\/\d+\//)?.[0];
|
||||
const pages = parseInt($(".pages").text().match(/\d+/)?.[0] || "0");
|
||||
const ext = thumb.match(/\.(jpg|png|jpeg|gif)/i)?.[1] || "jpg";
|
||||
|
||||
const chapterId = Buffer.from(JSON.stringify({ base, pages, ext })).toString("base64");
|
||||
|
||||
return [{
|
||||
id: chapterId,
|
||||
title,
|
||||
id: mangaId.toString(),
|
||||
title: "Chapter",
|
||||
number: 1,
|
||||
releaseDate: null,
|
||||
index: 0
|
||||
}];
|
||||
}
|
||||
|
||||
async findChapterPages(chapterId) {
|
||||
const { base, pages, ext } = JSON.parse(
|
||||
Buffer.from(chapterId, "base64").toString("utf8")
|
||||
);
|
||||
const html = await fetch(`${this.baseUrl}/g/${chapterId}/`).then(r => r.text());
|
||||
const $ = this.cheerio.load(html);
|
||||
|
||||
return Array.from({ length: pages }, (_, i) => ({
|
||||
url: `${base}${i + 1}.${ext}`,
|
||||
index: i
|
||||
}));
|
||||
const token = $('meta[name="csrf-token"]').attr("content") || "";
|
||||
const loadId = $("#load_id").val();
|
||||
const loadDir = $("#load_dir").val();
|
||||
const totalPages = $("#t_pages").val() || "0";
|
||||
|
||||
const body = new URLSearchParams({
|
||||
id: loadId,
|
||||
dir: loadDir,
|
||||
visible_pages: "0",
|
||||
t_pages: totalPages,
|
||||
type: "2",
|
||||
});
|
||||
|
||||
if (token) body.append("_token", token);
|
||||
|
||||
const res = await fetch(`${this.baseUrl}/gallery/`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Referer": `${this.baseUrl}/g/${chapterId}/`,
|
||||
},
|
||||
body
|
||||
}).then(r => r.text());
|
||||
|
||||
const $$ = this.cheerio.load(res);
|
||||
|
||||
return $$("img[data-src], img[src]").get()
|
||||
.map((el) => {
|
||||
let url = $$(el).attr("data-src") || $$(el).attr("src");
|
||||
if (url?.startsWith("//")) url = "https:" + url;
|
||||
return url;
|
||||
})
|
||||
.filter(url => {
|
||||
// Mantenemos el filtro que te funcionó
|
||||
return url && url.includes("images.") && !url.includes("/images/");
|
||||
})
|
||||
.map((url, i) => {
|
||||
// Reemplazamos "thumb" por el número del índice + 1
|
||||
// Ejemplo: .../thumb.jpg -> .../1.jpg
|
||||
const newUrl = url.replace("thumb", (i + 1).toString());
|
||||
|
||||
return {
|
||||
index: i,
|
||||
url: newUrl
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user