support for novels and lot of formats for books

This commit is contained in:
2025-12-28 18:31:54 +01:00
parent 6222e7736f
commit 48e1939d2a
16 changed files with 1798 additions and 236 deletions

View File

@@ -132,7 +132,7 @@ async function loadChapter() {
let newEndpoint;
if (provider === 'local') {
newEndpoint = `/api/library/manga/${bookId}/units`;
newEndpoint = `/api/library/${bookId}/units`;
} else {
newEndpoint = `/api/book/${bookId}/${chapter}/${provider}?source=${source}`;
}
@@ -142,29 +142,39 @@ async function loadChapter() {
const data = await res.json();
if (provider === 'local') {
const unit = data.units[Number(chapter)];
if (!unit) return;
if (!unit) {
reader.innerHTML = '<div class="loading-container"><span>Chapter not found</span></div>';
return;
}
chapterLabel.textContent = unit.name;
document.title = unit.name;
if (unit.format === 'cbz') {
chapterLabel.textContent = unit.name; // ✅
document.title = unit.name;
const pagesRes = await fetch(
`/api/library/manga/cbz/${unit.id}/pages`
);
const pagesData = await pagesRes.json();
const manifestRes = await fetch(`/api/library/${unit.id}/manifest`);
const manifest = await manifestRes.json();
reader.innerHTML = '';
// ===== MANGA =====
if (manifest.type === 'manga') {
currentType = 'manga';
updateSettingsVisibility();
applyStyles();
currentPages = pagesData.pages.map(url => ({ url }));
reader.innerHTML = '';
currentPages = manifest.pages;
loadManga(currentPages);
return;
}
// ===== LN =====
if (manifest.type === 'ln') {
currentType = 'ln';
updateSettingsVisibility();
applyStyles();
const contentRes = await fetch(manifest.url);
const html = await contentRes.text();
loadLN(html);
return;
}
}
@@ -205,13 +215,8 @@ async function loadChapter() {
reader.innerHTML = '';
if (data.type === 'manga') {
if (provider === 'local' && data.format === 'cbz') {
currentPages = data.pages.map(url => ({ url }));
loadManga(currentPages);
} else {
currentPages = data.pages || [];
loadManga(currentPages);
}
currentPages = data.pages || [];
loadManga(currentPages);
} else if (data.type === 'ln') {
loadLN(data.content);
}