forked from 50n50/sources
Update anicrush/anicrush.js
This commit is contained in:
+39
-24
@@ -23,11 +23,20 @@ async function searchResults(keyword) {
|
|||||||
|
|
||||||
if (data.status && data.result && data.result.movies) {
|
if (data.status && data.result && data.result.movies) {
|
||||||
for (const movie of data.result.movies) {
|
for (const movie of data.result.movies) {
|
||||||
results.push({
|
if (movie.has_sub) {
|
||||||
title: movie.name_english || movie.name,
|
results.push({
|
||||||
image: getImage(movie.poster_path),
|
title: (movie.name_english || movie.name) + " [SUB]",
|
||||||
href: "/watch/" + movie.slug + "." + movie.id
|
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) {
|
async function extractEpisodes(url) {
|
||||||
const results = [];
|
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 = {
|
const headers = {
|
||||||
"Host": "api.anicrush.to",
|
"Host": "api.anicrush.to",
|
||||||
@@ -122,7 +133,7 @@ async function extractEpisodes(url) {
|
|||||||
const season = data.result[seasonKey];
|
const season = data.result[seasonKey];
|
||||||
const isMovie = seasonKey === "001 - 001";
|
const isMovie = seasonKey === "001 - 001";
|
||||||
for (const ep of season) {
|
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({
|
results.push({
|
||||||
href: href,
|
href: href,
|
||||||
number: ep.number
|
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 = {
|
const headers = {
|
||||||
"Host": "api.anicrush.to",
|
"Host": "api.anicrush.to",
|
||||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0",
|
"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 getSourcesUrl = `${defaultDomain}embed-2/v3/e-1/getSources?id=${fileId}&_k=${nonce}`;
|
||||||
const getSourcesResp = await fetchv2(getSourcesUrl, headersTwo);
|
const getSourcesResp = await fetchv2(getSourcesUrl, headersTwo);
|
||||||
const getSourcesJson = await getSourcesResp.json();
|
const getSourcesJson = await getSourcesResp.json();
|
||||||
|
console.log(JSON.stringify(getSourcesJson));
|
||||||
const videoUrl = getSourcesJson.sources?.[0]?.file || "";
|
const videoUrl = getSourcesJson.sources?.[0]?.file || "";
|
||||||
if (!videoUrl) return null;
|
if (!videoUrl) return null;
|
||||||
|
|
||||||
@@ -227,9 +244,9 @@ async function extractStreamUrl(ID) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const serverPromises = [];
|
const serverPromises = [];
|
||||||
if (subServerId) serverPromises.push(processServer(subServerId, "SUB"));
|
if (type === "SUB" && subServerId) serverPromises.push(processServer(subServerId, "SUB"));
|
||||||
if (dubServerId) serverPromises.push(processServer(dubServerId, "DUB"));
|
else if (type === "DUB" && dubServerId) serverPromises.push(processServer(dubServerId, "DUB"));
|
||||||
if (rawServerId) serverPromises.push(processServer(rawServerId, "RAW"));
|
else if (type === "RAW" && rawServerId) serverPromises.push(processServer(rawServerId, "RAW"));
|
||||||
|
|
||||||
const results = await Promise.all(serverPromises);
|
const results = await Promise.all(serverPromises);
|
||||||
const streams = results.filter(r => r !== null);
|
const streams = results.filter(r => r !== null);
|
||||||
@@ -238,22 +255,24 @@ async function extractStreamUrl(ID) {
|
|||||||
return "https://error.org/";
|
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 => ({
|
const finalStreams = streams.map(s => ({
|
||||||
title: s.title,
|
title: s.title,
|
||||||
streamUrl: s.streamUrl,
|
streamUrl: s.streamUrl,
|
||||||
headers: s.headers
|
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,
|
streams: finalStreams,
|
||||||
subtitle: subtitle
|
subtitle: subtitle
|
||||||
}));
|
};
|
||||||
return JSON.stringify({
|
console.log(JSON.stringify(result));
|
||||||
streams: finalStreams,
|
return JSON.stringify(result);
|
||||||
subtitles: subtitle
|
|
||||||
});
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return "https://error.oraag/";
|
return "https://error.oraag/";
|
||||||
@@ -276,7 +295,3 @@ function getImage(path, type = "poster") {
|
|||||||
|
|
||||||
return imageUrl;
|
return imageUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user