Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update 88xiaoshuoParser #1523

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions plugin/js/parsers/88xiaoshuoParser.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
"use strict";

parserFactory.register("88xiaoshuo.net", () => new _88xiaoshuoParser());
parserFactory.register("m.88xiaoshuo.net", () => new _88xiaoshuoParser());
parserFactory.register("88xiaoshuo.net", () => new _88xiaoshuoParser());
parserFactory.register("m.ilwxs.com", () => new _88xiaoshuoParser());
parserFactory.register("ilwxs.com", () => new _88xiaoshuoParser());
parserFactory.register("m.ttshu8.com", () => new _88xiaoshuoParser());
parserFactory.register("ttshu8.com", () => new _88xiaoshuoParser());
parserFactory.register("m.xpaoshuba.com", () => new _88xiaoshuoParser());
parserFactory.register("xpaoshuba.com", () => new _88xiaoshuoParser());
parserFactory.register("m.shuhaige.net", () => new _88xiaoshuoParser());
parserFactory.register("shuhaige.net", () => new _88xiaoshuoParser());
parserFactory.register("m.qbxsw.com", () => new _88xiaoshuoParser());
parserFactory.register("qbxsw.com", () => new _88xiaoshuoParser());
parserFactory.register("m.38xs.com", () => new _88xiaoshuoParser());

class _88xiaoshuoParser extends Parser{
constructor() {
super();
this.infoPageDom = null;
}

async getChapterUrls(dom, chapterUrlsUI) {
let changedomurl = dom.baseURI;
if (changedomurl.includes("https://www.")) {
changedomurl = changedomurl.replace("https://www.","https://m.");
}
if (changedomurl != dom.baseURI) {
dom = (await HttpClient.fetchHtml(changedomurl)).responseXML;
}
return this.getChapterUrlsFromMultipleTocPages(dom,
this.extractPartialChapterList,
this.getUrlsOfTocPages,
Expand All @@ -21,14 +38,14 @@ class _88xiaoshuoParser extends Parser{
let lastPagespan = [...dom.querySelectorAll(".caption > span > a")];
let lastPage = null;
for (let node of lastPagespan) {
if (node.innerText == "尾页") {
if (node.innerText == "尾页" || node.innerText == "Last page") {
lastPage = node;
}
}
let urls = [];
if (lastPage) {
const lastPageNumber = parseInt(lastPage.href.split("/")[4].split("_")[1]);
const baseUrl = lastPage.baseURI.replace(/\/$/, "");
const lastPageNumber = parseInt(lastPage.href.substring(lastPage.href.search(/_[0-9]+\/?$/)).replace("_", "").replace("/", ""));
const baseUrl = lastPage.baseURI.replace(/_[0-9]+\/$/, "").replace(/\/$/, "");
for (let i = 2; i <= lastPageNumber; i++) {
urls.push(`${baseUrl}_${i}`);
}
Expand All @@ -50,8 +67,8 @@ class _88xiaoshuoParser extends Parser{
}

extractAuthor(dom) {
let element = dom.querySelector(".author > a");
return (element === null) ? null : element.textContent;
let element = dom.querySelector("#maininfo a[href*=\"author\"], .author a");
return (element === null) ? "" : element.textContent;
}

findChapterTitle(dom) {
Expand All @@ -60,6 +77,15 @@ class _88xiaoshuoParser extends Parser{
}

findCoverImageUrl(dom) {
return dom.querySelector(".detail > img")?.src ?? null;
return dom.querySelector(".box_con img, .detail > img")?.src ?? null;
}

getInformationEpubItemChildNodes(dom) {
return [...dom.querySelectorAll("#maininfo, .detail")];
}

extractDescription(dom) {
let element = dom.querySelector("#intro");
return (element === null) ? null : element.textContent;
}
}
Loading