From 65d27c3f6a5669778d08bd859c7b95c6cb7493c4 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Sun, 2 Jan 2022 16:34:08 +0000 Subject: [PATCH] Fix theflix redirect --- src/lib/scraper/theflix.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/scraper/theflix.js b/src/lib/scraper/theflix.js index 565e02d5..1d63e177 100644 --- a/src/lib/scraper/theflix.js +++ b/src/lib/scraper/theflix.js @@ -95,7 +95,15 @@ async function getEpisodes(slug) { } async function getStreamUrl(slug, type, season, episode) { - const res = await fetch(`${BASE_URL}/${type === 'show' ? 'tv-show' : type}/${slug}/${type === 'show' ? `season-${season}/episode-${episode}` : ""}${ type === 'movie' ? '?movieInfo=' + slug : '' }`).then(d => d.text()); + let url; + + if (type === 'show') { + url = `${BASE_URL}/tv-show/${slug}/season-${season}/episode-${episode}`; + } else { + url = `${BASE_URL}/movie/${slug}?movieInfo=${slug}`; + } + + const res = await fetch(url).then(d => d.text()); const scripts = Array.from(new DOMParser().parseFromString(res, "text/html").querySelectorAll('script')); const prop = scripts.find((e) => e.textContent.includes("theflixvd.b-cdn"));