Files
lnreader/src/services/plugin/fetch.ts
T
nyagami e5a1753e52 Fix tabiew (#939)
* fix: tabview look

* fix: error when library is not fetched fully

* fix: legacy backup

* fix: handle error for plugin methods
2024-02-03 10:19:09 +07:00

40 lines
1.0 KiB
TypeScript

import { getPlugin } from '@plugins/pluginManager';
export const fetchNovel = async (pluginId: string, novelUrl: string) => {
const plugin = getPlugin(pluginId);
const res = await plugin.parseNovelAndChapters(novelUrl).catch(e => {
throw e;
});
return res;
};
export const fetchImage = async (pluginId: string, imageUrl: string) => {
return getPlugin(pluginId)
.fetchImage(imageUrl)
.catch(e => {
throw e;
});
};
export const fetchChapter = async (pluginId: string, chapterUrl: string) => {
const plugin = getPlugin(pluginId);
let chapterText = `Not found plugin with id: ${pluginId}`;
if (plugin) {
chapterText = await plugin.parseChapter(chapterUrl).catch(e => {
throw e;
});
}
return chapterText;
};
export const fetchChapters = async (pluginId: string, novelUrl: string) => {
const plugin = getPlugin(pluginId);
const res = await plugin.parseNovelAndChapters(novelUrl).catch(e => {
throw e;
});
const chapters = res.chapters;
return chapters;
};