1
0
forked from 50n50/sources

Update anicrush/anicrush.js

This commit is contained in:
aka paul
2026-01-17 23:19:08 +00:00
parent 925c657e8e
commit d35b83e61d
+40 -25
View File
@@ -23,11 +23,20 @@ async function searchResults(keyword) {
if (data.status && data.result && data.result.movies) {
for (const movie of data.result.movies) {
results.push({
title: movie.name_english || movie.name,
image: getImage(movie.poster_path),
href: "/watch/" + movie.slug + "." + movie.id
});
if (movie.has_sub) {
results.push({
title: (movie.name_english || movie.name) + " [SUB]",
image: getImage(movie.poster_path),
href: "/watch/" + movie.slug + "." + movie.id + "?type=SUB"
});
}
if (movie.has_dub) {
results.push({
title: (movie.name_english || movie.name) + " [DUB]",
image: getImage(movie.poster_path),
href: "/watch/" + movie.slug + "." + movie.id + "?type=DUB"
});
}
}
}
@@ -93,7 +102,9 @@ async function extractDetails(url) {
async function extractEpisodes(url) {
const results = [];
const id = url.split('.').pop();
const id = url.split('.').pop().split('?')[0];
const typeMatch = url.match(/[?&]type=([^&]+)/);
const type = typeMatch ? typeMatch[1] : "SUB";
const headers = {
"Host": "api.anicrush.to",
@@ -122,7 +133,7 @@ async function extractEpisodes(url) {
const season = data.result[seasonKey];
const isMovie = seasonKey === "001 - 001";
for (const ep of season) {
const href = isMovie ? `?_movieId=${id}&ep=1` : `?_movieId=${id}&ep=${ep.number}`;
const href = isMovie ? `?_movieId=${id}&ep=1&type=${type}` : `?_movieId=${id}&ep=${ep.number}&type=${type}`;
results.push({
href: href,
number: ep.number
@@ -138,7 +149,12 @@ async function extractEpisodes(url) {
}
}
async function extractStreamUrl(ID) {
async function extractStreamUrl(ID, type = "DUB") {
const typeMatch = ID.match(/[?&]type=([^&]+)/);
if (typeMatch) {
type = typeMatch[1];
}
const headers = {
"Host": "api.anicrush.to",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0",
@@ -206,6 +222,7 @@ async function extractStreamUrl(ID) {
const getSourcesUrl = `${defaultDomain}embed-2/v3/e-1/getSources?id=${fileId}&_k=${nonce}`;
const getSourcesResp = await fetchv2(getSourcesUrl, headersTwo);
const getSourcesJson = await getSourcesResp.json();
console.log(JSON.stringify(getSourcesJson));
const videoUrl = getSourcesJson.sources?.[0]?.file || "";
if (!videoUrl) return null;
@@ -227,9 +244,9 @@ async function extractStreamUrl(ID) {
};
const serverPromises = [];
if (subServerId) serverPromises.push(processServer(subServerId, "SUB"));
if (dubServerId) serverPromises.push(processServer(dubServerId, "DUB"));
if (rawServerId) serverPromises.push(processServer(rawServerId, "RAW"));
if (type === "SUB" && subServerId) serverPromises.push(processServer(subServerId, "SUB"));
else if (type === "DUB" && dubServerId) serverPromises.push(processServer(dubServerId, "DUB"));
else if (type === "RAW" && rawServerId) serverPromises.push(processServer(rawServerId, "RAW"));
const results = await Promise.all(serverPromises);
const streams = results.filter(r => r !== null);
@@ -238,22 +255,24 @@ async function extractStreamUrl(ID) {
return "https://error.org/";
}
const englishTrack = streams[0].sourcesData.tracks?.find(t => t.kind === "captions" && t.label === "English");
const subtitle = englishTrack ? englishTrack.file : "";
const finalStreams = streams.map(s => ({
title: s.title,
streamUrl: s.streamUrl,
headers: s.headers
}));
console.log(JSON.stringify({
let subtitle = null;
if (streams.length > 0 && streams[0].sourcesData.tracks) {
const englishTrack = streams[0].sourcesData.tracks.find(t => t.kind === "captions" && t.label === "English");
subtitle = englishTrack ? englishTrack.file : null;
}
const result = {
streams: finalStreams,
subtitle: subtitle
}));
return JSON.stringify({
streams: finalStreams,
subtitles: subtitle
});
};
console.log(JSON.stringify(result));
return JSON.stringify(result);
} catch (err) {
console.log(err);
return "https://error.oraag/";
@@ -275,8 +294,4 @@ function getImage(path, type = "poster") {
const imageUrl = `${baseUrl}/${size}/100/${reversedHash}.${ext}`;
return imageUrl;
}
}