enhanced anime backend

This commit is contained in:
2025-12-04 00:30:41 +01:00
parent bf27d173e9
commit 6973f1485d
10 changed files with 205 additions and 112 deletions

View File

@@ -26,8 +26,8 @@ async function loadAnime() {
}
const fetchUrl = extensionName
? `/api/anime/${animeId}?ext=${extensionName}`
: `/api/anime/${animeId}`;
? `/api/anime/${animeId}?source=${extensionName}`
: `/api/anime/${animeId}?source=anilist`;
const res = await fetch(fetchUrl);
const data = await res.json();

View File

@@ -27,7 +27,7 @@ document.addEventListener('click', (e) => {
async function fetchSearh(query) {
try {
let apiUrl = `/api/search?q=${encodeURIComponent(query.slice(0, 30))}`;
let apiUrl = `/api/search?q=${encodeURIComponent(query)}`;
let extensionName = null;
let finalQuery = query;
@@ -47,7 +47,7 @@ async function fetchSearh(query) {
return;
}
apiUrl = `/api/search/${extensionName}?q=${encodeURIComponent(finalQuery.slice(0, 30))}`;
apiUrl = `/api/search/${extensionName}?q=${encodeURIComponent(finalQuery)}`;
}
}

View File

@@ -22,7 +22,7 @@ document.getElementById('episode-label').innerText = `Episode ${currentEpisode}`
async function loadMetadata() {
try {
const extQuery = extName ? `?ext=${extName}` : "";
const extQuery = extName ? `?source=${extName}` : "?source=anilist";
const res = await fetch(`/api/anime/${animeId}${extQuery}`);
const data = await res.json();
@@ -108,7 +108,7 @@ async function loadMetadata() {
async function loadExtensionEpisodes() {
try {
const extQuery = extName ? `?ext=${extName}` : "";
const extQuery = extName ? `?source=${extName}` : "?source=anilist";
const res = await fetch(`/api/anime/${animeId}/episodes${extQuery}`);
const data = await res.json();
@@ -271,7 +271,11 @@ async function loadStream() {
setLoading(`Loading stream (${audioMode})...`);
try {
const url = `/api/watch/stream?animeId=${animeId}&episode=${currentEpisode}&server=${server}&category=${audioMode}&ext=${currentExtension}`;
let sourc = "&source=anilist";
if (extName){
sourc = `&source=${extName}`;
}
const url = `/api/watch/stream?animeId=${animeId}&episode=${currentEpisode}&server=${server}&category=${audioMode}&ext=${currentExtension}${sourc}`;
const res = await fetch(url);
const data = await res.json();

View File

@@ -482,13 +482,12 @@ function updateURL(newChapter) {
document.getElementById('back-btn').addEventListener('click', () => {
const parts = window.location.pathname.split('/');
const provider = parts[2];
const mangaId = parts[4];
const urlParams = new URLSearchParams(window.location.search);
let source = urlParams.get('source');
if (!source) {
if (source === 'anilist') {
window.location.href = `/book/${mangaId}`;
} else {
window.location.href = `/book/${source}/${mangaId}`;