fix: s.to module - add base URL to relative links and images, update version to 0.4.2
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@
|
||||
"icon": "https://files.catbox.moe/ttj4fc.gif",
|
||||
"url": "https://github.com/JMcrafter26"
|
||||
},
|
||||
"version": "0.4.1",
|
||||
"version": "0.4.2",
|
||||
"language": "English (DUB)",
|
||||
"streamType": "HLS",
|
||||
"quality": "720p",
|
||||
|
||||
+21
-3
@@ -4,6 +4,7 @@
|
||||
|
||||
async function searchResults(keyword) {
|
||||
try {
|
||||
const baseUrl = 'https://s.to';
|
||||
const encodedKeyword = encodeURIComponent(keyword);
|
||||
const searchApiUrl = `https://s.to/suche?term=${encodedKeyword}`;
|
||||
const response = await soraFetch(searchApiUrl);
|
||||
@@ -15,11 +16,11 @@ async function searchResults(keyword) {
|
||||
while ((match = searchRegex.exec(text)) !== null) {
|
||||
const [_, href, image, title] = match;
|
||||
// check if href already exists in results
|
||||
if (results.some(result => result.href === href.trim())) {
|
||||
continue;
|
||||
if (results.some(result => result.href === baseUrl + href.trim())) {
|
||||
continue; // skip if href already exists
|
||||
}
|
||||
|
||||
results.push({ title: title.trim(), image: image.trim(), href: href.trim() });
|
||||
results.push({ title: title.trim(), image: baseUrl + image.trim(), href: baseUrl + href.trim() });
|
||||
}
|
||||
|
||||
|
||||
@@ -223,6 +224,7 @@ async function sendLog(message) {
|
||||
// Site specific structure
|
||||
function getSeasonLinks(html) {
|
||||
const seasonLinks = [];
|
||||
const baseUrl = 'https://s.to';
|
||||
// <nav class="mb-2" id="season-nav"> <ul class="nav list-items-nav">
|
||||
const seasonRegex = /<nav class="mb-2" id="season-nav">[\s\S]*?<ul class="nav list-items-nav">([\s\S]*?)<\/ul>/;
|
||||
|
||||
@@ -245,6 +247,13 @@ function getSeasonLinks(html) {
|
||||
seasonLinks.push(...filmeLinks);
|
||||
}
|
||||
|
||||
// if starts with /, add baseUrl
|
||||
for (let i = 0; i < seasonLinks.length; i++) {
|
||||
if (seasonLinks[i].startsWith('/')) {
|
||||
seasonLinks[i] = baseUrl + seasonLinks[i];
|
||||
}
|
||||
}
|
||||
|
||||
return seasonLinks;
|
||||
}
|
||||
|
||||
@@ -252,6 +261,7 @@ function getSeasonLinks(html) {
|
||||
// Site specific structure
|
||||
async function fetchSeasonEpisodes(url) {
|
||||
try {
|
||||
const baseUrl = 'https://s.to';
|
||||
const fetchUrl = `${url}`;
|
||||
const response = await soraFetch(fetchUrl);
|
||||
const text = await response?.text() ?? await response;
|
||||
@@ -273,6 +283,14 @@ async function fetchSeasonEpisodes(url) {
|
||||
}
|
||||
console.log("Episode List for season " + url + ": " + JSON.stringify(episodeList));
|
||||
}
|
||||
|
||||
// if starts with /, add baseUrl
|
||||
for (let i = 0; i < episodeList.length; i++) {
|
||||
if (episodeList[i].href.startsWith('/')) {
|
||||
episodeList[i].href = baseUrl + episodeList[i].href;
|
||||
}
|
||||
}
|
||||
|
||||
return episodeList;
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
"icon": "https://files.catbox.moe/ttj4fc.gif",
|
||||
"url": "https://github.com/JMcrafter26"
|
||||
},
|
||||
"version": "0.4.1",
|
||||
"version": "0.4.2",
|
||||
"language": "German (DUB)",
|
||||
"streamType": "HLS",
|
||||
"quality": "720p",
|
||||
|
||||
+21
-3
@@ -4,6 +4,7 @@
|
||||
|
||||
async function searchResults(keyword) {
|
||||
try {
|
||||
const baseUrl = 'https://s.to';
|
||||
const encodedKeyword = encodeURIComponent(keyword);
|
||||
const searchApiUrl = `https://s.to/suche?term=${encodedKeyword}`;
|
||||
const response = await soraFetch(searchApiUrl);
|
||||
@@ -15,11 +16,11 @@ async function searchResults(keyword) {
|
||||
while ((match = searchRegex.exec(text)) !== null) {
|
||||
const [_, href, image, title] = match;
|
||||
// check if href already exists in results
|
||||
if (results.some(result => result.href === href.trim())) {
|
||||
continue;
|
||||
if (results.some(result => result.href === baseUrl + href.trim())) {
|
||||
continue; // skip if href already exists
|
||||
}
|
||||
|
||||
results.push({ title: title.trim(), image: image.trim(), href: href.trim() });
|
||||
results.push({ title: title.trim(), image: baseUrl + image.trim(), href: baseUrl + href.trim() });
|
||||
}
|
||||
|
||||
|
||||
@@ -223,6 +224,7 @@ async function sendLog(message) {
|
||||
// Site specific structure
|
||||
function getSeasonLinks(html) {
|
||||
const seasonLinks = [];
|
||||
const baseUrl = 'https://s.to';
|
||||
// <nav class="mb-2" id="season-nav"> <ul class="nav list-items-nav">
|
||||
const seasonRegex = /<nav class="mb-2" id="season-nav">[\s\S]*?<ul class="nav list-items-nav">([\s\S]*?)<\/ul>/;
|
||||
|
||||
@@ -245,6 +247,13 @@ function getSeasonLinks(html) {
|
||||
seasonLinks.push(...filmeLinks);
|
||||
}
|
||||
|
||||
// if starts with /, add baseUrl
|
||||
for (let i = 0; i < seasonLinks.length; i++) {
|
||||
if (seasonLinks[i].startsWith('/')) {
|
||||
seasonLinks[i] = baseUrl + seasonLinks[i];
|
||||
}
|
||||
}
|
||||
|
||||
return seasonLinks;
|
||||
}
|
||||
|
||||
@@ -252,6 +261,7 @@ function getSeasonLinks(html) {
|
||||
// Site specific structure
|
||||
async function fetchSeasonEpisodes(url) {
|
||||
try {
|
||||
const baseUrl = 'https://s.to';
|
||||
const fetchUrl = `${url}`;
|
||||
const response = await soraFetch(fetchUrl);
|
||||
const text = await response?.text() ?? await response;
|
||||
@@ -273,6 +283,14 @@ async function fetchSeasonEpisodes(url) {
|
||||
}
|
||||
console.log("Episode List for season " + url + ": " + JSON.stringify(episodeList));
|
||||
}
|
||||
|
||||
// if starts with /, add baseUrl
|
||||
for (let i = 0; i < episodeList.length; i++) {
|
||||
if (episodeList[i].href.startsWith('/')) {
|
||||
episodeList[i].href = baseUrl + episodeList[i].href;
|
||||
}
|
||||
}
|
||||
|
||||
return episodeList;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user