From 34d9df60555c5380fba4b334c90f8d9883c97c58 Mon Sep 17 00:00:00 2001 From: 52191314 Date: Thu, 23 Jul 2026 14:23:55 +0700 Subject: [PATCH 1/2] fix(english): WTR-LAB fix missing chapters pagination and URL patterns (Closes #2340) --- plugins/english/wtrlab.ts | 53 ++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/plugins/english/wtrlab.ts b/plugins/english/wtrlab.ts index 50804e00b..ef056f668 100644 --- a/plugins/english/wtrlab.ts +++ b/plugins/english/wtrlab.ts @@ -8,7 +8,7 @@ class WTRLAB implements Plugin.PluginBase { id = 'WTRLAB'; name = 'WTR-LAB'; site = 'https://wtr-lab.com/'; - version = '1.1.4'; + version = '1.1.5'; icon = 'src/en/wtrlab/icon.png'; sourceLang = 'en/'; baggage = ''; @@ -341,7 +341,7 @@ class WTRLAB implements Plugin.PluginBase { ''; } - const urlMatch = novelPath.match(/serie-(\d+)\/([^/]+)/); + const urlMatch = novelPath.match(/(?:serie|novel)-?(\d+)\/([^/]+)/); if (urlMatch) { rawId = parseInt(urlMatch[1]); slug = urlMatch[2]; @@ -369,18 +369,17 @@ class WTRLAB implements Plugin.PluginBase { } let chapters: Plugin.ChapterItem[] = []; - if (rawId && slug && chapterCount > 0) { + if (rawId && slug) { try { - chapters = await this.fetchAllChapters(rawId, chapterCount, slug); + chapters = await this.fetchAllChapters(rawId, slug); } catch (error) { console.error('Failed to fetch chapters via API:', error); chapters = []; } } else { - console.warn('Could not extract rawId, slug, or chapterCount from page', { + console.warn('Could not extract rawId or slug from page', { rawId, slug, - chapterCount, }); } @@ -513,7 +512,7 @@ class WTRLAB implements Plugin.PluginBase { let chapterNo: number | null = null; let loadedCheerio = null; - const urlMatch = chapterPath.match(/serie-(\d+)\/[^/]+\/chapter-(\d+)/); + const urlMatch = chapterPath.match(/(?:serie|novel)-?(\d+)\/[^/]+\/chapter-(\d+)/); if (urlMatch) { rawId = parseInt(urlMatch[1], 10); chapterNo = parseInt(urlMatch[2], 10); @@ -622,14 +621,14 @@ class WTRLAB implements Plugin.PluginBase { async fetchAllChapters( rawId: number, - totalChapters: number, slug: string, ): Promise { const allChapters: Plugin.ChapterItem[] = []; - const batchSize = 250; + const batchSize = 500; + let start = 1; - for (let start = 1; start <= totalChapters; start += batchSize) { - const end = Math.min(start + batchSize - 1, totalChapters); + while (true) { + const end = start + batchSize - 1; try { const response = await fetchApi( @@ -644,27 +643,29 @@ class WTRLAB implements Plugin.PluginBase { const data = await response.json(); const chapters = data.chapters ?? data.data?.chapters ?? []; - if (Array.isArray(chapters)) { - const batchChapters: Plugin.ChapterItem[] = chapters.map( - (apiChapter: ApiChapter) => ({ - name: apiChapter.title, - path: `${this.sourceLang}serie-${rawId}/${slug}/chapter-${apiChapter.order}`, - releaseTime: apiChapter.updated_at?.substring(0, 10), - chapterNumber: apiChapter.order, - }), - ); + if (!Array.isArray(chapters) || chapters.length === 0) { + break; + } - allChapters.push(...batchChapters); + const batchChapters: Plugin.ChapterItem[] = chapters.map( + (apiChapter: ApiChapter) => ({ + name: apiChapter.title || apiChapter.name || `Chapter ${apiChapter.order}`, + path: `${this.sourceLang}serie-${rawId}/${slug}/chapter-${apiChapter.order}`, + releaseTime: apiChapter.updated_at?.substring(0, 10), + chapterNumber: apiChapter.order, + }), + ); - if (chapters.length < batchSize) { - break; - } - } else { + allChapters.push(...batchChapters); + + if (chapters.length < batchSize) { break; } + + start += batchSize; } catch (error) { console.error(`Failed to fetch chapters ${start}-${end}:`, error); - continue; + break; } } From 096f1b624dc4fbc31095ecec6c830a3b99f1067d Mon Sep 17 00:00:00 2001 From: 52191314 Date: Sun, 26 Jul 2026 14:49:06 +0700 Subject: [PATCH 2/2] fix(english): WTR-LAB replace while(true) loop with boolean flag --- plugins/english/wtrlab.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/english/wtrlab.ts b/plugins/english/wtrlab.ts index ef056f668..9f959a2cf 100644 --- a/plugins/english/wtrlab.ts +++ b/plugins/english/wtrlab.ts @@ -626,8 +626,9 @@ class WTRLAB implements Plugin.PluginBase { const allChapters: Plugin.ChapterItem[] = []; const batchSize = 500; let start = 1; + let hasMore = true; - while (true) { + while (hasMore) { const end = start + batchSize - 1; try { @@ -644,12 +645,16 @@ class WTRLAB implements Plugin.PluginBase { const chapters = data.chapters ?? data.data?.chapters ?? []; if (!Array.isArray(chapters) || chapters.length === 0) { + hasMore = false; break; } const batchChapters: Plugin.ChapterItem[] = chapters.map( (apiChapter: ApiChapter) => ({ - name: apiChapter.title || apiChapter.name || `Chapter ${apiChapter.order}`, + name: + apiChapter.title || + apiChapter.name || + `Chapter ${apiChapter.order}`, path: `${this.sourceLang}serie-${rawId}/${slug}/chapter-${apiChapter.order}`, releaseTime: apiChapter.updated_at?.substring(0, 10), chapterNumber: apiChapter.order, @@ -659,12 +664,14 @@ class WTRLAB implements Plugin.PluginBase { allChapters.push(...batchChapters); if (chapters.length < batchSize) { + hasMore = false; break; } start += batchSize; } catch (error) { console.error(`Failed to fetch chapters ${start}-${end}:`, error); + hasMore = false; break; } }