mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-20 14:37:43 +01:00
Implement vidzstore as a Movie source
This commit is contained in:
parent
58c507ebf7
commit
383a53e8d3
2 changed files with 46 additions and 1 deletions
|
@ -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 a new issue