Fixed s.to

This commit is contained in:
JMcrafter26 2025-12-08 19:27:48 +01:00
parent da75042805
commit dcd7c03ef2
10 changed files with 2682 additions and 19 deletions

View file

@ -6,7 +6,8 @@ async function searchResults(keyword) {
try {
const encodedKeyword = encodeURIComponent(keyword);
const searchApiUrl = `https://s.to/ajax/seriesSearch?keyword=${encodedKeyword}`;
const responseText = await fetch(searchApiUrl);
const response = await soraFetch(searchApiUrl);
const responseText = await response?.text() ?? response;
const data = await JSON.parse(responseText);
@ -27,7 +28,7 @@ async function searchResults(keyword) {
async function extractDetails(url) {
try {
const fetchUrl = `${url}`;
const response = await fetch(fetchUrl);
const response = await soraFetch(fetchUrl);
const text = response.text ? await response.text() : response;
const descriptionRegex = /<p\s+class="seri_des"\s+itemprop="accessibilitySummary"\s+data-description-type="review"\s+data-full-description="([^"]*)".*?>(.*?)<\/p>/s;
@ -40,11 +41,15 @@ async function extractDetails(url) {
}
const descriptionMatch = descriptionRegex.exec(text) || [];
// sanitize description by removing HTML tags
let description = descriptionMatch[1] || '';
description = description.replace(/<[^>]+>/g, '').trim();
const airdateMatch = "Unknown"; // TODO: Implement airdate extraction
const transformedResults = [{
description: descriptionMatch[1] || 'No description available',
description: description || 'No description available',
aliases: aliasesArray[0] || 'No aliases available',
airdate: airdateMatch
}];
@ -64,16 +69,18 @@ async function extractEpisodes(url) {
try {
const baseUrl = 'https://s.to';
const fetchUrl = `${url}`;
const response = await fetch(fetchUrl);
const response = await soraFetch(fetchUrl);
const html = response.text ? await response.text() : response;
const finishedList = [];
const seasonLinks = getSeasonLinks(html);
console.log("Season Links: " + JSON.stringify(seasonLinks));
for (const seasonLink of seasonLinks) {
const seasonEpisodes = await fetchSeasonEpisodes(`${baseUrl}${seasonLink}`);
finishedList.push(...seasonEpisodes);
}
console.log("Finished Episode List: " + JSON.stringify(finishedList));
// Replace the field "number" with the current index of each item, starting from 1
finishedList.forEach((item, index) => {
@ -94,7 +101,7 @@ async function extractStreamUrl(url) {
try {
const baseUrl = 'https://s.to';
const fetchUrl = `${url}`;
const response = await fetch(fetchUrl);
const response = await soraFetch(fetchUrl);
const text = response.text ? await response.text() : response;
const finishedList = [];
@ -125,7 +132,7 @@ async function extractStreamUrl(url) {
const providerName = value;
// fetch the provider link and extract the stream URL
const streamUrl = await fetch(providerLink);
const streamUrl = await soraFetch(providerLink);
console.log("Stream URL: " + streamUrl);
const winLocRegex = /window\.location\.href\s*=\s*['"]([^'"]+)['"]/;
const winLocMatch = await winLocRegex.exec(streamUrl);
@ -195,9 +202,11 @@ function selectHoster(finishedList) {
// "https://speedfiles.net/82346fs": "speedfiles",
// };
console.log("Hoster List: " + JSON.stringify(finishedList));
// Define the preferred providers and languages
const providerList = ["VOE", "SpeedFiles", "Vidmoly", "DoodStream", "Vidoza", "MP4Upload"];
const languageList = ["Englisch", "mit Untertitel Englisch", "Deutsch", "mit Untertitel Deutsch"];
const providerList = ["VOE", "SpeedFiles", "Filemoon", "Vidmoly", "DoodStream", "Vidoza", "MP4Upload"];
const languageList = ["English", "mit Untertitel Deutsch", "mit Untertitel Englisch"];
@ -263,10 +272,14 @@ async function fetchSeasonEpisodes(url) {
try {
const baseUrl = 'https://s.to';
const fetchUrl = `${url}`;
const text = await fetch(fetchUrl);
const response = await soraFetch(fetchUrl);
const text = await response?.text() ?? response;
// Updated regex to allow empty <strong> content
const regex = /<td class="seasonEpisodeTitle">\s*<a[^>]*href="([^"]+)"[^>]*>.*?<strong>([^<]*)<\/strong>.*?<span>([^<]+)<\/span>.*?<\/a>/g;
const regex2 =
/<td[^>]*seasonEpisodeTitle[^>]*>\s*<a[^>]*href=["']([^"']+)["'][^>]*>[\s\S]*?<strong>\s*([^<]*?)\s*<\/strong>[\s\S]*?(?:<span[^>]*>\s*([^<]*?)\s*<\/span>)?[\s\S]*?<\/a>/gi;
const matches = [];
let match;
@ -277,6 +290,16 @@ async function fetchSeasonEpisodes(url) {
matches.push({ number: holderNumber, href: `${baseUrl}${link}` });
}
// If no matches found with the first regex, try the second one
if (matches.length === 0) {
console.log("No matches found with first regex, trying second regex.");
while ((match = regex2.exec(text)) !== null) {
const [_, link] = match;
console.log("Match found with second regex: " + link);
matches.push({ number: holderNumber, href: `${baseUrl}${link}` });
}
}
return matches;
} catch (error) {
@ -348,6 +371,7 @@ function base64Decode(str) {
}
// ⚠️ DO NOT EDIT BELOW THIS LINE ⚠️
// EDITING THIS FILE COULD BREAK THE UPDATER AND CAUSE ISSUES WITH THE EXTRACTOR