mirror of
https://github.com/movie-web/movie-web.git
synced 2024-12-26 03:51:51 +01:00
Merge pull request #57 from lem6ns/master
Add GDrivePlayer as a scraper (movie only)
This commit is contained in:
commit
97f0ad3f2d
@ -16,6 +16,7 @@
|
||||
"react-helmet": "^6.1.0",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"react-scripts": "4.0.3",
|
||||
"unpacker": "^1.0.1",
|
||||
"web-vitals": "^1.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
|
@ -18,7 +18,8 @@ export function VideoElement({ streamUrl, loading, setProgress, videoRef, startT
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!streamUrl.includes('.mp4')) {
|
||||
if (!streamUrl.includes('.mp4') && !streamUrl.includes('redirector.php')) {
|
||||
console.log(streamUrl)
|
||||
setError(false)
|
||||
if (!videoRef || !videoRef.current || !streamUrl || streamUrl.length === 0 || loading) return;
|
||||
|
||||
@ -46,7 +47,7 @@ export function VideoElement({ streamUrl, loading, setProgress, videoRef, startT
|
||||
if (!streamUrl || streamUrl.length === 0)
|
||||
return <VideoPlaceholder>No video selected</VideoPlaceholder>
|
||||
|
||||
if (!streamUrl.includes('.mp4')) {
|
||||
if (!streamUrl.includes('.mp4') && !streamUrl.includes('redirector.php')) {
|
||||
return (
|
||||
<video className="videoElement" ref={videoRef} controls autoPlay onProgress={setProgress} onLoadedData={onLoad}>
|
||||
{ streamData.subtitles && streamData.subtitles.map((sub, index) => <track key={index} kind="captions" label={sub.language} src={sub.file} />) }
|
||||
|
@ -2,14 +2,15 @@ import lookmovie from './scraper/lookmovie';
|
||||
import xemovie from './scraper/xemovie';
|
||||
import theflix from './scraper/theflix';
|
||||
import vidzstore from './scraper/vidzstore';
|
||||
import gdriveplayer from './scraper/gdriveplayer';
|
||||
|
||||
async function findContent(searchTerm, type) {
|
||||
const results = { options: []};
|
||||
const content = await Promise.all([
|
||||
// lookmovie.findContent(searchTerm, type),
|
||||
gdriveplayer.findContent(searchTerm, type),
|
||||
xemovie.findContent(searchTerm, type),
|
||||
theflix.findContent(searchTerm, type),
|
||||
vidzstore.findContent(searchTerm, type)
|
||||
vidzstore.findContent(searchTerm, type),
|
||||
]);
|
||||
|
||||
content.forEach((o) => {
|
||||
@ -34,6 +35,8 @@ async function getStreamUrl(slug, type, source, season, episode) {
|
||||
return await vidzstore.getStreamUrl(slug);
|
||||
case 'xemovie':
|
||||
return await xemovie.getStreamUrl(slug, type, season, episode);
|
||||
case 'gdriveplayer':
|
||||
return await gdriveplayer.getStreamUrl(slug, type, season, episode);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
80
src/lib/scraper/gdriveplayer.js
Normal file
80
src/lib/scraper/gdriveplayer.js
Normal file
@ -0,0 +1,80 @@
|
||||
// THIS SCRAPER CURRENTLY WORKS AND IS IN USE
|
||||
import CryptoJS from "crypto-js";
|
||||
import { unpack } from "unpacker";
|
||||
|
||||
const BASE_URL = `${process.env.REACT_APP_CORS_PROXY_URL}https://database.gdriveplayer.us`;
|
||||
const API_URL = `${process.env.REACT_APP_CORS_PROXY_URL}https://api.gdriveplayer.us`;
|
||||
|
||||
const format = {
|
||||
stringify: (cipher) => {
|
||||
const ct = cipher.ciphertext.toString(CryptoJS.enc.Base64);
|
||||
const iv = cipher.iv.toString() || "";
|
||||
const salt = cipher.salt.toString() || "";
|
||||
return JSON.stringify({
|
||||
ct,
|
||||
iv,
|
||||
salt,
|
||||
});
|
||||
},
|
||||
parse: (jsonStr) => {
|
||||
const json = JSON.parse(jsonStr);
|
||||
const ciphertext = CryptoJS.enc.Base64.parse(json.ct);
|
||||
const iv = CryptoJS.enc.Hex.parse(json.iv) || "";
|
||||
const salt = CryptoJS.enc.Hex.parse(json.s) || "";
|
||||
|
||||
const cipher = CryptoJS.lib.CipherParams.create({
|
||||
ciphertext,
|
||||
iv,
|
||||
salt,
|
||||
});
|
||||
return cipher;
|
||||
}
|
||||
};
|
||||
|
||||
async function findContent(searchTerm, type) {
|
||||
if (type === 'show') return { options: [] }; // will be like this until rewrite
|
||||
try {
|
||||
const searchUrl = `${API_URL}/v1/movie/search?title=${searchTerm}`;
|
||||
const searchRes = await fetch(searchUrl).then((r) => r.json());
|
||||
const results = searchRes.map(movie => {
|
||||
return {
|
||||
type,
|
||||
title: movie.title,
|
||||
year: movie.year,
|
||||
slug: encodeURIComponent(`player.php?imdb=${movie.imdb}`),
|
||||
source: "gdriveplayer",
|
||||
}
|
||||
});
|
||||
|
||||
return { options: results };
|
||||
} catch {
|
||||
return { options: [] };
|
||||
}
|
||||
}
|
||||
|
||||
async function getStreamUrl(slug) {
|
||||
const url = `${BASE_URL}/${decodeURIComponent(slug)}`;
|
||||
const res = await fetch(url).then(d => d.text());
|
||||
const DOM = new DOMParser().parseFromString(res, "text/html");
|
||||
|
||||
const script = [...DOM.querySelectorAll("script")].find(s => s.textContent.includes("eval"));
|
||||
const unpacked = unpack(script.textContent);
|
||||
|
||||
const data = unpacked.split("var data=\\'")[1].split("\\'")[0].replace(/\\/g, "");
|
||||
const decryptedData = unpack(CryptoJS.AES.decrypt(data, "alsfheafsjklNIWORNiolNIOWNKLNXakjsfwnBdwjbwfkjbJjkopfjweopjASoiwnrflakefneiofrt", { format }).toString(CryptoJS.enc.Utf8));
|
||||
// eslint-disable-next-line
|
||||
const sources = JSON.parse(JSON.stringify(eval(decryptedData.split("sources:")[1].split(",image")[0].replace(/\\/g, "").replace(/document\.referrer/g, "\"\""))));
|
||||
const unmappedSubtitles = JSON.parse(DOM.querySelector("#subtitlez").textContent).filter(s => s.file.length !== 2);
|
||||
const subtitles = unmappedSubtitles.map(async (sub) => {
|
||||
const subtitleBlob = URL.createObjectURL(await fetch(`${process.env.REACT_APP_CORS_PROXY_URL}${sub.file}`).then(res => res.blob()));
|
||||
return {
|
||||
file: subtitleBlob,
|
||||
language: sub.label,
|
||||
}
|
||||
});
|
||||
|
||||
return { url: sources[sources.length - 1].file, subtitles };
|
||||
}
|
||||
|
||||
const gdriveplayer = { findContent, getStreamUrl }
|
||||
export default gdriveplayer;
|
@ -98,9 +98,7 @@ async function getStreamUrl(slug, type, season, episode) {
|
||||
if (script.textContent.match(/https:\/\/s[0-9]\.xemovie\.com/)) {
|
||||
// eslint-disable-next-line
|
||||
let data = JSON.parse(JSON.stringify(eval(`(${script.textContent.replace("const data = ", "").split("};")[0]}})`)));
|
||||
// eslint-disable-next-line
|
||||
mediaUrl = data.playlist[0].file;
|
||||
// eslint-disable-next-line
|
||||
for (const subtitleTrack of data.playlist[0].tracks) {
|
||||
const subtitleBlob = URL.createObjectURL(await fetch(`${process.env.REACT_APP_CORS_PROXY_URL}${subtitleTrack.file}`).then(res => res.blob())); // do this so no need for CORS errors
|
||||
subtitles.push({
|
||||
|
Loading…
Reference in New Issue
Block a user