185 lines
5.8 KiB
JavaScript
185 lines
5.8 KiB
JavaScript
function cleanTitle(title) {
|
|
return title
|
|
.replace(/’/g, "'")
|
|
.replace(/–/g, "-")
|
|
.replace(/&#[0-9]+;/g, "");
|
|
}
|
|
|
|
async function searchResults(keyword) {
|
|
const results = [];
|
|
try {
|
|
const response = await fetchv2("https://wwv.monoschinos2.net/animes?buscar=" + encodeURIComponent(keyword));
|
|
const html = await response.text();
|
|
|
|
const regex = /<li class="col mb-5 ficha_efecto">.*?<a href="([^"]+)" title="([^"]+)">.*?<img[^>]+src="([^"]+)"/gs;
|
|
|
|
let match;
|
|
while ((match = regex.exec(html)) !== null) {
|
|
results.push({
|
|
href: match[1].trim().replace("./", "https://wwv.monoschinos2.net/"),
|
|
title: cleanTitle(match[2].trim().replace(" Online Gratis", "").replace("Ver Anime", "")),
|
|
image: match[3].trim()
|
|
});
|
|
}
|
|
|
|
return JSON.stringify(results);
|
|
} catch (err) {
|
|
return JSON.stringify([{
|
|
title: "Error",
|
|
image: "Error",
|
|
href: "Error"
|
|
}]);
|
|
}
|
|
}
|
|
|
|
async function extractDetails(url) {
|
|
try {
|
|
const response = await fetchv2(url);
|
|
const html = await response.text();
|
|
|
|
const match = html.match(/<div class="mb-3">\s*<p>(.*?)<\/p>/s);
|
|
const description = match ? match[1].trim() : "N/A";
|
|
|
|
return JSON.stringify([{
|
|
description: description,
|
|
aliases: "N/A",
|
|
airdate: "N/A"
|
|
}]);
|
|
} catch (err) {
|
|
return JSON.stringify([{
|
|
description: "Error",
|
|
aliases: "Error",
|
|
airdate: "Error"
|
|
}]);
|
|
}
|
|
}
|
|
|
|
async function extractEpisodes(url) {
|
|
const results = [];
|
|
try {
|
|
const parts = url.split('/');
|
|
const u = parts[parts.length - 1] || parts[parts.length - 2];
|
|
|
|
const initialResponse = await fetchv2(url);
|
|
const html = await initialResponse.text();
|
|
const iMatch = html.match(/data-i="(\d+)"/);
|
|
const i = iMatch ? iMatch[1] : null;
|
|
|
|
console.log("Slug:" + u);
|
|
console.log("Data-i:" + i);
|
|
|
|
if (!i) throw new Error("data-i not found");
|
|
|
|
let page = 1;
|
|
let episodeCount = 0;
|
|
|
|
while (true) {
|
|
const formData = `acc=episodes&i=${i}&u=${u}&p=${page}`;
|
|
console.log("Form Data: " + formData);
|
|
const headers = {
|
|
"X-Requested-With": "XMLHttpRequest",
|
|
"Referer": "https://vww.monoschinos2.net/",
|
|
"Host": "vww.monoschinos2.net",
|
|
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
|
};
|
|
const response = await fetchv2("https://wwv.monoschinos2.net/ajax_pagination", headers, "POST", formData);
|
|
const pageHtml = await response.text();
|
|
console.log(pageHtml);
|
|
if (!pageHtml.trim()) break;
|
|
|
|
const regex = /<a class="ko" href="([^"]+)"/g;
|
|
let match;
|
|
while ((match = regex.exec(pageHtml)) !== null) {
|
|
episodeCount++;
|
|
results.push({
|
|
href: match[1].trim(),
|
|
number: episodeCount
|
|
});
|
|
}
|
|
|
|
page++;
|
|
}
|
|
|
|
const total = results.length;
|
|
results.forEach((ep, index) => {
|
|
ep.number = total - index;
|
|
});
|
|
|
|
return JSON.stringify(results.reverse());
|
|
} catch (err) {
|
|
return JSON.stringify({
|
|
slug: "Error",
|
|
dataI: "Error",
|
|
episodes: [{
|
|
href: "Error",
|
|
number: "Error"
|
|
}]
|
|
});
|
|
}
|
|
}
|
|
|
|
async function extractStreamUrl(url) {
|
|
try {
|
|
const response = await fetchv2(url);
|
|
const html = await response.text();
|
|
|
|
const encryptMatch = html.match(/data-encrypt="([^"]+)"/);
|
|
if (!encryptMatch) return JSON.stringify({ streams: [], subtitle: "" });
|
|
const iValue = encryptMatch[1];
|
|
|
|
const formData = `acc=opt&i=${iValue}`;
|
|
const headers = {
|
|
"X-Requested-With": "XMLHttpRequest",
|
|
"Referer": url,
|
|
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
|
};
|
|
const domain = url.match(/https?:\/\/[^/]+/)[0];
|
|
const optResp = await fetchv2(`${domain}/ajax_pagination`, headers, "POST", formData);
|
|
const optHtml = await optResp.text();
|
|
|
|
const mp4uploadMatch = optHtml.match(/data-player="([^"]+)"[^>]*>mp4upload/i);
|
|
if (mp4uploadMatch) {
|
|
const playerUrl = atob(mp4uploadMatch[1]);
|
|
const playerResp = await fetchv2(playerUrl);
|
|
const playerHtml = await playerResp.text();
|
|
|
|
const mp4Match = playerHtml.match(/src:\s*"([^"]+\.mp4[^"]*)"/);
|
|
if (mp4Match) {
|
|
return JSON.stringify({
|
|
streams: [{
|
|
title: "Mp4Upload",
|
|
streamUrl: mp4Match[1],
|
|
headers: { "Referer": "https://mp4upload.com/" }
|
|
}],
|
|
subtitle: ""
|
|
});
|
|
}
|
|
}
|
|
|
|
return JSON.stringify({ streams: [], subtitle: "" });
|
|
} catch (error) {
|
|
return JSON.stringify({ streams: [], subtitle: "" });
|
|
}
|
|
}
|
|
|
|
function atob(input) {
|
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
let str = '';
|
|
let buffer = 0;
|
|
let bits = 0;
|
|
for (let i = 0; i < input.length; i++) {
|
|
const char = input.charAt(i);
|
|
if (char === '=') break;
|
|
const index = chars.indexOf(char);
|
|
if (index === -1) continue;
|
|
buffer = (buffer << 6) | index;
|
|
bits += 6;
|
|
if (bits >= 8) {
|
|
bits -= 8;
|
|
str += String.fromCharCode((buffer >> bits) & 0xFF);
|
|
buffer &= (1 << bits) - 1;
|
|
}
|
|
}
|
|
return str;
|
|
}
|