refactor: Remove commented-out HTML parsing code
This commit is contained in:
+3
-99
@@ -9,50 +9,6 @@ async function searchResults(keyword) {
|
||||
const response = await soraFetch(searchApiUrl);
|
||||
const text = response.text ? await response.text() : await response;
|
||||
|
||||
// parse html
|
||||
/* <div class="col-6 col-md-4 col-lg-2">
|
||||
<a href="https://s.to/serie/pluribus-glck-ist-ansteckend" class="text-decoration-none">
|
||||
<div class="card cover-card h-100 border-0 shadow-sm">
|
||||
<a href="https://s.to/serie/pluribus-glck-ist-ansteckend" class="d-block show-cover">
|
||||
<picture>
|
||||
|
||||
<source type="image/avif" srcset="
|
||||
https://s.to/media/images/channel/mobile/pluribus-glck-ist-ansteckend-tombd2cv?format=avif 375w,
|
||||
https://s.to/media/images/channel/tablet/pluribus-glck-ist-ansteckend-tombd2cv?format=avif 768w,
|
||||
https://s.to/media/images/channel/desktop/pluribus-glck-ist-ansteckend-tombd2cv?format=avif 1024w
|
||||
" sizes="(max-width: 600px) 375px,
|
||||
(max-width: 992px) 768px,
|
||||
1024px">
|
||||
|
||||
|
||||
<source type="image/webp" srcset="
|
||||
https://s.to/media/images/channel/mobile/pluribus-glck-ist-ansteckend-tombd2cv?format=webp 375w,
|
||||
https://s.to/media/images/channel/tablet/pluribus-glck-ist-ansteckend-tombd2cv?format=webp 768w,
|
||||
https://s.to/media/images/channel/desktop/pluribus-glck-ist-ansteckend-tombd2cv?format=webp 1024w
|
||||
" sizes="(max-width: 600px) 375px,
|
||||
(max-width: 992px) 768px,
|
||||
1024px">
|
||||
|
||||
|
||||
<img src="https://s.to/media/images/channel/desktop/pluribus-glck-ist-ansteckend-tombd2cv?format=jpg"
|
||||
srcset="
|
||||
https://s.to/media/images/channel/desktop/pluribus-glck-ist-ansteckend-tombd2cv?format=jpg 1x,
|
||||
https://s.to/media/images/channel/2x-desktop/pluribus-glck-ist-ansteckend-tombd2cv?format=jpg 2x
|
||||
" alt="Pluribus - Glück ist ansteckend" class="img-fluid w-100">
|
||||
</picture>
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
<div class="card-body py-2 p-1">
|
||||
<h6 class="show-title mb-0 small" title="Pluribus - Glück ist ansteckend">Pluribus - Glück ist
|
||||
ansteckend</h6>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
...
|
||||
*/
|
||||
const searchRegex = /<a\s+href="([^"]+)"\s+class="d-block\s+show-cover"[\s\S]*?<img\s+src="([^"]+)"[\s\S]*?class="show-title[^"]*"[^>]*>([\s\S]*?)<\//g;
|
||||
const results = [];
|
||||
let match;
|
||||
@@ -95,15 +51,6 @@ async function extractDetails(url) {
|
||||
const airdateMatch = yearMatch ? `${yearMatch[1]}` : 'Unknown Year';
|
||||
|
||||
|
||||
// get genres
|
||||
/* <li class="series-group">
|
||||
<strong class="me-1">Genre:</strong>
|
||||
|
||||
|
||||
<a href="https://s.to/genre/science-fiction" class="link-light">Science Fiction</a>, <a href="https://s.to/genre/comedy" class="link-light">Comedy</a>, <a href="https://s.to/genre/drama" class="link-light">Drama</a>
|
||||
|
||||
</li>
|
||||
*/
|
||||
const genresRegex = /<li class="series-group">\s*<strong class="me-1">Genre:<\/strong>([\s\S]*?)<\/li>/;
|
||||
const genresMatch = genresRegex.exec(text);
|
||||
let genres = '';
|
||||
@@ -165,7 +112,7 @@ async function extractEpisodes(url) {
|
||||
|
||||
async function extractStreamUrl(url) {
|
||||
try {
|
||||
const language = [2, 4, 3]; // Englisch Dub, Eng-Sub, Ger-Sub
|
||||
const language = [2 ,4, 3]; // Prioritize languages: 1=Deutsch, 3=Ger-Sub, 2=Englisch, 4=Eng-Sub
|
||||
|
||||
const fetchUrl = `${url}`;
|
||||
const response = await soraFetch(fetchUrl);
|
||||
@@ -281,17 +228,7 @@ function getSeasonLinks(html) {
|
||||
const seasonMatch = seasonRegex.exec(html);
|
||||
if (seasonMatch) {
|
||||
const seasonList = seasonMatch[1];
|
||||
/* <a
|
||||
href="https://s.to/serie/dexter/staffel-1"
|
||||
class="alphabet-link nav-link bg-primary "
|
||||
data-season-pill="1"
|
||||
> 1 </a>
|
||||
<a
|
||||
href="https://s.to/serie/dexter/staffel-2"
|
||||
class="alphabet-link nav-link "
|
||||
data-season-pill="2"
|
||||
> 2 </a>
|
||||
*/
|
||||
|
||||
const seasonLinkRegex = /<a\s+[^>]*?href="([^"]+)"[^>]*?class="[^"]*alphabet-link/g;
|
||||
let seasonLinkMatch;
|
||||
const filmeLinks = [];
|
||||
@@ -323,27 +260,7 @@ async function fetchSeasonEpisodes(url) {
|
||||
const episodeList = [];
|
||||
if (episodeDivMatch) {
|
||||
const episodeListHtml = episodeDivMatch[1];
|
||||
/* <li class="nav-item me-1 mb-2">
|
||||
<a href="https://s.to/serie/dexter/staffel-1/episode-1"
|
||||
class=" alphabet-link nav-link ">
|
||||
1
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item me-1 mb-2">
|
||||
<a href="https://s.to/serie/dexter/staffel-1/episode-2"
|
||||
class=" alphabet-link nav-link ">
|
||||
2
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item me-1 mb-2">
|
||||
<a href="https://s.to/serie/dexter/staffel-1/episode-3"
|
||||
class=" alphabet-link nav-link ">
|
||||
3
|
||||
</a>
|
||||
</li>
|
||||
*/
|
||||
|
||||
const episodeLinkRegex = /<a\s+[^>]*?href="([^"]+)"[^>]*?class="[^"]*alphabet-link[^"]*"[^>]*>\s*([\s\S]*?)\s*<\/a>/g;
|
||||
let episodeLinkMatch;
|
||||
let number = 0;
|
||||
@@ -375,19 +292,6 @@ async function fetchSeasonEpisodes(url) {
|
||||
function getVideoLinks(html) {
|
||||
const baseUrl = 'https://s.to';
|
||||
|
||||
// get links based on button:
|
||||
/* <button type="button"
|
||||
class="link-box btn btn-dark w-100 text-start gap-2"
|
||||
data-link-id="21778990"
|
||||
data-play-url="/r?t=eyJpdiI6IjRBTHNuWGVqekFjMVBzK09rREhqelE9PSIsInZhbHVlIjoiMzBnQjZJSW5INHBhWm1qNk9UdGVGYkR0Nyt4Mm1iVlYwRkk5TWFGNEpjaFdDcGJkSW11dTRSeE5RcndqRlJ5SWtXSitHVzFJc0pPSU9rdjBaa3RxUUE9PSIsIm1hYyI6IjM4ZDAxMjgyZWQ5ODYzYWZhODVlODJmMDAyNGMxZDcwODg3NTI0NDJjYWM2YjNlMTM5OGE5YWEzYWMzZjdiNWYiLCJ0YWciOiIifQ%3D%3D"
|
||||
data-auto-embed="1"
|
||||
data-provider-name="VOE"
|
||||
data-language-label="Deutsch"
|
||||
data-language-id="1"
|
||||
>
|
||||
...
|
||||
</button>
|
||||
*/
|
||||
const videoLinks = [];
|
||||
const videoLinkRegex = /<button\s+type="button"[^>]*?class="link-box btn btn-dark w-100 text-start gap-2"[^>]*?data-play-url="([^"]+)"[^>]*?data-provider-name="([^"]+)"[^>]*?data-language-id="([^"]+)"[^>]*?>/g;
|
||||
let videoLinkMatch;
|
||||
|
||||
Reference in New Issue
Block a user