added local manga, todo: novels

This commit is contained in:
2025-12-27 21:59:03 +01:00
parent 295cab93f3
commit d49f739565
16 changed files with 759 additions and 53 deletions

View File

@@ -129,11 +129,44 @@ async function loadChapter() {
if (!source) {
source = 'anilist';
}
const newEndpoint = `/api/book/${bookId}/${chapter}/${provider}?source=${source}`;
let newEndpoint;
if (provider === 'local') {
newEndpoint = `/api/library/manga/${bookId}/units`;
} else {
newEndpoint = `/api/book/${bookId}/${chapter}/${provider}?source=${source}`;
}
try {
const res = await fetch(newEndpoint);
const data = await res.json();
if (provider === 'local') {
const unit = data.units[Number(chapter)];
if (!unit) {
reader.innerHTML = '<div class="loading-container"><span>Chapter not found</span></div>';
return;
}
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();
currentType = 'manga';
updateSettingsVisibility();
applyStyles();
currentPages = pagesData.pages.map(url => ({ url }));
reader.innerHTML = '';
loadManga(currentPages);
return;
}
}
if (data.title) {
chapterLabel.textContent = data.title;
@@ -172,8 +205,13 @@ async function loadChapter() {
reader.innerHTML = '';
if (data.type === 'manga') {
currentPages = data.pages || [];
loadManga(currentPages);
if (provider === 'local' && data.format === 'cbz') {
currentPages = data.pages.map(url => ({ url }));
loadManga(currentPages);
} else {
currentPages = data.pages || [];
loadManga(currentPages);
}
} else if (data.type === 'ln') {
loadLN(data.content);
}
@@ -293,7 +331,9 @@ function createImageElement(page, index) {
img.className = 'page-img';
img.dataset.index = index;
const url = buildProxyUrl(page.url, page.headers);
const url = provider === 'local'
? page.url
: buildProxyUrl(page.url, page.headers);
const placeholder = "/public/assets/placeholder.svg";
img.onerror = () => {