enhanced book backend

This commit is contained in:
2025-12-03 21:43:19 +01:00
parent 920ce19cc2
commit bf27d173e9
5 changed files with 53 additions and 37 deletions

View File

@@ -255,7 +255,8 @@ async function searchChaptersInExtension(ext: Extension, name: string, searchTit
number: parseFloat(ch.number.toString()),
title: ch.title,
date: ch.releaseDate,
provider: name
provider: name,
index: ch.index
}));
await setCache(cacheKey, result, CACHE_TTL_MS);
@@ -311,17 +312,15 @@ export async function getChaptersForBook(id: string, ext: Boolean): Promise<{ ch
};
}
export async function getChapterContent(bookId: string, chapterIndex: string, providerName: string, name: string): Promise<ChapterContent> {
export async function getChapterContent(bookId: string, chapterIndex: string, providerName: string, source: string): Promise<ChapterContent> {
const extensions = getAllExtensions();
const ext = extensions.get(providerName);
if (!ext) {
throw new Error("Provider not found");
}
let exts = "anilist";
if (name) exts = "ext";
const contentCacheKey = `content:${providerName}:${exts}:${bookId}:${chapterIndex}`;
const contentCacheKey = `content:${providerName}:${source}:${bookId}:${chapterIndex}`;
const cachedContent = await getCache(contentCacheKey);
if (cachedContent) {
@@ -340,7 +339,8 @@ export async function getChapterContent(bookId: string, chapterIndex: string, pr
}
}
const chapterList = await getChaptersForBook(bookId, Boolean(name));
const isExternal = source !== 'anilist';
const chapterList = await getChaptersForBook(bookId, isExternal);
if (!chapterList?.chapters || chapterList.chapters.length === 0) {
throw new Error("Chapters not found");