aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Data
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-09-10 00:06:05 -0700
committerFuwn <[email protected]>2024-09-10 00:06:05 -0700
commitfcbc26f544a5ad7ec841561dec695aaceb63d709 (patch)
treec94210ebbdec428cac3cd7148ae2fb5929474d12 /src/lib/Data
parentrefactor(reader): chapter list component (diff)
downloaddue.moe-fcbc26f544a5ad7ec841561dec695aaceb63d709.tar.xz
due.moe-fcbc26f544a5ad7ec841561dec695aaceb63d709.zip
feat(reader): add rawkuma chapter support
Diffstat (limited to 'src/lib/Data')
-rw-r--r--src/lib/Data/Manga/raw.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/Data/Manga/raw.ts b/src/lib/Data/Manga/raw.ts
index c570474d..0d7e928c 100644
--- a/src/lib/Data/Manga/raw.ts
+++ b/src/lib/Data/Manga/raw.ts
@@ -1,5 +1,11 @@
import proxy from '$lib/Utility/proxy';
+interface Chapter {
+ href: string;
+ chapterNum: string;
+ chapterDate: string;
+}
+
export const getChapterCount = async (nativeTitle: string): Promise<number | undefined> => {
const html = new DOMParser().parseFromString(
await (await fetch(proxy(`https://rawkuma.com/?s=${encodeURIComponent(nativeTitle)}`))).text(),
@@ -19,3 +25,23 @@ export const getChapterCount = async (nativeTitle: string): Promise<number | und
return undefined;
};
+
+export const getChaptersFromText = (text: string) => {
+ const dom = new DOMParser().parseFromString(text, 'text/html').querySelectorAll('.eph-num');
+ const chapters: Chapter[] = [];
+
+ dom.forEach((chapter) => {
+ const href = chapter.querySelector('a')?.getAttribute('href');
+ const chapterNum = chapter.querySelector('.chapternum')?.textContent;
+ const chapterDate = chapter.querySelector('.chapterdate')?.textContent;
+
+ if (href && chapterNum && chapterDate)
+ chapters.push({
+ href,
+ chapterNum,
+ chapterDate
+ });
+ });
+
+ return chapters;
+};