added local manga, todo: novels
This commit is contained in:
@@ -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;
|
||||
@@ -160,8 +193,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);
|
||||
}
|
||||
@@ -281,7 +319,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 = () => {
|
||||
|
||||
Reference in New Issue
Block a user