mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-06-19 13:07:44 +00:00
fix: update animetsu and movies4u providers
This commit is contained in:
+102
-75
@@ -8,8 +8,26 @@ export const getStream = async function ({
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Stream[]> {
|
||||
try {
|
||||
const { axios } = providerContext;
|
||||
const baseUrl = "https://backend.animetsu.to";
|
||||
const { axios, openWebView, commonHeaders } = providerContext;
|
||||
const baseUrl = "https://animetsu.net";
|
||||
|
||||
let wafCookies: string | undefined;
|
||||
try {
|
||||
await axios.get(baseUrl, {
|
||||
headers: { ...commonHeaders, Referer: baseUrl },
|
||||
});
|
||||
} catch (error: any) {
|
||||
if (error.response?.status === 403) {
|
||||
const wafResult = await openWebView(baseUrl, {
|
||||
title: "Solve the captcha below and click done",
|
||||
description: "Required to bypass Animetsu anti-bot protection.",
|
||||
headers: { ...commonHeaders, Referer: baseUrl },
|
||||
force: true,
|
||||
waitForCookie: "cf_clearance",
|
||||
});
|
||||
wafCookies = wafResult.cookies;
|
||||
}
|
||||
}
|
||||
|
||||
// Parse link format: "animeId:episodeNumber"
|
||||
const [animeId, episodeNumber] = id.split(":");
|
||||
@@ -18,61 +36,65 @@ export const getStream = async function ({
|
||||
throw new Error("Invalid link format");
|
||||
}
|
||||
|
||||
const servers = ["pahe", "zoro"]; // Available servers based on API structure
|
||||
const servers = ["sage", "meg", "dio", "kite"];
|
||||
const streamLinks: Stream[] = [];
|
||||
|
||||
await Promise.all(
|
||||
servers.map(async (server) => {
|
||||
try {
|
||||
const url = `${baseUrl}/api/anime/tiddies?server=${server}&id=${animeId}&num=${episodeNumber}&subType=sub`;
|
||||
const url = `${baseUrl}/v2/api/anime/oppai/${animeId}/${episodeNumber}?server=${server}&source_type=sub`;
|
||||
|
||||
const res = await axios.get(url, {
|
||||
headers: {
|
||||
Referer: "https://animetsu.to/",
|
||||
...commonHeaders,
|
||||
Referer: baseUrl,
|
||||
...(wafCookies ? { Cookie: wafCookies } : {}),
|
||||
},
|
||||
});
|
||||
|
||||
if (res.data && res.data.sources) {
|
||||
const subtitles: TextTracks = [];
|
||||
// if (res.data.subtitles && Array.isArray(res.data.subtitles)) {
|
||||
// res.data.subtitles.forEach((sub: any) => {
|
||||
// if (sub.url && sub.lang) {
|
||||
// // Extract language code from lang string (e.g., "English" -> "en", "Arabic - CR" -> "ar")
|
||||
// const langCode = sub.lang.toLowerCase().includes("english")
|
||||
// ? "en"
|
||||
// : sub.lang.toLowerCase().includes("arabic")
|
||||
// ? "ar"
|
||||
// : sub.lang.toLowerCase().includes("french")
|
||||
// ? "fr"
|
||||
// : sub.lang.toLowerCase().includes("german")
|
||||
// ? "de"
|
||||
// : sub.lang.toLowerCase().includes("italian")
|
||||
// ? "it"
|
||||
// : sub.lang.toLowerCase().includes("portuguese")
|
||||
// ? "pt"
|
||||
// : sub.lang.toLowerCase().includes("russian")
|
||||
// ? "ru"
|
||||
// : sub.lang.toLowerCase().includes("spanish")
|
||||
// ? "es"
|
||||
// : "und";
|
||||
if (res.data.subs && Array.isArray(res.data.subs)) {
|
||||
res.data.subs.forEach((sub: any) => {
|
||||
if (sub.url && sub.lang) {
|
||||
const langCode = sub.lang.toLowerCase().includes("english")
|
||||
? "en"
|
||||
: sub.lang.toLowerCase().includes("arabic")
|
||||
? "ar"
|
||||
: sub.lang.toLowerCase().includes("french")
|
||||
? "fr"
|
||||
: sub.lang.toLowerCase().includes("german")
|
||||
? "de"
|
||||
: sub.lang.toLowerCase().includes("italian")
|
||||
? "it"
|
||||
: sub.lang.toLowerCase().includes("portuguese")
|
||||
? "pt"
|
||||
: sub.lang.toLowerCase().includes("russian")
|
||||
? "ru"
|
||||
: sub.lang.toLowerCase().includes("spanish")
|
||||
? "es"
|
||||
: "und";
|
||||
|
||||
// subtitles.push({
|
||||
// title: sub.lang,
|
||||
// language: langCode,
|
||||
// type: "text/vtt",
|
||||
// uri: sub.url,
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
subtitles.push({
|
||||
title: sub.lang,
|
||||
language: langCode,
|
||||
type: "text/vtt",
|
||||
uri: sub.url,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
res.data.sources.forEach((source: any) => {
|
||||
const sourceUrl = source.url.startsWith("/")
|
||||
? `${baseUrl}${source.url}`
|
||||
: source.url;
|
||||
streamLinks.push({
|
||||
server: server + `: ${source.quality}`,
|
||||
link: `https://m3u8.8man.workers.dev?url=${source.url}`,
|
||||
server: `${server} (Sub): ${source.quality}`,
|
||||
link: `https://m3u8.8man.workers.dev?url=${encodeURIComponent(sourceUrl)}`,
|
||||
type: "m3u8",
|
||||
quality: source.quality,
|
||||
headers: {
|
||||
referer: "https://animetsu.to/",
|
||||
referer: baseUrl,
|
||||
},
|
||||
subtitles: subtitles.length > 0 ? subtitles : [],
|
||||
});
|
||||
@@ -81,62 +103,67 @@ export const getStream = async function ({
|
||||
} catch (e) {
|
||||
console.log(`Error with server ${server}:`, e);
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
// Try dub version as well
|
||||
await Promise.all(
|
||||
servers.map(async (server) => {
|
||||
try {
|
||||
const url = `${baseUrl}/api/anime/tiddies?server=${server}&id=${animeId}&num=${episodeNumber}&subType=dub`;
|
||||
const url = `${baseUrl}/v2/api/anime/oppai/${animeId}/${episodeNumber}?server=${server}&source_type=dub`;
|
||||
|
||||
const res = await axios.get(url, {
|
||||
headers: {
|
||||
referer: "https://animetsu.to/",
|
||||
...commonHeaders,
|
||||
Referer: baseUrl,
|
||||
...(wafCookies ? { Cookie: wafCookies } : {}),
|
||||
},
|
||||
});
|
||||
|
||||
if (res.data && res.data.sources) {
|
||||
const subtitles: TextTracks = [];
|
||||
// if (res.data.subtitles && Array.isArray(res.data.subtitles)) {
|
||||
// res.data.subtitles.forEach((sub: any) => {
|
||||
// if (sub.url && sub.lang) {
|
||||
// // Extract language code from lang string (e.g., "English" -> "en", "Arabic - CR" -> "ar")
|
||||
// const langCode = sub.lang.toLowerCase().includes("english")
|
||||
// ? "en"
|
||||
// : sub.lang.toLowerCase().includes("arabic")
|
||||
// ? "ar"
|
||||
// : sub.lang.toLowerCase().includes("french")
|
||||
// ? "fr"
|
||||
// : sub.lang.toLowerCase().includes("german")
|
||||
// ? "de"
|
||||
// : sub.lang.toLowerCase().includes("italian")
|
||||
// ? "it"
|
||||
// : sub.lang.toLowerCase().includes("portuguese")
|
||||
// ? "pt"
|
||||
// : sub.lang.toLowerCase().includes("russian")
|
||||
// ? "ru"
|
||||
// : sub.lang.toLowerCase().includes("spanish")
|
||||
// ? "es"
|
||||
// : "und";
|
||||
if (res.data.subs && Array.isArray(res.data.subs)) {
|
||||
res.data.subs.forEach((sub: any) => {
|
||||
if (sub.url && sub.lang) {
|
||||
// Extract language code from lang string (e.g., "English" -> "en", "Arabic - CR" -> "ar")
|
||||
const langCode = sub.lang.toLowerCase().includes("english")
|
||||
? "en"
|
||||
: sub.lang.toLowerCase().includes("arabic")
|
||||
? "ar"
|
||||
: sub.lang.toLowerCase().includes("french")
|
||||
? "fr"
|
||||
: sub.lang.toLowerCase().includes("german")
|
||||
? "de"
|
||||
: sub.lang.toLowerCase().includes("italian")
|
||||
? "it"
|
||||
: sub.lang.toLowerCase().includes("portuguese")
|
||||
? "pt"
|
||||
: sub.lang.toLowerCase().includes("russian")
|
||||
? "ru"
|
||||
: sub.lang.toLowerCase().includes("spanish")
|
||||
? "es"
|
||||
: "und";
|
||||
|
||||
// subtitles.push({
|
||||
// title: sub.lang,
|
||||
// language: langCode,
|
||||
// type: "text/vtt",
|
||||
// uri: sub.url,
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
subtitles.push({
|
||||
title: sub.lang,
|
||||
language: langCode,
|
||||
type: "text/vtt",
|
||||
uri: sub.url,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
res.data.sources.forEach((source: any) => {
|
||||
const sourceUrl = source.url.startsWith("/")
|
||||
? `${baseUrl}${source.url}`
|
||||
: source.url;
|
||||
streamLinks.push({
|
||||
server: `${server} (Dub) : ${source.quality}`,
|
||||
link: `https://m3u8.8man.workers.dev?url=${source.url}`,
|
||||
server: `${server} (Dub): ${source.quality}`,
|
||||
link: `https://m3u8.8man.workers.dev?url=${encodeURIComponent(sourceUrl)}`,
|
||||
type: "m3u8",
|
||||
quality: source.quality,
|
||||
headers: {
|
||||
referer: "https://animetsu.to/",
|
||||
referer: baseUrl,
|
||||
},
|
||||
subtitles: subtitles.length > 0 ? subtitles : [],
|
||||
});
|
||||
@@ -145,7 +172,7 @@ export const getStream = async function ({
|
||||
} catch (e) {
|
||||
console.log(`Error with server ${server} (dub):`, e);
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
console.log("Stream links:", streamLinks);
|
||||
|
||||
Reference in New Issue
Block a user