1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-29 16:07:40 +01:00

clean up lookmovie scraper

This commit is contained in:
James Hawkins 2021-10-20 18:07:33 +01:00
parent b82aa4660d
commit 8cf8f6a918

View file

@ -56,42 +56,33 @@ async function findContent(searchTerm, type) {
}
}
async function getVideoUrl(config) {
const { subtitles } = await getAccessInfo(config);
// const now = Math.floor(Date.now() / 1e3);
let subs;
if (config.type === "show") {
subs = await getEpisodeSubs(config);
} else if (config.type === "movie") {
subs = subtitles;
}
let url = '';
// if (config.type === 'movie') {
// url = `${CORS_URL}/manifests/movies/json/${config.id}/${now}/${accessToken}/master.m3u8`;
// } else if (config.type === 'show') {
// url = `${CORS_URL}/manifests/shows/json/${accessToken}/${now}/${config.id}/master.m3u8`;
// }
if (config.type === 'movie') {
url = `${CORS_URL}/api/v1/security/movie-access?id_movie=${config.id}&token=1&sk=&step=1`;
} else if (config.type === 'show') {
url = `${CORS_URL}/api/v1/security/show-access?slug=${config.slug}&token=&step=2`;
}
const videoOpts = await fetch(url, {
const data = await fetch(url, {
headers: { phpsessid },
}).then((d) => d.json());
let subs;
if (config.type === "show") {
subs = await getEpisodeSubs(config);
} else if (config.type === "movie") {
subs = data?.data?.subtitles;
}
// Find video URL and return it (with a check for a full url if needed)
const opts = ["1080p", "1080", "720p", "720", "480p", "480", "auto"];
let videoUrl = "";
for (let res of opts) {
if (videoOpts.streams[res] && !videoOpts.streams[res].includes('dummy') && !videoOpts.streams[res].includes('earth-1984') && !videoUrl) {
videoUrl = videoOpts.streams[res]
if (data.streams[res] && !data.streams[res].includes('dummy') && !data.streams[res].includes('earth-1984') && !videoUrl) {
videoUrl = data.streams[res]
}
}
@ -107,27 +98,6 @@ async function getEpisodeSubs (config) {
}).then(res => res.json());
}
async function getAccessInfo(config) {
let url = '';
if (config.type === 'movie') {
url = `${CORS_URL}/api/v1/security/movie-access?id_movie=${config.id}&token=1&sk=&step=1`;
} else if (config.type === 'show') {
url = `${CORS_URL}/api/v1/security/show-access?slug=${config.slug}&token=&step=2`;
}
const data = await fetch(url, {
headers: { phpsessid },
}).then((d) => d.json());
const token = data?.data?.accessToken;
const subtitles = data?.data?.subtitles;
if (token) return { token, subtitles };
return "Invalid type provided in config";
}
async function getEpisodes(slug) {
const url = `${CORS_URL}/shows/view/${slug}`;
const pageReq = await fetch(url, {