mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-29 16:07:40 +01:00
cleanup
This commit is contained in:
parent
0528531bb5
commit
8c78cec211
7 changed files with 101 additions and 82 deletions
|
@ -1,5 +1,4 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
// import { Arrow } from './Arrow';
|
|
||||||
import './TypeSelector.css'
|
import './TypeSelector.css'
|
||||||
|
|
||||||
// setType: (txt: string) => void
|
// setType: (txt: string) => void
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { unpacker } from './unpacker';
|
import { unpack } from './unpacker';
|
||||||
|
|
||||||
const CORS_URL = 'https://hidden-inlet-27205.herokuapp.com/';
|
const CORS_URL = 'https://hidden-inlet-27205.herokuapp.com/';
|
||||||
const BASE_URL = `${CORS_URL}https://gomo.to`;
|
const BASE_URL = `${CORS_URL}https://gomo.to`;
|
||||||
const MOVIE_URL = `${BASE_URL}/movie`
|
const MOVIE_URL = `${BASE_URL}/movie`
|
||||||
const DECODING_URL = `${BASE_URL}/decoding_v3.php`
|
const DECODING_URL = `${BASE_URL}/decoding_v3.php`
|
||||||
|
|
||||||
async function findContentGomo(searchTerm, type) {
|
async function findContent(searchTerm, type) {
|
||||||
try {
|
try {
|
||||||
if (type !== 'movie') return;
|
if (type !== 'movie') return;
|
||||||
|
|
||||||
|
@ -29,17 +29,13 @@ async function findContentGomo(searchTerm, type) {
|
||||||
} else {
|
} else {
|
||||||
return { options: [results[0]] }
|
return { options: [results[0]] }
|
||||||
}
|
}
|
||||||
|
|
||||||
// const movieId = imdbRes.d[0]?.id
|
|
||||||
// if (!movieId) return;
|
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
throw new Error(err)
|
throw new Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getStreamUrlGomo(slug, type, season, episode) {
|
async function getStreamUrl(slug, type, season, episode) {
|
||||||
if (type !== 'movie') return;
|
if (type !== 'movie') return;
|
||||||
|
|
||||||
// Get stream to go with IMDB ID
|
// Get stream to go with IMDB ID
|
||||||
|
@ -67,7 +63,7 @@ async function getStreamUrlGomo(slug, type, season, episode) {
|
||||||
const site2Dom = parser.parseFromString(site2, "text/html");
|
const site2Dom = parser.parseFromString(site2, "text/html");
|
||||||
const script = site2Dom.querySelectorAll("script")[8].innerHTML;
|
const script = site2Dom.querySelectorAll("script")[8].innerHTML;
|
||||||
|
|
||||||
let unpacked = unpacker.unpack(script).split('');
|
let unpacked = unpack(script).split('');
|
||||||
unpacked.splice(0, 43);
|
unpacked.splice(0, 43);
|
||||||
let index = unpacked.findIndex((e) => e === '"');
|
let index = unpacked.findIndex((e) => e === '"');
|
||||||
const url = unpacked.slice(0, index).join('');
|
const url = unpacked.slice(0, index).join('');
|
||||||
|
@ -75,4 +71,4 @@ async function getStreamUrlGomo(slug, type, season, episode) {
|
||||||
return { url }
|
return { url }
|
||||||
}
|
}
|
||||||
|
|
||||||
export { findContentGomo, getStreamUrlGomo }
|
export { findContent, getStreamUrl }
|
16
src/lib/index.js
Normal file
16
src/lib/index.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import lookMovie from './lookMovie';
|
||||||
|
// import gomostream from './gomostream';
|
||||||
|
|
||||||
|
async function findContent(searchTerm, type) {
|
||||||
|
return await lookMovie.findContent(searchTerm, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getStreamUrl(slug, type, season, episode) {
|
||||||
|
return await lookMovie.getStreamUrl(slug, type, season, episode);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getEpisodes(slug) {
|
||||||
|
return await lookMovie.getEpisodes(slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { findContent, getStreamUrl, getEpisodes }
|
|
@ -66,9 +66,9 @@ async function getEpisodes(slug) {
|
||||||
"}"
|
"}"
|
||||||
);
|
);
|
||||||
|
|
||||||
let seasons, episodes = [];
|
let seasons = [];
|
||||||
|
let episodes = [];
|
||||||
data.forEach((e) => {
|
data.seasons.forEach((e) => {
|
||||||
if (!seasons.includes(e.season))
|
if (!seasons.includes(e.season))
|
||||||
seasons.push(e.season);
|
seasons.push(e.season);
|
||||||
|
|
||||||
|
@ -96,14 +96,14 @@ async function getStreamUrl(slug, type, season, episode) {
|
||||||
let id = '';
|
let id = '';
|
||||||
|
|
||||||
if (type === "movie") {
|
if (type === "movie") {
|
||||||
id = data.id_movie;
|
id = data.id_movie;
|
||||||
} else if (type === "show") {
|
} else if (type === "show") {
|
||||||
const episodeObj = data.seasons.find((v) => { return v.season === season && v.episode === episode; });
|
const episodeObj = data.seasons.find((v) => { return v.season === season && v.episode === episode; });
|
||||||
|
|
||||||
if (episodeObj) {
|
if (episodeObj) {
|
||||||
id = episodeObj.id_episode;
|
id = episodeObj.id_episode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id === '') {
|
if (id === '') {
|
||||||
return { url: '' }
|
return { url: '' }
|
||||||
|
@ -119,7 +119,6 @@ async function getStreamUrl(slug, type, season, episode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function findContent(searchTerm, type) {
|
async function findContent(searchTerm, type) {
|
||||||
// const searchUrl = getCorsUrl(`https://lookmovie.io/api/v1/${type}s/search/?q=${encodeURIComponent(searchTerm)}`);
|
|
||||||
const searchUrl = getCorsUrl(`https://lookmovie.io/${type}s/search/?q=${encodeURIComponent(searchTerm)}`);
|
const searchUrl = getCorsUrl(`https://lookmovie.io/${type}s/search/?q=${encodeURIComponent(searchTerm)}`);
|
||||||
const searchRes = await fetch(searchUrl).then((d) => d.text());
|
const searchRes = await fetch(searchUrl).then((d) => d.text());
|
||||||
|
|
||||||
|
@ -165,4 +164,5 @@ async function findContent(searchTerm, type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { findContent, getStreamUrl, getEpisodes };
|
const lookMovie = { findContent, getStreamUrl, getEpisodes };
|
||||||
|
export default lookMovie;
|
|
@ -1,46 +1,53 @@
|
||||||
/* port of https://github.com/beautify-web/js-beautify/blob/master/python/jsbeautifier/unpackers/packer.py (MIT) */
|
const alphabet = {
|
||||||
const unpacker = {
|
62: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||||
unpack: function (str) {
|
95: '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'
|
||||||
var params = unpacker.filterargs(str);
|
|
||||||
var payload = params[0], symtab = params[1], radix = params[2], count = params[3];
|
|
||||||
if (count !== symtab.length) {
|
|
||||||
throw new Error("Malformed p.a.c.k.e.r. symtab. (" + count + " != " + symtab.length + ")");
|
|
||||||
}
|
|
||||||
var unbase = unpacker.unbaser(radix);
|
|
||||||
var lookup = (word) => symtab[unbase(word)] || word;
|
|
||||||
var source = payload.replace(/\b\w+\b/g, lookup);
|
|
||||||
return source;
|
|
||||||
},
|
|
||||||
filterargs: function(str) {
|
|
||||||
/* [\s\S] insteadof . because javascript has no dotall modifier */
|
|
||||||
var juicers = [
|
|
||||||
/}\('([\s\S]*)', *(\d+), *(\d+), *'([\s\S]*)'\.split\('\|'\), *(\d+), *([\s\S]*)\)\)/,
|
|
||||||
/}\('([\s\S]*)', *(\d+), *(\d+), *'([\s\S]*)'\.split\('\|'\)/
|
|
||||||
];
|
|
||||||
for (var c = 0; c < juicers.length; ++c) {
|
|
||||||
var m, juicer = juicers[c];
|
|
||||||
// eslint-disable-next-line no-cond-assign
|
|
||||||
if (m = juicer.exec(str)) {
|
|
||||||
return [m[1], m[4].split('|'), parseInt(m[2]), parseInt(m[3])];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new Error("Could not make sense of p.a.c.k.e.r data (unexpected code structure)");
|
|
||||||
},
|
|
||||||
alphabet: {
|
|
||||||
62: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
||||||
95: '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'
|
|
||||||
},
|
|
||||||
unbaser: function(base)
|
|
||||||
{
|
|
||||||
if (2 <= base <= 36) return (str) => parseInt(str, base);
|
|
||||||
var dictionary = {};
|
|
||||||
var alphabet = unpacker.alphabet[base];
|
|
||||||
if (!alphabet) throw new Error("Unsupported encoding");
|
|
||||||
for (var c = 0; c < alphabet.length; ++alphabet) {
|
|
||||||
dictionary[alphabet[c]] = c;
|
|
||||||
}
|
|
||||||
return (str) => str.split("").reverse().reduce((cipher, ind) => Math.pow(base, ind) * dictionary[cipher]);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export { unpacker };
|
function _filterargs(str) {
|
||||||
|
var juicers = [
|
||||||
|
/}\('([\s\S]*)', *(\d+), *(\d+), *'([\s\S]*)'\.split\('\|'\), *(\d+), *([\s\S]*)\)\)/,
|
||||||
|
/}\('([\s\S]*)', *(\d+), *(\d+), *'([\s\S]*)'\.split\('\|'\)/
|
||||||
|
];
|
||||||
|
|
||||||
|
for (var c = 0; c < juicers.length; ++c) {
|
||||||
|
var m, juicer = juicers[c];
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-cond-assign
|
||||||
|
if (m = juicer.exec(str)) {
|
||||||
|
return [m[1], m[4].split('|'), parseInt(m[2]), parseInt(m[3])];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error("Could not make sense of p.a.c.k.e.r data (unexpected code structure)");
|
||||||
|
}
|
||||||
|
|
||||||
|
function _unbaser(base) {
|
||||||
|
if (2 <= base <= 36) return (str) => parseInt(str, base);
|
||||||
|
|
||||||
|
const dictionary = {};
|
||||||
|
var alpha = alphabet[base];
|
||||||
|
if (!alpha) throw new Error("Unsupported encoding");
|
||||||
|
|
||||||
|
for (let c = 0; c < alpha.length; ++alpha) {
|
||||||
|
dictionary[alpha[c]] = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (str) => str.split("").reverse().reduce((cipher, ind) => Math.pow(base, ind) * dictionary[cipher]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function unpack(str) {
|
||||||
|
var params = _filterargs(str);
|
||||||
|
var payload = params[0], symtab = params[1], radix = params[2], count = params[3];
|
||||||
|
|
||||||
|
if (count !== symtab.length) {
|
||||||
|
throw new Error("Malformed p.a.c.k.e.r. symtab. (" + count + " != " + symtab.length + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
var unbase = _unbaser(radix);
|
||||||
|
var lookup = (word) => symtab[unbase(word)] || word;
|
||||||
|
var source = payload.replace(/\b\w+\b/g, lookup);
|
||||||
|
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { unpack };
|
|
@ -4,8 +4,9 @@ import { Card } from '../components/Card'
|
||||||
import { useMovie } from '../hooks/useMovie'
|
import { useMovie } from '../hooks/useMovie'
|
||||||
import { VideoElement } from '../components/VideoElement'
|
import { VideoElement } from '../components/VideoElement'
|
||||||
import { EpisodeSelector } from '../components/EpisodeSelector'
|
import { EpisodeSelector } from '../components/EpisodeSelector'
|
||||||
|
import { getStreamUrl } from '../lib/index'
|
||||||
|
|
||||||
import './Movie.css'
|
import './Movie.css'
|
||||||
import { getStreamUrl } from '../lib/lookMovie'
|
|
||||||
|
|
||||||
export function MovieView(props) {
|
export function MovieView(props) {
|
||||||
const { streamUrl, streamData, setStreamUrl } = useMovie();
|
const { streamUrl, streamData, setStreamUrl } = useMovie();
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { InputBox } from '../components/InputBox'
|
import { InputBox } from '../components/InputBox';
|
||||||
import { Title } from '../components/Title'
|
import { Title } from '../components/Title';
|
||||||
import { Card } from '../components/Card'
|
import { Card } from '../components/Card';
|
||||||
import { ErrorBanner } from '../components/ErrorBanner'
|
import { ErrorBanner } from '../components/ErrorBanner';
|
||||||
import { MovieRow } from '../components/MovieRow'
|
import { MovieRow } from '../components/MovieRow';
|
||||||
import { Arrow } from '../components/Arrow'
|
import { Arrow } from '../components/Arrow';
|
||||||
import { Progress } from '../components/Progress'
|
import { Progress } from '../components/Progress';
|
||||||
import { findContent, getStreamUrl, getEpisodes } from '../lib/lookMovie'
|
import { findContent, getStreamUrl, getEpisodes } from '../lib/index';
|
||||||
// import { findContentGomo, getStreamUrlGomo } from '../lib/gomostream';
|
|
||||||
import { useMovie } from '../hooks/useMovie';
|
import { useMovie } from '../hooks/useMovie';
|
||||||
import { TypeSelector } from '../components/TypeSelector'
|
import { TypeSelector } from '../components/TypeSelector';
|
||||||
|
|
||||||
import './Search.css'
|
import './Search.css';
|
||||||
|
|
||||||
export function SearchView() {
|
export function SearchView() {
|
||||||
const { navigate, setStreamUrl, setStreamData } = useMovie();
|
const { navigate, setStreamUrl, setStreamData } = useMovie();
|
||||||
|
@ -68,6 +67,7 @@ export function SearchView() {
|
||||||
setText(`Streaming...`)
|
setText(`Streaming...`)
|
||||||
navigate("movie")
|
navigate("movie")
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
fail("Failed to get stream")
|
fail("Failed to get stream")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue