From 8d91170ff5a04a3789adcb5210b8e1b1c0bf5dc1 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Mon, 19 Jul 2021 15:32:40 +0100 Subject: [PATCH 1/7] gomostream initial work --- src/lib/gomostream.js | 45 +++++++++++++++++++++++++++++++++++++++++++ src/lib/lookMovie.js | 13 ++++++++++++- src/views/Search.js | 13 +++---------- 3 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 src/lib/gomostream.js diff --git a/src/lib/gomostream.js b/src/lib/gomostream.js new file mode 100644 index 00000000..954a9333 --- /dev/null +++ b/src/lib/gomostream.js @@ -0,0 +1,45 @@ +const CORS_URL = 'https://hidden-inlet-27205.herokuapp.com/'; +const BASE_URL = `${CORS_URL}https://gomo.to`; +const MOVIE_URL = `${BASE_URL}/movie` +const DECODING_URL = `${BASE_URL}/decoding_v3.php` + +async function findContent(searchTerm, type) { + try { + if (type !== 'movie') return; + + const term = searchTerm.toLowerCase() + const imdbRes = await fetch(`${CORS_URL}https://v2.sg.media-imdb.com/suggestion/${term.slice(0, 1)}/${term}.json`).then(d => d.json()) + const movieId = imdbRes.d[0]?.id + if(!movieId) { + return; + } + console.log(imdbRes, movieId) + + // Get stream to go with IMDB ID + const site1 = await fetch(`${MOVIE_URL}/${movieId}`).then((d) => d.text()); + + const tc = site1.match(/var tc = '(.+)';/)?.[1] + const _token = site1.match(/"_token": "(.+)",/)?.[1] + + const fd = new FormData() + fd.append('tokenCode', tc) + fd.append('_token', _token) + + const src = await fetch(DECODING_URL, { + method: "POST", + body: fd, + headers: { + 'x-token': tc.slice(5, 13).split("").reverse().join("") + "13574199" + } + }).then((d) => d.json()); + + console.log(src); + const embedUrl = src.find(url => url.includes('gomo.to')); + const site2 = await fetch(`${CORS_URL}${embedUrl}`).then((d) => d.text()); + } catch (err) { + console.log(err); + throw new Error(err) + } +} + +export { findContent } \ No newline at end of file diff --git a/src/lib/lookMovie.js b/src/lib/lookMovie.js index 6166c7dc..55047c33 100644 --- a/src/lib/lookMovie.js +++ b/src/lib/lookMovie.js @@ -66,7 +66,18 @@ async function getEpisodes(slug) { "}" ); - return data.seasons + let seasons, episodes = []; + + data.forEach((e) => { + if (!seasons.includes(e.season)) + seasons.push(e.season); + + if (!episodes[e.season]) + episodes[e.season] = [] + episodes[e.season].push(e.episode) + }) + + return { seasons, episodes } } async function getStreamUrl(slug, type, season, episode) { diff --git a/src/views/Search.js b/src/views/Search.js index c0232aea..c50d9a58 100644 --- a/src/views/Search.js +++ b/src/views/Search.js @@ -40,16 +40,9 @@ export function SearchView() { let seasons = []; let episodes = []; if (type === "show") { - const episodeData = await getEpisodes(slug); - episodeData.forEach((e) => { - if (!seasons.includes(e.season)) - seasons.push(e.season); - - if (!episodes[e.season]) - episodes[e.season] = [] - episodes[e.season].push(e.episode) - - }) + const data = await getEpisodes(slug); + seasons = data.seasons; + episodes = data.episodes; } let realUrl = ''; From 7ee63c4c7f7b34b89a5f3c3cd6cbe9efc56ede8a Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Mon, 19 Jul 2021 22:26:49 +0100 Subject: [PATCH 2/7] gomostream works! we don't want to use this ever though. --- src/components/VideoElement.js | 42 ++++++++++------- src/lib/gomostream.js | 85 +++++++++++++++++++++++----------- src/lib/unpacker.js | 46 ++++++++++++++++++ src/views/Search.js | 3 +- 4 files changed, 132 insertions(+), 44 deletions(-) create mode 100644 src/lib/unpacker.js diff --git a/src/components/VideoElement.js b/src/components/VideoElement.js index 35ec011a..9d26ff50 100644 --- a/src/components/VideoElement.js +++ b/src/components/VideoElement.js @@ -10,21 +10,23 @@ export function VideoElement({ streamUrl, loading, setProgress }) { const [error, setError] = React.useState(false); React.useEffect(() => { - setError(false) - if (!videoRef || !videoRef.current || !streamUrl || streamUrl.length === 0 || loading) return; - - const hls = new Hls(); - - if (!Hls.isSupported() && videoRef.current.canPlayType('application/vnd.apple.mpegurl')) { - videoRef.current.src = streamUrl; - return; - } else if (!Hls.isSupported()) { - setError(true) - return; + if (!streamUrl.endsWith('.mp4')) { + setError(false) + if (!videoRef || !videoRef.current || !streamUrl || streamUrl.length === 0 || loading) return; + + const hls = new Hls(); + + if (!Hls.isSupported() && videoRef.current.canPlayType('application/vnd.apple.mpegurl')) { + videoRef.current.src = streamUrl; + return; + } else if (!Hls.isSupported()) { + setError(true) + return; + } + + hls.attachMedia(videoRef.current); + hls.loadSource(streamUrl); } - - hls.attachMedia(videoRef.current); - hls.loadSource(streamUrl); }, [videoRef, streamUrl, loading]) if (error) @@ -36,7 +38,13 @@ export function VideoElement({ streamUrl, loading, setProgress }) { if (!streamUrl || streamUrl.length === 0) return No video selected - return ( -