added anime entries from extensions

This commit is contained in:
2025-11-28 22:22:23 +01:00
parent 03ebb5d88e
commit 09a89507e7
8 changed files with 180 additions and 32 deletions

View File

@@ -7,7 +7,16 @@ let currentExtension = '';
let plyrInstance;
let hlsInstance;
document.getElementById('back-link').href = `/anime/${animeId}`;
const params = new URLSearchParams(window.location.search);
const firstKey = params.keys().next().value;
let extName;
if (firstKey) extName = firstKey;
const href = extName
? `/anime/${extName}/${animeId}`
: `/anime/${animeId}`;
document.getElementById('back-link').href = href;
document.getElementById('episode-label').innerText = `Episode ${currentEpisode}`;
async function loadMetadata() {
@@ -29,18 +38,26 @@ async function loadExtensions() {
const select = document.getElementById('extension-select');
if (data.extensions && data.extensions.length > 0) {
data.extensions.forEach(extName => {
data.extensions.forEach(ext => {
const opt = document.createElement('option');
opt.value = extName;
opt.innerText = extName;
opt.value = opt.innerText = ext;
select.appendChild(opt);
});
if (data.extensions.includes(extName ?? "")) {
select.value = extName;
currentExtension = extName;
onExtensionChange();
}
} else {
select.innerHTML = '<option>No Extensions</option>';
select.disabled = true;
setLoading("No extensions found in WaifuBoards folder.");
}
} catch(e) { console.error("Extension Error:", e); }
} catch(e) {
console.error("Extension Error:", e);
}
}
async function onExtensionChange() {
@@ -114,7 +131,7 @@ async function loadStream() {
setLoading(`Searching & Resolving Stream (${audioMode})...`);
try {
const url = `/api/watch/stream?animeId=${animeId}&episode=${currentEpisode}&server=${server}&category=${audioMode}&ext=${currentExtension}`;
const url = `/api/watch/stream?animeId=${animeId.slice(0, 30)}&episode=${currentEpisode}&server=${server}&category=${audioMode}&ext=${currentExtension}`;
const res = await fetch(url);
const data = await res.json();
@@ -199,11 +216,15 @@ function setLoading(msg) {
text.innerText = msg;
}
const extParam = extName ? `?${extName}` : "";
document.getElementById('prev-btn').onclick = () => {
if(currentEpisode > 1) window.location.href = `/watch/${animeId}/${currentEpisode - 1}`;
if (currentEpisode > 1) {
window.location.href = `/watch/${animeId}/${currentEpisode - 1}${extParam}`;
}
};
document.getElementById('next-btn').onclick = () => {
window.location.href = `/watch/${animeId}/${currentEpisode + 1}`;
window.location.href = `/watch/${animeId}/${currentEpisode + 1}${extParam}`;
};
if(currentEpisode <= 1) document.getElementById('prev-btn').disabled = true;