diff options
| author | Fuwn <[email protected]> | 2024-07-22 16:16:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-07-22 16:16:41 -0700 |
| commit | 98f6803c5828d83abf0583c59a07b427266d7089 (patch) | |
| tree | a55821a52165cda08a4b9e8ac25210860c01a5ec /src/lib/Data | |
| parent | refactor(Data): rename awc module (diff) | |
| download | due.moe-98f6803c5828d83abf0583c59a07b427266d7089.tar.xz due.moe-98f6803c5828d83abf0583c59a07b427266d7089.zip | |
feat(Data): raw manga chapter count handler
Diffstat (limited to 'src/lib/Data')
| -rw-r--r-- | src/lib/Data/Manga/raw.ts | 19 |
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; +}; |