1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-20 14:37:43 +01:00

shows work!

This commit is contained in:
James Hawkins 2021-07-14 17:31:35 +01:00
parent 19891569b7
commit 32a8518193
5 changed files with 75 additions and 27 deletions

View file

@ -42,11 +42,10 @@
outline: none; outline: none;
background-color: #36363e; background-color: #36363e;
color: white; color: white;
padding: .7rem; padding: .7rem 1rem;
height: auto; height: auto;
width: 20%; width: 25%;
color: white; color: white;
font-weight: bold; font-weight: bold;
cursor: pointer; cursor: pointer;
} }
@ -56,7 +55,6 @@
outline: none; outline: none;
background-color: #36363e; background-color: #36363e;
color: white; color: white;
/* padding: .7rem 1.5rem; */
height: auto; height: auto;
width: 5%; width: 5%;
box-sizing: border-box; box-sizing: border-box;
@ -74,6 +72,10 @@
background-color: #3C3D44; background-color: #3C3D44;
} }
.inputOptionBox:hover {
background-color: #3C3D44;
}
.inputSearchButton .text > .arrow { .inputSearchButton .text > .arrow {
opacity: 0; opacity: 0;
transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out; transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
@ -116,11 +118,19 @@
} }
.inputTextBox { .inputTextBox {
margin-top: .5rem;
width: 100%; width: 100%;
} }
.inputDropdown { .inputDropdown {
width: 100%; width: 100%;
margin-bottom: .5rem; padding: .7rem 1.5rem;
}
.inputOptionBox {
margin-top: .5rem;
width: 50%;
align-items:stretch;
padding: .7rem 1.5rem;
} }
} }

View file

@ -6,13 +6,15 @@ import './InputBox.css'
export function InputBox({ onSubmit, placeholder }) { export function InputBox({ onSubmit, placeholder }) {
const [searchTerm, setSearchTerm] = React.useState(""); const [searchTerm, setSearchTerm] = React.useState("");
const [type, setType] = React.useState("movie"); const [type, setType] = React.useState("movie");
const [season, setSeason] = React.useState("");
const [episode, setEpisode] = React.useState("");
const showContentType = type === "show" ? false : true; const showContentType = type === "show" ? false : true;
return ( return (
<form className="inputBar" onSubmit={(e) => { <form className="inputBar" onSubmit={(e) => {
e.preventDefault(); e.preventDefault();
onSubmit(searchTerm, type) onSubmit(searchTerm, type, season, episode)
return false; return false;
}}> }}>
<select name="type" id="type" className="inputDropdown" onChange={(e) => setType(e.target.value)} required> <select name="type" id="type" className="inputDropdown" onChange={(e) => setType(e.target.value)} required>
@ -28,8 +30,25 @@ export function InputBox({ onSubmit, placeholder }) {
onChange={(e) => setSearchTerm(e.target.value)} onChange={(e) => setSearchTerm(e.target.value)}
required required
/> />
<input type='text' className='inputOptionBox' id='inputOptionBoxSeason' placeholder='s' required={showContentType} hidden={showContentType}/> <input
<input type='text' className='inputOptionBox' id='inputOptionBoxEpisode' placeholder='e' required={showContentType} hidden={showContentType}/> type='text'
className='inputOptionBox'
id='inputOptionBoxSeason'
placeholder='season'
value={season}
onChange={(e) => setSeason(e.target.value)}
hidden={showContentType}
required={!showContentType}
/>
<input
type='text'
className='inputOptionBox'
id='inputOptionBoxEpisode'
placeholder='episode'
value={episode}
onChange={(e) => setEpisode(e.target.value)}
hidden={showContentType}
required={!showContentType} />
<button className="inputSearchButton"><span className="text">Search<span className="arrow"><Arrow /></span></span></button> <button className="inputSearchButton"><span className="text">Search<span className="arrow"><Arrow /></span></span></button>
</form> </form>
) )

View file

@ -6,10 +6,17 @@ function getCorsUrl(url) {
} }
async function getVideoUrl(config) { async function getVideoUrl(config) {
// return getCorsUrl('https://vdoc1.sallenes.space/_eTeNnlOAFdWb-gPYTiQfg/1626297249/storage3/shows/0413573-greys-anatomy-2005/6-S1E1-1553949090/720p/v2-index.m3u8');
const accessToken = await getAccessToken(config); const accessToken = await getAccessToken(config);
const now = Math.floor(Date.now() / 1e3); const now = Math.floor(Date.now() / 1e3);
let url = getCorsUrl(`https://lookmovie.io/manifests/movies/json/${config.movieId}/${now}/${accessToken}/master.m3u8`); let url = '';
if (config.type === 'movie') {
url = getCorsUrl(`https://lookmovie.io/manifests/movies/json/${config.id}/${now}/${accessToken}/master.m3u8`);
} else if (config.type === 'show') {
url = getCorsUrl(`https://lookmovie.io/manifests/shows/json/${accessToken}/${now}/${config.id}/master.m3u8`);
}
if (url) { if (url) {
const videoOpts = await fetch(url).then((d) => d.json()); const videoOpts = await fetch(url).then((d) => d.json());
@ -31,7 +38,13 @@ async function getVideoUrl(config) {
} }
async function getAccessToken(config) { async function getAccessToken(config) {
let url = getCorsUrl(`https://lookmovie.io/api/v1/security/movie-access?id_movie=${config.movieId}&token=1&sk=&step=1`); let url = '';
if (config.type === 'movie') {
url = getCorsUrl(`https://lookmovie.io/api/v1/security/movie-access?id_movie=${config.id}&token=1&sk=&step=1`);
} else if (config.type === 'show') {
url = getCorsUrl(`https://lookmovie.io/api/v1/security/show-access?slug=${config.slug}&token=&step=2`);
}
const data = await fetch(url).then((d) => d.json()); const data = await fetch(url).then((d) => d.json());
@ -41,7 +54,7 @@ async function getAccessToken(config) {
return "Invalid type provided in config"; return "Invalid type provided in config";
} }
async function getStreamUrl(slug, type) { async function getStreamUrl(slug, type, season, episode) {
const url = getCorsUrl(`https://lookmovie.io/${type}s/view/${slug}`); const url = getCorsUrl(`https://lookmovie.io/${type}s/view/${slug}`);
const pageReq = await fetch(url).then((d) => d.text()); const pageReq = await fetch(url).then((d) => d.text());
@ -54,9 +67,21 @@ async function getStreamUrl(slug, type) {
"}" "}"
); );
let id = '';
if (type === "movie") {
id = data.id_movie;
} else if (type === "show") {
const episodeObj = data.seasons.find((v) => { return v.season === season && v.episode === episode; });
if (episodeObj) {
id = episodeObj.id_episode;
}
}
const videoUrl = await getVideoUrl({ const videoUrl = await getVideoUrl({
slug: slug, slug: slug,
movieId: data.id_movie, id: id,
type: type, type: type,
}); });
@ -64,9 +89,9 @@ async function getStreamUrl(slug, type) {
} }
async function findContent(searchTerm, type) { async function findContent(searchTerm, type) {
const searchUrl = getCorsUrl(`https://lookmovie.io/api/v1/movies/search/?q=${encodeURIComponent(searchTerm)}`); const searchUrl = getCorsUrl(`https://lookmovie.io/api/v1/${type}s/search/?q=${encodeURIComponent(searchTerm)}`);
const searchRes = await fetch(searchUrl).then((d) => d.json()); const searchRes = await fetch(searchUrl).then((d) => d.json());
let results = [...searchRes.result.map((v) => ({ ...v, type: "movie" }))]; const results = [...searchRes.result.map((v) => ({ ...v, type: type}))];
const fuse = new Fuse(results, { threshold: 0.3, distance: 200, keys: ["title"] }); const fuse = new Fuse(results, { threshold: 0.3, distance: 200, keys: ["title"] });
const matchedResults = fuse const matchedResults = fuse

View file

@ -55,10 +55,6 @@ function registerValidSW(swUrl, config) {
// At this point, the updated precached content has been fetched, // At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older // but the previous service worker will still serve the older
// content until all client tabs are closed. // content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://cra.link/PWA.'
);
// Execute callback // Execute callback
if (config && config.onUpdate) { if (config && config.onUpdate) {
@ -68,7 +64,6 @@ function registerValidSW(swUrl, config) {
// At this point, everything has been precached. // At this point, everything has been precached.
// It's the perfect time to display a // It's the perfect time to display a
// "Content is cached for offline use." message. // "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback // Execute callback
if (config && config.onSuccess) { if (config && config.onSuccess) {
@ -108,7 +103,6 @@ function checkValidServiceWorker(swUrl, config) {
} }
}) })
.catch(() => { .catch(() => {
console.log('No internet connection found. App is running in offline mode.');
}); });
} }

View file

@ -26,12 +26,12 @@ export function SearchView() {
setFailed(true) setFailed(true)
} }
async function getStream(title, slug, type) { async function getStream(title, slug, type, season, episode) {
setStreamUrl(""); setStreamUrl("");
try { try {
setProgress(2); setProgress(2);
setText(`Getting stream for "${title}"`) setText(`Getting stream for "${title}"`)
const { url } = await getStreamUrl(slug, type); const { url } = await getStreamUrl(slug, type, season, episode);
setProgress(maxSteps); setProgress(maxSteps);
setStreamUrl(url); setStreamUrl(url);
setStreamData({ setStreamData({
@ -45,9 +45,9 @@ export function SearchView() {
} }
} }
async function searchMovie(query, contentType) { async function searchMovie(query, contentType, season, episode) {
setFailed(false); setFailed(false);
setText(`Searching for ${contentType} "${query}"`); setText(`Searching for ${contentType} "${query}" ${contentType === 'show' ? ` (${season}x${episode})` : ''}`);
setProgress(1) setProgress(1)
setShowingOptions(false) setShowingOptions(false)
@ -65,7 +65,7 @@ export function SearchView() {
} }
const { title, slug, type } = options[0]; const { title, slug, type } = options[0];
getStream(title, slug, type); getStream(title, slug, type, season, episode);
} catch (err) { } catch (err) {
fail(`Failed to watch ${contentType}`) fail(`Failed to watch ${contentType}`)
} }
@ -77,7 +77,7 @@ export function SearchView() {
<Title accent="Because watching content legally is boring"> <Title accent="Because watching content legally is boring">
What do you wanna watch? What do you wanna watch?
</Title> </Title>
<InputBox placeholder="Hamilton" onSubmit={(str, type) => searchMovie(str, type)} /> <InputBox placeholder="Hamilton" onSubmit={(str, type, season, episode) => searchMovie(str, type, season, episode)} />
<Progress show={progress > 0} failed={failed} progress={progress} steps={maxSteps} text={text} /> <Progress show={progress > 0} failed={failed} progress={progress} steps={maxSteps} text={text} />
</Card> </Card>