diff --git a/package.json b/package.json
index 29118a46..b0bec93e 100644
--- a/package.json
+++ b/package.json
@@ -7,6 +7,7 @@
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
+ "crypto-js": "^4.0.0",
"fuse.js": "^6.4.6",
"hls.js": "^1.0.7",
"json5": "^2.2.0",
diff --git a/src/components/EpisodeSelector.js b/src/components/EpisodeSelector.js
index aac45e27..e1f98117 100644
--- a/src/components/EpisodeSelector.js
+++ b/src/components/EpisodeSelector.js
@@ -3,7 +3,7 @@ import { TypeSelector } from './TypeSelector';
import { NumberSelector } from './NumberSelector';
import './EpisodeSelector.css'
-export function EpisodeSelector({ setSeason, setEpisode, seasons, season, episodes, currentSeason, currentEpisode, slug }) {
+export function EpisodeSelector({ setSeason, setEpisode, seasons, season, episodes, currentSeason, currentEpisode, slug, source }) {
const choices = episodes.map(v => {
@@ -12,7 +12,7 @@ export function EpisodeSelector({ setSeason, setEpisode, seasons, season, episod
let currentlyAt = 0;
let totalDuration = 0;
- const progress = progressData?.lookmovie?.show?.slug?.[`${season}-${v}`]
+ const progress = progressData?.[source]?.show?.slug?.[`${season}-${v}`]
if(progress) {
currentlyAt = progress.currentlyAt
totalDuration = progress.totalDuration
diff --git a/src/components/MovieRow.js b/src/components/MovieRow.js
index 9473dfa0..00219e19 100644
--- a/src/components/MovieRow.js
+++ b/src/components/MovieRow.js
@@ -11,7 +11,7 @@ export function MovieRow(props) {
let progress;
let percentage = null;
if(props.type === "movie") {
- progress = progressData?.lookmovie?.movie?.[props.slug]?.full
+ progress = progressData?.[props.source]?.movie?.[props.slug]?.full
if(progress) {
percentage = Math.floor((progress.currentlyAt / progress.totalDuration) * 100)
}
@@ -24,6 +24,7 @@ export function MovieRow(props) {
({props.year})
+
{props.source}
Watch {props.type}
diff --git a/src/lib/gomostream.js b/src/lib/gomostream.js
index 9c81036f..04e2998b 100644
--- a/src/lib/gomostream.js
+++ b/src/lib/gomostream.js
@@ -1,4 +1,4 @@
-import { unpack } from './unpacker';
+import { unpack } from './util/unpacker';
const CORS_URL = 'https://hidden-inlet-27205.herokuapp.com/';
const BASE_URL = `${CORS_URL}https://gomo.to`;
@@ -20,17 +20,18 @@ async function findContent(searchTerm, type) {
title: e.l,
slug: e.id,
type: 'movie',
- year: e.y
+ year: e.y,
+ source: 'gomostream'
})
});
if (results.length > 1) {
return { options: results };
} else {
- return { options: [results[0]] }
+ return { options: [ { ...results[0], source: 'gomostream' } ] }
}
} catch (err) {
- console.log(err);
+ console.error(err);
throw new Error(err)
}
}
@@ -41,6 +42,9 @@ async function getStreamUrl(slug, type, season, episode) {
// Get stream to go with IMDB ID
const site1 = await fetch(`${MOVIE_URL}/${slug}`).then((d) => d.text());
+ if (site1 === "Movie not available.")
+ return { url: '' };
+
const tc = site1.match(/var tc = '(.+)';/)?.[1]
const _token = site1.match(/"_token": "(.+)",/)?.[1]
@@ -71,4 +75,5 @@ async function getStreamUrl(slug, type, season, episode) {
return { url }
}
-export { findContent, getStreamUrl }
\ No newline at end of file
+const gomostream = { findContent, getStreamUrl }
+export default gomostream;
\ No newline at end of file
diff --git a/src/lib/index.js b/src/lib/index.js
index 7e1ccfc9..27915eca 100644
--- a/src/lib/index.js
+++ b/src/lib/index.js
@@ -1,16 +1,44 @@
import lookMovie from './lookMovie';
-// import gomostream from './gomostream';
+import gomostream from './gomostream';
async function findContent(searchTerm, type) {
- return await lookMovie.findContent(searchTerm, type);
+ const results = { options: []};
+ const content = await Promise.all([
+ lookMovie.findContent(searchTerm, type),
+ gomostream.findContent(searchTerm, type)
+ ]);
+
+ content.forEach((o) => {
+ if (!o || !o.options) return;
+
+ o.options.forEach((i) => {
+ if (!i) return;
+ results.options.push(i)
+ })
+ });
+
+ return results;
}
-async function getStreamUrl(slug, type, season, episode) {
- return await lookMovie.getStreamUrl(slug, type, season, episode);
+async function getStreamUrl(slug, type, source, season, episode) {
+ switch (source) {
+ case 'lookmovie':
+ return await lookMovie.getStreamUrl(slug, type, season, episode);
+ case 'gomostream':
+ return await gomostream.getStreamUrl(slug, type, season, episode);
+ default:
+ return;
+ }
}
-async function getEpisodes(slug) {
- return await lookMovie.getEpisodes(slug);
+async function getEpisodes(slug, source) {
+ switch (source) {
+ case 'lookmovie':
+ return await lookMovie.getEpisodes(slug);
+ case 'gomostream':
+ default:
+ return;
+ }
}
export { findContent, getStreamUrl, getEpisodes }
\ No newline at end of file
diff --git a/src/lib/lookMovie.js b/src/lib/lookMovie.js
index 7bd0c8fb..0aa8ab9d 100644
--- a/src/lib/lookMovie.js
+++ b/src/lib/lookMovie.js
@@ -17,23 +17,19 @@ async function getVideoUrl(config) {
url = getCorsUrl(`https://lookmovie.io/manifests/shows/json/${accessToken}/${now}/${config.id}/master.m3u8`);
}
- if (url) {
- const videoOpts = await fetch(url).then((d) => d.json());
+ const videoOpts = await fetch(url).then((d) => d.json());
- // Find video URL and return it (with a check for a full url if needed)
- const opts = ["1080p", "1080", "720p", "720", "480p", "480", "auto"]
+ // Find video URL and return it (with a check for a full url if needed)
+ const opts = ["1080p", "1080", "720p", "720", "480p", "480", "auto"]
- let videoUrl = "";
- for (let res of opts) {
- if (videoOpts[res] && !videoOpts[res].includes('dummy') && !videoOpts[res].includes('earth-1984') && !videoUrl) {
- videoUrl = videoOpts[res]
- }
+ let videoUrl = "";
+ for (let res of opts) {
+ if (videoOpts[res] && !videoOpts[res].includes('dummy') && !videoOpts[res].includes('earth-1984') && !videoUrl) {
+ videoUrl = videoOpts[res]
}
-
- return videoUrl.startsWith("/") ? getCorsUrl(`https://lookmovie.io/${videoUrl}`) : getCorsUrl(videoUrl);
}
- return "Invalid type.";
+ return videoUrl.startsWith("/") ? `https://lookmovie.io${videoUrl}` : videoUrl;
}
async function getAccessToken(config) {
@@ -151,7 +147,8 @@ async function findContent(searchTerm, type) {
title: r.title,
slug: r.slug,
type: r.type,
- year: r.year
+ year: r.year,
+ source: 'lookmovie'
}));
return res;
@@ -159,7 +156,7 @@ async function findContent(searchTerm, type) {
const { title, slug, type, year } = matchedResults[0];
return {
- options: [{ title, slug, type, year }]
+ options: [{ title, slug, type, year, source: 'lookmovie' }]
}
}
}
diff --git a/src/lib/unpacker.js b/src/lib/util/unpacker.js
similarity index 100%
rename from src/lib/unpacker.js
rename to src/lib/util/unpacker.js
diff --git a/src/views/Movie.js b/src/views/Movie.js
index 7e7d9c74..4ad94786 100644
--- a/src/views/Movie.js
+++ b/src/views/Movie.js
@@ -43,7 +43,7 @@ export function MovieView(props) {
}
setLoading(true);
- getStreamUrl(streamData.slug, streamData.type, episode.season, episode.episode)
+ getStreamUrl(streamData.slug, streamData.type, streamData.source, episode.season, episode.episode)
.then(({url}) => {
if (cancel) return;
setStreamUrl(url)
@@ -106,6 +106,7 @@ export function MovieView(props) {
slug={streamData.slug}
currentSeason={season}
currentEpisode={episode}
+ source={streamData.source}
/>
: ''}
diff --git a/src/views/Search.js b/src/views/Search.js
index 2dd5aedb..b2a0da8a 100644
--- a/src/views/Search.js
+++ b/src/views/Search.js
@@ -30,7 +30,7 @@ export function SearchView() {
setFailed(true)
}
- async function getStream(title, slug, type) {
+ async function getStream(title, slug, type, source) {
setStreamUrl("");
try {
@@ -40,14 +40,15 @@ export function SearchView() {
let seasons = [];
let episodes = [];
if (type === "show") {
- const data = await getEpisodes(slug);
+ const data = await getEpisodes(slug, source);
seasons = data.seasons;
episodes = data.episodes;
}
let realUrl = '';
if (type === "movie") {
- const { url } = await getStreamUrl(slug, type);
+ // getStreamUrl(slug, type, source, season, episode)
+ const { url } = await getStreamUrl(slug, type, source);
if (url === '') {
return fail(`Not found: ${title}`)
@@ -62,7 +63,8 @@ export function SearchView() {
type,
seasons,
episodes,
- slug
+ slug,
+ source
})
setText(`Streaming...`)
navigate("movie")
@@ -79,7 +81,7 @@ export function SearchView() {
setShowingOptions(false)
try {
- const { options } = await findContent(query, contentType)
+ const { options } = await findContent(query, contentType);
if (options.length === 0) {
return fail(`Could not find that ${contentType}`)
@@ -91,9 +93,10 @@ export function SearchView() {
return;
}
- const { title, slug, type } = options[0];
- getStream(title, slug, type);
+ const { title, slug, type, source } = options[0];
+ getStream(title, slug, type, source);
} catch (err) {
+ console.error(err);
fail(`Failed to watch ${contentType}`)
}
}
@@ -134,9 +137,9 @@ export function SearchView() {
Whoops, there are a few {type}s like that
{options?.map((v, i) => (
- {
+ {
setShowingOptions(false)
- getStream(v.title, v.slug, v.type, v.season, v.episode)
+ getStream(v.title, v.slug, v.type, v.source)
}}/>
))}
diff --git a/yarn.lock b/yarn.lock
index 7b138a93..786af3aa 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3654,6 +3654,11 @@ crypto-browserify@^3.11.0:
randombytes "^2.0.0"
randomfill "^1.0.3"
+crypto-js@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.0.0.tgz#2904ab2677a9d042856a2ea2ef80de92e4a36dcc"
+ integrity sha512-bzHZN8Pn+gS7DQA6n+iUmBfl0hO5DJq++QP3U6uTucDtk/0iGpXd/Gg7CGR0p8tJhofJyaKoWBuJI4eAO00BBg==
+
crypto-random-string@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e"