mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-29 16:07:40 +01:00
some css
This commit is contained in:
parent
1c03b11808
commit
964b412053
4 changed files with 107 additions and 100 deletions
|
@ -0,0 +1,59 @@
|
||||||
|
@font-face {
|
||||||
|
font-family: 'JetBrainsMono';
|
||||||
|
src: url(../fonts/JetBrainsMono-Regular.woff2);
|
||||||
|
font-weight: 400;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
html, body {
|
||||||
|
height: 1vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
color: #95979F;
|
||||||
|
background-color: #0c0e14;
|
||||||
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23586ca8' fill-opacity='0.12'%3E%3Cpath d='M0 38.59l2.83-2.83 1.41 1.41L1.41 40H0v-1.41zM0 1.4l2.83 2.83 1.41-1.41L1.41 0H0v1.41zM38.59 40l-2.83-2.83 1.41-1.41L40 38.59V40h-1.41zM40 1.41l-2.83 2.83-1.41-1.41L38.59 0H40v1.41zM20 18.6l2.83-2.83 1.41 1.41L21.41 20l2.83 2.83-1.41 1.41L20 21.41l-2.83 2.83-1.41-1.41L18.59 20l-2.83-2.83 1.41-1.41L20 18.59z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
|
||||||
|
font-family: 'JetBrainsMono';
|
||||||
|
}
|
||||||
|
|
||||||
|
.messages {
|
||||||
|
background-color: #2D313D;
|
||||||
|
border-radius: 10px;
|
||||||
|
width: 80%;
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
color: #f3565d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
color: #2e5bbd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding: 1rem;
|
||||||
|
border-radius: 10px;
|
||||||
|
background-color: #2D313D;
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.video {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
background-color: #2D313D;
|
||||||
|
padding: 5px;
|
||||||
|
width: 300px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="submit"] {
|
||||||
|
width: 20%;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="text"] {
|
||||||
|
width: 70%;
|
||||||
|
}
|
BIN
assets/fonts/JetBrainsMono-Regular.woff2
Normal file
BIN
assets/fonts/JetBrainsMono-Regular.woff2
Normal file
Binary file not shown.
|
@ -1,18 +1,12 @@
|
||||||
const cfg = {
|
function getCorsUrl(url) {
|
||||||
base: "https://hidden-inlet-27205.herokuapp.com/https://lookmovie.io"
|
return `https://hidden-inlet-27205.herokuapp.com/${url}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getVideoUrl(config) {
|
async function getVideoUrl(config) {
|
||||||
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 = null;
|
let url = getCorsUrl(`https://lookmovie.io/manifests/movies/json/${config.movieId}/${now}/${accessToken}/master.m3u8`);
|
||||||
|
|
||||||
if (config.type === "tv") {
|
|
||||||
url = `${cfg.base}/manifests/shows/json/${accessToken}/${now}/${config.episodeId}/master.m3u8`;
|
|
||||||
} else if (config.type === "movie") {
|
|
||||||
url = `${cfg.base}/manifests/movies/json/${config.movieId}/${now}/${accessToken}/master.m3u8`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
const videoOpts = await fetch(url).then((d) => d.json());
|
const videoOpts = await fetch(url).then((d) => d.json());
|
||||||
|
@ -27,22 +21,14 @@ async function getVideoUrl(config) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return videoUrl.startsWith("/") ? `${cfg.base}${videoUrl}` : videoUrl;
|
return videoUrl.startsWith("/") ? getCorsUrl(`https://lookmovie.io/${videoUrl}`) : getCorsUrl(videoUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Invalid type.";
|
return "Invalid type.";
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAccessToken(config) {
|
async function getAccessToken(config) {
|
||||||
let url = "";
|
let url = getCorsUrl(`https://lookmovie.io/api/v1/security/movie-access?id_movie=${config.movieId}&token=1&sk=&step=1`);
|
||||||
|
|
||||||
if (config.type === "tv") {
|
|
||||||
// 'mbQFYTR499c9vfDmAwOFrg' // Retrieved from: https://lookmovie.io/api/v1/security/show-access?slug=1839578-person-of-interest-2011&token=&step=2
|
|
||||||
url = `${cfg.base}/api/v1/security/show-access?slug=${config.slug}&token=&step=2`;
|
|
||||||
} else if (config.type === "movie") {
|
|
||||||
// https://lookmovie.io/api/v1/security/movie-access?id_movie=14358&token=1&sk=&step=1
|
|
||||||
url = `${cfg.base}/api/v1/security/movie-access?id_movie=${config.movieId}&token=1&sk=&step=1`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await fetch(url).then((d) => d.json());
|
const data = await fetch(url).then((d) => d.json());
|
||||||
|
|
||||||
|
@ -55,27 +41,13 @@ async function getAccessToken(config) {
|
||||||
async function findMovie() {
|
async function findMovie() {
|
||||||
const searchTerm = document.getElementById('search').value;
|
const searchTerm = document.getElementById('search').value;
|
||||||
|
|
||||||
const movieSearchRes = await fetch(
|
sendMessage('info', `Searching for "${searchTerm}"`)
|
||||||
`https://hidden-inlet-27205.herokuapp.com/https://lookmovie.io/api/v1/movies/search/?q=${encodeURIComponent(
|
|
||||||
searchTerm
|
|
||||||
)}`
|
|
||||||
).then((d) => d.json());
|
|
||||||
const showSearchRes = await fetch(
|
|
||||||
`https://hidden-inlet-27205.herokuapp.com/https://lookmovie.io/api/v1/shows/search/?q=${encodeURIComponent(
|
|
||||||
searchTerm
|
|
||||||
)}`
|
|
||||||
).then((d) => d.json());
|
|
||||||
|
|
||||||
let results = [
|
const searchUrl = getCorsUrl(`https://lookmovie.io/api/v1/movies/search/?q=${encodeURIComponent(searchTerm)}`);
|
||||||
...movieSearchRes.result.map((v) => ({ ...v, type: "movie" })),
|
const searchRes = await fetch(searchUrl).then((d) => d.json());
|
||||||
...showSearchRes.result.map((v) => ({ ...v, type: "show" })),
|
let results = [ ...searchRes.result.map((v) => ({ ...v, type: "movie" })) ];
|
||||||
];
|
|
||||||
|
|
||||||
const fuse = new Fuse(results, {
|
const fuse = new Fuse(results, { threshold: 0.3, distance: 200, keys: ["title"] });
|
||||||
threshold: 0.3,
|
|
||||||
distance: 200,
|
|
||||||
keys: ["title"],
|
|
||||||
});
|
|
||||||
const matchedResults = fuse
|
const matchedResults = fuse
|
||||||
.search(searchTerm.toString())
|
.search(searchTerm.toString())
|
||||||
.map((result) => result.item);
|
.map((result) => result.item);
|
||||||
|
@ -89,81 +61,46 @@ async function findMovie() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!toShow) {
|
if (!toShow) {
|
||||||
document.getElementById('error').innerHTML = 'Unable to find that, sorry!'
|
sendMessage('error', 'Unable to find that, sorry!')
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Scraping the ${toShow.type} "${toShow.title}"`);
|
sendMessage('info', `Scraping the ${toShow.type} "${toShow.title}"`)
|
||||||
|
|
||||||
// ! Now we get the ID and stuff we need
|
const url = getCorsUrl(`https://lookmovie.io/${toShow.type}s/view/${toShow.slug}`);
|
||||||
const url = `https://hidden-inlet-27205.herokuapp.com/https://lookmovie.io/${toShow.type}s/view/${toShow.slug}`;
|
|
||||||
const pageReq = await fetch(url).then((d) => d.text());
|
const pageReq = await fetch(url).then((d) => d.text());
|
||||||
|
|
||||||
// Extract and parse JSON
|
const data = JSON5.parse("{" +
|
||||||
let scriptJson =
|
|
||||||
"{" +
|
|
||||||
pageReq
|
pageReq
|
||||||
.slice(pageReq.indexOf(`${toShow.type}_storage`))
|
.slice(pageReq.indexOf(`${toShow.type}_storage`))
|
||||||
.split("};")[0]
|
.split("};")[0]
|
||||||
.split("= {")[1]
|
.split("= {")[1]
|
||||||
.trim() +
|
.trim() +
|
||||||
"}";
|
"}"
|
||||||
|
);
|
||||||
|
|
||||||
const data = JSON5.parse(scriptJson);
|
const videoUrl = await getVideoUrl({
|
||||||
|
slug: toShow.slug,
|
||||||
|
movieId: data.id_movie,
|
||||||
|
type: "movie",
|
||||||
|
});
|
||||||
|
|
||||||
// Find the relevant id
|
sendMessage('info', `Streaming "${toShow.title}"`)
|
||||||
let id = null;
|
streamVideo(videoUrl)
|
||||||
let relevantEpisode;
|
}
|
||||||
if (toShow.type === "movie") {
|
|
||||||
id = data.id_movie;
|
|
||||||
} else if (toShow.type === "show") {
|
|
||||||
const episodeObj = data.seasons.find((v) => {
|
|
||||||
return v.season == season && v.episode == episode;
|
|
||||||
});
|
|
||||||
if (episodeObj) {
|
|
||||||
console.log(
|
|
||||||
`Finding streams for ${toShow.title} ${season}x${episode}: ${episodeObj.title}`
|
|
||||||
);
|
|
||||||
id = episodeObj.id_episode;
|
|
||||||
relevantEpisode = episodeObj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check ID
|
function sendMessage(type, message) {
|
||||||
if (id === null) {
|
if (!['info', 'error'].includes(type)) return;
|
||||||
console.error(`Not found: S${season} E${episode}`);
|
document.getElementById(type).innerHTML += `${message}<br>`;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Generate object to send over to scraper
|
|
||||||
let reqObj = null;
|
|
||||||
if (toShow.type === "show") {
|
|
||||||
reqObj = {
|
|
||||||
slug: toShow.slug,
|
|
||||||
episodeId: id,
|
|
||||||
type: "tv",
|
|
||||||
};
|
|
||||||
} else if (toShow.type === "movie") {
|
|
||||||
reqObj = {
|
|
||||||
slug: toShow.slug,
|
|
||||||
movieId: id,
|
|
||||||
type: "movie",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!reqObj) {
|
|
||||||
document.getElementById('error').innerHTML = 'Invalid type!'
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const videoUrl = await getVideoUrl(reqObj);
|
|
||||||
|
|
||||||
|
function streamVideo(url) {
|
||||||
var video = document.getElementById('video');
|
var video = document.getElementById('video');
|
||||||
var videoSrc = `https://hidden-inlet-27205.herokuapp.com/${videoUrl}`;
|
|
||||||
if (Hls.isSupported()) {
|
if (Hls.isSupported()) {
|
||||||
var video = document.getElementById('video');
|
var video = document.getElementById('video');
|
||||||
var hls = new Hls();
|
var hls = new Hls();
|
||||||
hls.attachMedia(video);
|
hls.attachMedia(video);
|
||||||
hls.loadSource(videoSrc);
|
hls.loadSource(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
23
index.html
23
index.html
|
@ -5,19 +5,30 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>movie-web</title>
|
<title>movie-web</title>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="./assets/css/style.css" type="text/css">
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
|
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/fuse.js@6.4.6"></script>
|
<script src="https://cdn.jsdelivr.net/npm/fuse.js@6.4.6"></script>
|
||||||
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
||||||
<script src="assets/js/index.js"></script>
|
<script src="assets/js/index.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id='errorContainer'>
|
<form action='#' onsubmit='findMovie();return false;'>
|
||||||
<h2 id='error'></h2>
|
<input type='text' id='search' placeholder='Find movie...'><!--
|
||||||
|
--><input type='submit'>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div class='content'>
|
||||||
|
<video id="video" class="video" controls autoplay></video>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input id="search" placeholder="Find movie..."><!--
|
<div class='messages'>
|
||||||
--><button onclick=findMovie()>find movie</button>
|
<strong>
|
||||||
|
<p id='error' class='error'></p>
|
||||||
<video id="video" controls autoplay style="width: 80%"></video>
|
<p id='info' class='info'></p>
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in a new issue