NovelFire Empty Chapter fix (#2462)
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
"options": {
|
"options": {
|
||||||
"lang": "English",
|
"lang": "English",
|
||||||
"minorVer": 4,
|
"minorVer": 4,
|
||||||
"versionIncrement": 3
|
"versionIncrement": 4
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
"sourceName": "Novel Phoenix",
|
"sourceName": "Novel Phoenix",
|
||||||
"options": {
|
"options": {
|
||||||
"lang": "English",
|
"lang": "English",
|
||||||
"versionIncrement": 1
|
"versionIncrement": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -449,17 +449,32 @@ export class NovelFirePlugin implements Plugin.PagePlugin {
|
|||||||
const loadedCheerio = await this.getCheerio(url, false);
|
const loadedCheerio = await this.getCheerio(url, false);
|
||||||
|
|
||||||
const chapterText = loadedCheerio('#content');
|
const chapterText = loadedCheerio('#content');
|
||||||
|
|
||||||
|
if (chapterText.length === 0) {
|
||||||
|
throw new Error(
|
||||||
|
`Chapter content container (#content) not found for ${chapterPath} — possible transient fetch issue. Retry`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const odds = chapterText.find(
|
const odds = chapterText.find(
|
||||||
':not(p, h1, span, i, b, u, img, a, div, strong)',
|
':not(p, h1, span, i, b, u, img, a, div, strong)',
|
||||||
);
|
);
|
||||||
for (const ele of odds.toArray()) {
|
for (const ele of odds.toArray()) {
|
||||||
const tag = ele.name.toString();
|
const tag = ele.name.toString();
|
||||||
if (tag.length > 5 && ele.name.toString().substring(0, 1) == 'nf') {
|
if (tag.length > 5 && tag.substring(0, 1) == 'nf') {
|
||||||
loadedCheerio(ele).remove();
|
loadedCheerio(ele).remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return chapterText.html()?.replace(/ /g, ' ') || '';
|
const html = chapterText.html()?.replace(/ /g, ' ');
|
||||||
|
|
||||||
|
if (!html || html.trim().length === 0) {
|
||||||
|
throw new Error(
|
||||||
|
`Chapter content was empty after parsing for ${chapterPath}.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
async searchNovels(
|
async searchNovels(
|
||||||
|
|||||||
Reference in New Issue
Block a user