aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Data
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Data')
-rw-r--r--src/lib/Data/Manga/raw.ts19
1 files changed, 19 insertions, 0 deletions
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<number | undefined> => {
+ 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;
+};