Update toonitalia/toonitalia.js

This commit is contained in:
aka paul 2025-11-02 15:27:57 +00:00
parent 28c025cd86
commit e8ce789f0b

View file

@ -1,3 +1,10 @@
function cleanTitle(title) {
return title
.replace(/’/g, "'")
.replace(/–/g, "-")
.replace(/&#[0-9]+;/g, "");
}
async function searchResults(keyword) {
const results = [];
try {
@ -8,7 +15,7 @@ async function searchResults(keyword) {
let match;
while ((match = regex.exec(html)) !== null) {
results.push({
title: match[2].trim(),
title: cleanTitle(match[2].trim()),
image: match[3] ? match[3].trim() : "",
href: match[1].trim()
});
@ -86,12 +93,35 @@ async function extractEpisodes(url) {
async function extractStreamUrl(url) {
const response = await fetchv2(url);
const html = await response.text();
let streamData = null;
const htmlOne = await response.text();
streamData = voeExtractor(html);
console.log("Voe Stream Data: " + streamData);
return streamData;
const redirectMatch = htmlOne.match(/window\.location\.href\s*=\s*['"]([^'"]+)['"]/);
if (!redirectMatch) {
console.log("No redirect URL found");
return null;
}
const redirectUrl = redirectMatch[1];
console.log("Redirect URL: " + redirectUrl);
const actualResponse = await fetchv2(redirectUrl);
const html = await actualResponse.text();
let streamUrl = voeExtractor(html);
console.log("Voe Stream Data: " + streamUrl);
return JSON.stringify({
streams: [
{
title: "Server 1",
streamUrl: streamUrl,
headers: {
Referer: redirectUrl
}
}
],
subtitle: "https://none.com"
});
}
/* SCHEME START */