Merge pull request #54 from lem6ns/master

Add source: vidzstore
This commit is contained in:
James Hawkins 2022-01-30 20:25:14 +00:00 committed by GitHub
commit 644be8256a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 1 deletions

View File

@ -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;
}

View 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;