Fix some bugs with inkitt (#1478)

* Fix some bugs with inkitt

* remove debug
This commit is contained in:
Adam Kemish
2025-01-31 01:15:50 +08:00
committed by GitHub
parent c517a62b45
commit 5005b43671
+6 -4
View File
@@ -9,7 +9,7 @@ class InkittPlugin implements Plugin.PluginBase {
name = 'Inkitt'; name = 'Inkitt';
icon = 'src/en/inkitt/icon.png'; icon = 'src/en/inkitt/icon.png';
site = 'https://www.inkitt.com'; site = 'https://www.inkitt.com';
version = '1.0.0'; version = '1.0.1';
imageRequestInit?: Plugin.ImageRequestInit | undefined = undefined; imageRequestInit?: Plugin.ImageRequestInit | undefined = undefined;
//flag indicates whether access to LocalStorage, SesesionStorage is required. //flag indicates whether access to LocalStorage, SesesionStorage is required.
@@ -53,7 +53,7 @@ class InkittPlugin implements Plugin.PluginBase {
} }
getPath(novel: any) { getPath(novel: any) {
return novel.category_one + '/' + novel.id; return (novel.category_one || novel.genres[0]) + '/' + novel.id;
} }
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> { async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
@@ -66,13 +66,15 @@ class InkittPlugin implements Plugin.PluginBase {
name: loadedCheerio('h1.story-title').text(), name: loadedCheerio('h1.story-title').text(),
}; };
novel.author = loadedCheerio('a.author-link').text(); novel.author = loadedCheerio('dl > dd > a.author-link').text();
novel.genres = loadedCheerio('dd.genres > a') novel.genres = loadedCheerio('dd.genres > a')
.map((i, el) => loadedCheerio(el).text()) .map((i, el) => loadedCheerio(el).text())
.toArray() .toArray()
.join(', '); .join(', ');
const status = loadedCheerio('div.dlc > dl > dd').text().trim(); const status = loadedCheerio('div.dlc > dl:has(dt:contains("Status")) > dd')
.text()
.trim();
if (status === 'Complete') novel.status = NovelStatus.Completed; if (status === 'Complete') novel.status = NovelStatus.Completed;
if (status === 'Ongoing') novel.status = NovelStatus.Ongoing; if (status === 'Ongoing') novel.status = NovelStatus.Ongoing;