fix(source): WTR-LAB (#906)

* fix(source): WTR-LAB

* fix(source): Bump Version
This commit is contained in:
Rajarshee Chatterjee
2024-04-26 15:07:29 +05:30
committed by GitHub
parent db313999e0
commit dcd1101f5d
+9 -9
View File
@@ -7,7 +7,7 @@ class WTRLAB implements Plugin.PluginBase {
id = 'WTRLAB'; id = 'WTRLAB';
name = 'WTR-LAB'; name = 'WTR-LAB';
site = 'https://wtr-lab.com/'; site = 'https://wtr-lab.com/';
version = '1.0.0'; version = '1.0.1';
icon = 'src/en/wtrlab/icon.png'; icon = 'src/en/wtrlab/icon.png';
sourceLang = 'en/'; sourceLang = 'en/';
@@ -53,7 +53,6 @@ class WTRLAB implements Plugin.PluginBase {
} else { } else {
const body = await fetchApi(link).then(res => res.text()); const body = await fetchApi(link).then(res => res.text());
const loadedCheerio = parseHTML(body); const loadedCheerio = parseHTML(body);
//console.log(link);
const novels: Plugin.NovelItem[] = loadedCheerio('.serie-item') const novels: Plugin.NovelItem[] = loadedCheerio('.serie-item')
.map((index, element) => ({ .map((index, element) => ({
name: name:
@@ -74,7 +73,6 @@ class WTRLAB implements Plugin.PluginBase {
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> { async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
const body = await fetchApi(this.site + novelPath).then(res => res.text()); const body = await fetchApi(this.site + novelPath).then(res => res.text());
const loadedCheerio = parseHTML(body); const loadedCheerio = parseHTML(body);
//console.log(this.site + novelPath);
const novel: Plugin.SourceNovel = { const novel: Plugin.SourceNovel = {
path: novelPath, path: novelPath,
@@ -106,7 +104,7 @@ class WTRLAB implements Plugin.PluginBase {
const chapters: Plugin.ChapterItem[] = const chapters: Plugin.ChapterItem[] =
jsonData.props.pageProps.serie.chapters.map( jsonData.props.pageProps.serie.chapters.map(
(jsonChapter, chapterIndex) => ({ (jsonChapter, chapterIndex) => ({
name: 'Chapter ' + jsonChapter.slug + ' ' + jsonChapter.title, name: jsonChapter.title,
path: path:
this.sourceLang + this.sourceLang +
'serie-' + 'serie-' +
@@ -114,8 +112,10 @@ class WTRLAB implements Plugin.PluginBase {
'/' + '/' +
jsonData.props.pageProps.serie.serie_data.slug + jsonData.props.pageProps.serie.serie_data.slug +
'/chapter-' + '/chapter-' +
jsonChapter.slug, // Assuming 'slug' is the intended path jsonChapter.order, // Assuming 'slug' is the intended path
releaseTime: jsonChapter.created_at.substring(0, 10), releaseTime: (
jsonChapter?.created_at || jsonChapter?.updated_at
)?.substring(0, 10),
chapterNumber: chapterIndex + 1, chapterNumber: chapterIndex + 1,
}), }),
); );
@@ -129,16 +129,14 @@ class WTRLAB implements Plugin.PluginBase {
const body = await fetchApi(this.site + chapterPath).then(res => const body = await fetchApi(this.site + chapterPath).then(res =>
res.text(), res.text(),
); );
const loadedCheerio = parseHTML(body); const loadedCheerio = parseHTML(body);
const chapterJson = loadedCheerio('#__NEXT_DATA__').html() + ''; const chapterJson = loadedCheerio('#__NEXT_DATA__').html() + '';
const jsonData: NovelJson = JSON.parse(chapterJson); const jsonData: NovelJson = JSON.parse(chapterJson);
//console.log(body);
const chapterContent = JSON.stringify( const chapterContent = JSON.stringify(
jsonData.props.pageProps.serie.chapter_data.data.body, jsonData.props.pageProps.serie.chapter_data.data.body,
); );
//console.log(chapterContent);
const parsedArray = JSON.parse(chapterContent); const parsedArray = JSON.parse(chapterContent);
let htmlString = ''; let htmlString = '';
@@ -239,10 +237,12 @@ interface Serie {
interface Chapter { interface Chapter {
serie_id: number; serie_id: number;
id: number; id: number;
order: number;
slug: string; slug: string;
title: string; title: string;
name: string; name: string;
created_at: string; created_at: string;
updated_at: string;
} }
interface ChapterData { interface ChapterData {
data: ChapterContent; data: ChapterContent;