fix: Fenrir Realm (#1876)

This commit is contained in:
Justin COLLON
2025-11-10 08:47:04 +01:00
committed by GitHub
parent 406af7d4b1
commit 5d705f4a7c
+14 -12
View File
@@ -10,7 +10,7 @@ class FenrirRealmPlugin implements Plugin.PluginBase {
name = 'Fenrir Realm'; name = 'Fenrir Realm';
icon = 'src/en/fenrirrealm/icon.png'; icon = 'src/en/fenrirrealm/icon.png';
site = 'https://fenrirealm.com'; site = 'https://fenrirealm.com';
version = '1.0.10'; version = '1.0.11';
imageRequestInit?: Plugin.ImageRequestInit | undefined = undefined; imageRequestInit?: Plugin.ImageRequestInit | undefined = undefined;
hideLocked = storage.get('hideLocked'); hideLocked = storage.get('hideLocked');
@@ -40,17 +40,21 @@ class FenrirRealmPlugin implements Plugin.PluginBase {
.join(''); .join('');
const res = await fetchApi( const res = await fetchApi(
`${this.site}/api/series/filter?page=${pageNo}&per_page=20&status=${filters.status.value}&order=${sort}${genresFilter}`, `${this.site}/api/series/filter?page=${pageNo}&per_page=20&status=${filters.status.value}&order=${sort}${genresFilter}`,
).then(r => r.json()); ).then(r =>
r.json().catch(() => {
throw new Error(
'There was an error fetching the data from the server. Please try to open it in WebView',
);
}),
);
return res.data.map(r => this.parseNovelFromApi(r)); return res.data.map(r => this.parseNovelFromApi(r));
} }
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> { async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
const html = await fetchApi(`${this.site}/series/${novelPath}`, { const html = await fetchApi(`${this.site}/series/${novelPath}`, {}).then(
headers: { r => r.text(),
'User-Agent': '', );
},
}).then(r => r.text());
const loadedCheerio = loadCheerio(html); const loadedCheerio = loadCheerio(html);
const novel: Plugin.SourceNovel = { const novel: Plugin.SourceNovel = {
@@ -110,11 +114,9 @@ class FenrirRealmPlugin implements Plugin.PluginBase {
} }
async parseChapter(chapterPath: string): Promise<string> { async parseChapter(chapterPath: string): Promise<string> {
const page = await fetchApi(this.site + '/series/' + chapterPath, { const page = await fetchApi(this.site + '/series/' + chapterPath, {}).then(
headers: { r => r.text(),
'User-Agent': '', );
},
}).then(r => r.text());
return loadCheerio(page)('#reader-area').html() || ''; return loadCheerio(page)('#reader-area').html() || '';
} }