From 00cecb13952eeb7dadf5f28959cfe3ab06e5dc62 Mon Sep 17 00:00:00 2001 From: D3ICIDE <183315953+D3ICIDE@users.noreply.github.com> Date: Mon, 24 Aug 2026 00:04:22 +0530 Subject: [PATCH 1/5] testing1 --- plugins/multisrc/novelfire/template.ts | 80 ++++++++++++++++++++++---- 1 file changed, 70 insertions(+), 10 deletions(-) diff --git a/plugins/multisrc/novelfire/template.ts b/plugins/multisrc/novelfire/template.ts index 9b9d0f13f..7d98ff3b5 100644 --- a/plugins/multisrc/novelfire/template.ts +++ b/plugins/multisrc/novelfire/template.ts @@ -445,21 +445,73 @@ export class NovelFirePlugin implements Plugin.PagePlugin { } async parseChapter(chapterPath: string): Promise { + console.log(`[NovelFire] >>> parseChapter ENTERED for: ${chapterPath}`); const url = this.site + chapterPath; - const loadedCheerio = await this.getCheerio(url, false); + const retryCount = 4; + const sleepTime = 2; // seconds between retries - const chapterText = loadedCheerio('#content'); - const odds = chapterText.find( - ':not(p, h1, span, i, b, u, img, a, div, strong)', - ); - for (const ele of odds.toArray()) { - const tag = ele.name.toString(); - if (tag.length > 5 && ele.name.toString().substring(0, 1) == 'nf') { - loadedCheerio(ele).remove(); + let lastError: unknown; + + for (let attempt = 0; attempt < retryCount; attempt++) { + try { + const loadedCheerio = await this.getCheerio(url, false); + const chapterText = loadedCheerio('#content'); + + if (chapterText.length === 0) { + throw new NovelFireEmptyContentError( + `#content not found (attempt ${attempt + 1}/${retryCount})`, + ); + } + + const odds = chapterText.find( + ':not(p, h1, span, i, b, u, img, a, div, strong)', + ); + for (const ele of odds.toArray()) { + const tag = ele.name.toString(); + if (tag.length > 5 && tag.substring(0, 1) == 'nf') { + loadedCheerio(ele).remove(); + } + } + + const html = chapterText.html()?.replace(/ /g, ' '); + + if (!html || html.trim().length === 0) { + throw new NovelFireEmptyContentError( + `#content was empty after parsing (attempt ${attempt + 1}/${retryCount})`, + ); + } + + return html; + } catch (err) { + lastError = err; + + if (err instanceof NovelFireEmptyContentError) { + if (attempt < retryCount - 1) { + console.warn( + `[${chapterPath}] Chapter content missing, retrying in ${sleepTime}s... (${attempt + 1}/${retryCount})`, + ); + await new Promise(resolve => setTimeout(resolve, sleepTime * 1000)); + continue; + } else { + console.warn( + `[${chapterPath}] Chapter content still missing after ${retryCount} attempts, giving up.`, + ); + } + } else { + // Non-retryable error (network failure, Cloudflare block, etc.) - fail immediately + console.warn( + `[${chapterPath}] parseChapter failed with non-retryable error: ${ + err instanceof Error ? err.message : String(err) + }`, + ); + throw err; + } } } - return chapterText.html()?.replace(/ /g, ' ') || ''; + throw lastError instanceof Error + ? lastError + : new Error('Chapter content could not be loaded after retries.'); } async searchNovels( @@ -501,3 +553,11 @@ class NovelFireAjaxNotFound extends Error { this.name = 'NovelFireAjaxError'; } } + +// Custom error for when chapter content couldn't be found (triggers a retry in parseChapter) +class NovelFireEmptyContentError extends Error { + constructor(message = 'Novel Fire chapter content was empty or missing') { + super(message); + this.name = 'NovelFireEmptyContentError'; + } +} From 6e99897aba1bb5f7e9e0ef3bef61e676cd4f41c4 Mon Sep 17 00:00:00 2001 From: D3ICIDE <183315953+D3ICIDE@users.noreply.github.com> Date: Mon, 24 Aug 2026 00:05:25 +0530 Subject: [PATCH 2/5] testing1.2 --- plugins/multisrc/novelfire/sources.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/multisrc/novelfire/sources.json b/plugins/multisrc/novelfire/sources.json index fe106ad11..1a5bbb752 100644 --- a/plugins/multisrc/novelfire/sources.json +++ b/plugins/multisrc/novelfire/sources.json @@ -6,7 +6,7 @@ "options": { "lang": "English", "minorVer": 4, - "versionIncrement": 3 + "versionIncrement": 4 } }, { From 44fbbac6a0d90487577c9bd6841524830ad5b1bc Mon Sep 17 00:00:00 2001 From: D3ICIDE <183315953+D3ICIDE@users.noreply.github.com> Date: Mon, 24 Aug 2026 00:28:44 +0530 Subject: [PATCH 3/5] success --- plugins/multisrc/novelfire/template.ts | 89 +++++++------------------- 1 file changed, 22 insertions(+), 67 deletions(-) diff --git a/plugins/multisrc/novelfire/template.ts b/plugins/multisrc/novelfire/template.ts index 7d98ff3b5..e695fffa1 100644 --- a/plugins/multisrc/novelfire/template.ts +++ b/plugins/multisrc/novelfire/template.ts @@ -445,73 +445,36 @@ export class NovelFirePlugin implements Plugin.PagePlugin { } async parseChapter(chapterPath: string): Promise { - console.log(`[NovelFire] >>> parseChapter ENTERED for: ${chapterPath}`); const url = this.site + chapterPath; - const retryCount = 4; - const sleepTime = 2; // seconds between retries + const loadedCheerio = await this.getCheerio(url, false); - let lastError: unknown; + const chapterText = loadedCheerio('#content'); - for (let attempt = 0; attempt < retryCount; attempt++) { - try { - const loadedCheerio = await this.getCheerio(url, false); - const chapterText = loadedCheerio('#content'); - - if (chapterText.length === 0) { - throw new NovelFireEmptyContentError( - `#content not found (attempt ${attempt + 1}/${retryCount})`, - ); - } - - const odds = chapterText.find( - ':not(p, h1, span, i, b, u, img, a, div, strong)', - ); - for (const ele of odds.toArray()) { - const tag = ele.name.toString(); - if (tag.length > 5 && tag.substring(0, 1) == 'nf') { - loadedCheerio(ele).remove(); - } - } - - const html = chapterText.html()?.replace(/ /g, ' '); + if (chapterText.length === 0) { + throw new Error( + `Chapter content container (#content) not found for ${chapterPath} — possible transient fetch issue.`, + ); + } - if (!html || html.trim().length === 0) { - throw new NovelFireEmptyContentError( - `#content was empty after parsing (attempt ${attempt + 1}/${retryCount})`, - ); - } + const odds = chapterText.find( + ':not(p, h1, span, i, b, u, img, a, div, strong)', + ); + for (const ele of odds.toArray()) { + const tag = ele.name.toString(); + if (tag.length > 5 && tag.substring(0, 1) == 'nf') { + loadedCheerio(ele).remove(); + } + } - return html; - } catch (err) { - lastError = err; + const html = chapterText.html()?.replace(/ /g, ' '); - if (err instanceof NovelFireEmptyContentError) { - if (attempt < retryCount - 1) { - console.warn( - `[${chapterPath}] Chapter content missing, retrying in ${sleepTime}s... (${attempt + 1}/${retryCount})`, - ); - await new Promise(resolve => setTimeout(resolve, sleepTime * 1000)); - continue; - } else { - console.warn( - `[${chapterPath}] Chapter content still missing after ${retryCount} attempts, giving up.`, - ); - } - } else { - // Non-retryable error (network failure, Cloudflare block, etc.) - fail immediately - console.warn( - `[${chapterPath}] parseChapter failed with non-retryable error: ${ - err instanceof Error ? err.message : String(err) - }`, - ); - throw err; - } - } + if (!html || html.trim().length === 0) { + throw new Error( + `Chapter content was empty after parsing for ${chapterPath}.`, + ); } - throw lastError instanceof Error - ? lastError - : new Error('Chapter content could not be loaded after retries.'); + return html; } async searchNovels( @@ -553,11 +516,3 @@ class NovelFireAjaxNotFound extends Error { this.name = 'NovelFireAjaxError'; } } - -// Custom error for when chapter content couldn't be found (triggers a retry in parseChapter) -class NovelFireEmptyContentError extends Error { - constructor(message = 'Novel Fire chapter content was empty or missing') { - super(message); - this.name = 'NovelFireEmptyContentError'; - } -} From 257195c994a1c4cfcc0e59cbe1d5d4f2e454b39f Mon Sep 17 00:00:00 2001 From: D3ICIDE <183315953+D3ICIDE@users.noreply.github.com> Date: Mon, 24 Aug 2026 00:42:32 +0530 Subject: [PATCH 4/5] final --- plugins/multisrc/novelfire/template.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/multisrc/novelfire/template.ts b/plugins/multisrc/novelfire/template.ts index e695fffa1..3b47f2440 100644 --- a/plugins/multisrc/novelfire/template.ts +++ b/plugins/multisrc/novelfire/template.ts @@ -452,7 +452,7 @@ export class NovelFirePlugin implements Plugin.PagePlugin { if (chapterText.length === 0) { throw new Error( - `Chapter content container (#content) not found for ${chapterPath} — possible transient fetch issue.`, + `Chapter content container (#content) not found for ${chapterPath} — possible transient fetch issue. Retry`, ); } From f9a41fc8a403174e18f58d9f0981f94b56be26b1 Mon Sep 17 00:00:00 2001 From: D3ICIDE <183315953+D3ICIDE@users.noreply.github.com> Date: Mon, 24 Aug 2026 01:03:59 +0530 Subject: [PATCH 5/5] Novel Phoenix version bump --- plugins/multisrc/novelfire/sources.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/multisrc/novelfire/sources.json b/plugins/multisrc/novelfire/sources.json index 1a5bbb752..826f71c15 100644 --- a/plugins/multisrc/novelfire/sources.json +++ b/plugins/multisrc/novelfire/sources.json @@ -15,7 +15,7 @@ "sourceName": "Novel Phoenix", "options": { "lang": "English", - "versionIncrement": 1 + "versionIncrement": 2 } } ]