diff --git a/src/app/api/buscar/animes/anroll/route.js b/src/app/api/buscar/animes/anroll/route.js index d8e2b6e..801a121 100644 --- a/src/app/api/buscar/animes/anroll/route.js +++ b/src/app/api/buscar/animes/anroll/route.js @@ -17,21 +17,36 @@ async function pegarInformacoesDetalhadasAnime(data) { } export async function GET(request) { - const query = request.nextUrl.searchParams.get("q"); + let query = request.nextUrl.searchParams.get("q"); if (!query) return Response.json({ error: "missing query." }, { status: 401 }); + query = query.replace('×', 'x').replace(':', '').toLowerCase(); const res = await fetch(`https://api-search.anroll.net/data?q=${query}`, { cache: "no-store" }); let {data} = await res.json(); + let responses = [] if (!data.length) return Response.json({ error: "anime not found." }, { status: 404 }); - data = data.filter((i) => i.title.replace('×', 'x').replace(':', '').toLowerCase().startsWith(query.toLowerCase()) || i.slug.includes(toSlug(query.toLowerCase()))); + if (data.length > 1) { + for (let i = 0; i < data.length; i++) { + let item = data[i]; + item.title = item.title.replace('×', 'x').replace(':', '').toLowerCase(); + console.log(item.title) + + if (item.title.startsWith(query)) + responses.push(item); + if (item.title.split(' ')[0].includes(query.split(' ')[0])) + responses.push(item); + } + } + + data = responses; data.forEach((i) => i.thumbnail = `https://static.anroll.net/images/${i.type === "movie" ? "filmes" : "animes"}/capas/${i.slug}.jpg`); for (let i = 0; i < data.length; i++) { data[i].extra_data = await pegarInformacoesDetalhadasAnime(data[i]); diff --git a/src/app/api/imagens/anroll/route.js b/src/app/api/imagens/anroll/route.js index f3cd18c..8e31120 100644 --- a/src/app/api/imagens/anroll/route.js +++ b/src/app/api/imagens/anroll/route.js @@ -20,7 +20,6 @@ export async function GET(request) { status: 200, headers: { "Content-Type": "image/webp", - "Content-Disposition": "inline", "Content-Length": contentLength }, }); diff --git a/src/app/api/streaming/anroll/[slug]/media.m3u8/route.js b/src/app/api/streaming/anroll/[slug]/media.m3u8/route.js index 341b7f1..426fb74 100644 --- a/src/app/api/streaming/anroll/[slug]/media.m3u8/route.js +++ b/src/app/api/streaming/anroll/[slug]/media.m3u8/route.js @@ -20,13 +20,18 @@ export async function GET(request) { if (!res.ok) return new Response(JSON.stringify({ error: "Failed to fetch the .m3u8 file." }), { status: res.status }); - const buffer = await res.arrayBuffer(); + const m3u8Text = await res.text(); - return new Response(buffer, { + const updatedM3U8Text = m3u8Text.replace(/(https:\/\/[^\s]+)/g, (url) => { + const encodedUrl = encodeURIComponent(url); + return `${request.headers.get("x-forwarded-proto") || "http"}://${request.headers.get("host")}/api/imagens/anroll?q=${encodedUrl}`; + }); + + return new Response(updatedM3U8Text, { headers: { "Content-Type": "application/vnd.apple.mpegurl", "Content-Disposition": `attachment; filename="${slug}.m3u8"`, - "Content-Length": buffer.byteLength, + "Content-Length": Buffer.byteLength(updatedM3U8Text, "utf8"), "Cache-Control": "no-store" } }); diff --git a/src/components/Anime/AnrollAnimeInfos.jsx b/src/components/Anime/AnrollAnimeInfos.jsx index aaeae30..62a6e1d 100644 --- a/src/components/Anime/AnrollAnimeInfos.jsx +++ b/src/components/Anime/AnrollAnimeInfos.jsx @@ -55,14 +55,11 @@ export default function AnrollAnimeInfos({anime}) { try1 = await tentaPegarDadosAnimeAnroll(anime.synonyms[i]); } const try2 = await tentaPegarDadosAnimeAnroll(anime.title.english); - const try3 = await tentaPegarDadosAnimeAnroll(toSlug(anime.title.english)); if (try1) { setAnimeAnroll(try1); } else if (try2) { setAnimeAnroll(try2) - } else if (try3) { - setAnimeAnroll(try3); } } } @@ -246,8 +243,8 @@ export default function AnrollAnimeInfos({anime}) { {animeAnroll?.type === "movie" && ( -
-
+
+
)} {episodios.length > 0 && ( @@ -274,7 +271,7 @@ export default function AnrollAnimeInfos({anime}) {
) : ( - animeAnroll && ( + (animeAnroll && animeAnroll?.type === "anime") && (

Sem mais episódios. {anime.nextAiringEpisode && (formatAiringEpisode(anime.nextAiringEpisode))}