Skip to content

Commit e1dcd06

Browse files
authored
NovelFire Empty Chapter fix (#2462)
1 parent 5e08dfe commit e1dcd06

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

plugins/multisrc/novelfire/sources.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"options": {
77
"lang": "English",
88
"minorVer": 4,
9-
"versionIncrement": 3
9+
"versionIncrement": 4
1010
}
1111
},
1212
{
@@ -15,7 +15,7 @@
1515
"sourceName": "Novel Phoenix",
1616
"options": {
1717
"lang": "English",
18-
"versionIncrement": 1
18+
"versionIncrement": 2
1919
}
2020
}
2121
]

plugins/multisrc/novelfire/template.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,17 +449,32 @@ export class NovelFirePlugin implements Plugin.PagePlugin {
449449
const loadedCheerio = await this.getCheerio(url, false);
450450

451451
const chapterText = loadedCheerio('#content');
452+
453+
if (chapterText.length === 0) {
454+
throw new Error(
455+
`Chapter content container (#content) not found for ${chapterPath} — possible transient fetch issue. Retry`,
456+
);
457+
}
458+
452459
const odds = chapterText.find(
453460
':not(p, h1, span, i, b, u, img, a, div, strong)',
454461
);
455462
for (const ele of odds.toArray()) {
456463
const tag = ele.name.toString();
457-
if (tag.length > 5 && ele.name.toString().substring(0, 1) == 'nf') {
464+
if (tag.length > 5 && tag.substring(0, 1) == 'nf') {
458465
loadedCheerio(ele).remove();
459466
}
460467
}
461468

462-
return chapterText.html()?.replace(/ /g, ' ') || '';
469+
const html = chapterText.html()?.replace(/ /g, ' ');
470+
471+
if (!html || html.trim().length === 0) {
472+
throw new Error(
473+
`Chapter content was empty after parsing for ${chapterPath}.`,
474+
);
475+
}
476+
477+
return html;
463478
}
464479

465480
async searchNovels(

0 commit comments

Comments
 (0)