mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-11 01:05:08 +01:00
commit
644be8256a
@ -1,11 +1,13 @@
|
||||
import lookmovie from './scraper/lookmovie';
|
||||
import theflix from './scraper/theflix';
|
||||
import vidzstore from './scraper/vidzstore';
|
||||
|
||||
async function findContent(searchTerm, type) {
|
||||
const results = { options: []};
|
||||
const content = await Promise.all([
|
||||
lookmovie.findContent(searchTerm, type),
|
||||
theflix.findContent(searchTerm, type)
|
||||
theflix.findContent(searchTerm, type),
|
||||
vidzstore.findContent(searchTerm, type)
|
||||
]);
|
||||
|
||||
content.forEach((o) => {
|
||||
@ -26,6 +28,8 @@ async function getStreamUrl(slug, type, source, season, episode) {
|
||||
return await lookmovie.getStreamUrl(slug, type, season, episode);
|
||||
case 'theflix':
|
||||
return await theflix.getStreamUrl(slug, type, season, episode);
|
||||
case 'vidzstore':
|
||||
return await vidzstore.getStreamUrl(slug);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
41
src/lib/scraper/vidzstore.js
Normal file
41
src/lib/scraper/vidzstore.js
Normal file
@ -0,0 +1,41 @@
|
||||
const BASE_URL = `${process.env.REACT_APP_CORS_PROXY_URL}https://stream.vidzstore.com`;
|
||||
|
||||
async function findContent(searchTerm, type) {
|
||||
if (type === 'show') return { options: [] };
|
||||
try {
|
||||
const searchUrl = `${BASE_URL}/search.php?sd=${searchTerm.replace(/ /g, "_")}`;
|
||||
const searchRes = await fetch(searchUrl).then((d) => d.text());
|
||||
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString(searchRes, "text/html");
|
||||
const nodes = [...doc.querySelectorAll(".post")];
|
||||
const results = nodes.map(node => {
|
||||
const title = node.querySelector("a").title.replace(/-/g, " ").trim();
|
||||
const titleArray = title.split(" ");
|
||||
titleArray.splice(-2);
|
||||
return {
|
||||
type,
|
||||
title: titleArray.join(" "),
|
||||
year: node.querySelector(".post-meta").innerText.split(" ").pop().split("-").shift(),
|
||||
slug: encodeURIComponent(node.querySelector("a").href.split('/').pop()),
|
||||
source: "vidzstore",
|
||||
}
|
||||
});
|
||||
|
||||
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");
|
||||
|
||||
return { url: `${process.env.REACT_APP_CORS_PROXY_URL}${DOM.querySelector("source").src}` };
|
||||
}
|
||||
|
||||
const vidzstore = { findContent, getStreamUrl }
|
||||
export default vidzstore;
|
Loading…
Reference in New Issue
Block a user