From 98f6803c5828d83abf0583c59a07b427266d7089 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 22 Jul 2024 16:16:41 -0700 Subject: feat(Data): raw manga chapter count handler --- src/lib/Data/Manga/raw.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/lib/Data/Manga/raw.ts (limited to 'src') diff --git a/src/lib/Data/Manga/raw.ts b/src/lib/Data/Manga/raw.ts new file mode 100644 index 00000000..a09fa17f --- /dev/null +++ b/src/lib/Data/Manga/raw.ts @@ -0,0 +1,19 @@ +export const getChapterCount = async (nativeTitle: string): Promise => { + const html = new DOMParser().parseFromString( + await (await fetch(`https://rawkuma.com/?s=${encodeURIComponent(nativeTitle)}`)).text(), + 'text/html' + ); + const listContent = html.querySelector('.listupd'); + + if (listContent && listContent.textContent && listContent.textContent.includes('Not Found')) { + return undefined; + } + + const chapterCount = html.querySelector('.epxs'); + + if (chapterCount && chapterCount.textContent && chapterCount.textContent.includes('Chapter')) { + return Number.parseInt(chapterCount.textContent.replace('Chapter', '').trim(), 10); + } + + return undefined; +}; -- cgit v1.2.3