fix chapter date

This commit is contained in:
kodjomoustapha
2024-11-05 17:27:09 +01:00
parent 8bdedff5a5
commit 12d9e194b2

View File

@@ -104,15 +104,15 @@ class DefaultExtension extends MProvider {
// get urls // get urls
const id = url.split(".").pop(); const id = url.split(".").pop();
const infoUrl = this.source.baseUrl + url; const infoUrl = this.source.baseUrl + url;
const chapterUrl = `https://mangafire.to/ajax/read/${id}/chapter/${this.source.lang}`; const chapterUrl = this.source.baseUrl + `/ajax/read/${id}/chapter/${this.source.lang}`;
const detail = {}; const detail = {};
// request // request
const idRes = await new Client().get(chapterUrl); const idRes = await new Client().get(chapterUrl);
const idDoc = new Document(JSON.parse(idRes.body).result.html); const idDoc = new Document(JSON.parse(idRes.body).result.html);
const infoRes = await new Client().get(infoUrl); const infoRes = await new Client().get(infoUrl);
const infoDoc = new Document(infoRes.body); const infoDoc = new Document(infoRes.body);
// extract info // extract info
const info = infoDoc.selectFirst("div.info"); const info = infoDoc.selectFirst("div.info");
const sidebar = infoDoc.select("aside.sidebar div.meta div"); const sidebar = infoDoc.select("aside.sidebar div.meta div");
@@ -128,14 +128,22 @@ class DefaultExtension extends MProvider {
// get chapter // get chapter
const ids = idDoc.select("a"); const ids = idDoc.select("a");
const dates = infoDoc.select("div.list-body > ul.scroll-sm > li > a > span + span"); const chapRes = await new Client().get(this.source.baseUrl + `/ajax/manga/${id}/chapter/${this.source.lang}`);
const chapDoc = new Document(JSON.parse(chapRes.body).result);
const chapElements = chapDoc.selectFirst(".scroll-sm").children;
detail.chapters = []; detail.chapters = [];
for (let i = 0; i < ids.length; i++) { for (let i = 0; i < ids.length; i++) {
const name = ids[i].text; const name = ids[i].text;
const id = ids[i].attr("data-id"); const id = ids[i].attr("data-id");
const url = `https://mangafire.to/ajax/read/chapter/${id}`; const url = this.source.baseUrl + `/ajax/read/chapter/${id}`;
const dateUpload = this.parseDate(dates[i].text); let dateUpload;
detail.chapters.push({name, url, dateUpload}); try {
dateUpload = this.parseDate(chapElements[i].selectFirst("span + span").text);
} catch (_) {
dateUpload = null
}
detail.chapters.push({ name, url, dateUpload });
} }
return detail; return detail;
} }