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

Update lookmovie.js

This commit is contained in:
mansoor-roeen-glitch 2021-09-13 23:55:29 +05:30 committed by GitHub
parent 4878238143
commit fbd0f57a73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -50,9 +50,19 @@ async function findContent(searchTerm, type) {
}
}
async function getVideoUrl(config) {
const accessToken = await getAccessToken(config);
const accessInfo = await getAccessToken(config);
const accessToken = accessInfo.token;
const subtitles = accessInfo.subtitles;
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') {
@ -73,7 +83,11 @@ async function getVideoUrl(config) {
}
}
return videoUrl.startsWith("/") ? `${BASE_URL}${videoUrl}` : videoUrl;
return {videoUrl: videoUrl.startsWith("/") ? `${BASE_URL}${videoUrl}` : videoUrl, subs};
}
async function getEpisodeSubs (config) {
return await fetch(`${BASE_URL}/api/v1/shows/episode-subtitles/?id_episode=${config.id}`).then(res => res.json());
}
async function getAccessToken(config) {
@ -88,7 +102,9 @@ async function getAccessToken(config) {
const data = await fetch(url).then((d) => d.json());
const token = data?.data?.accessToken;
if (token) return token;
let subtitles = data?.data?.subtitles;
if (token) return {token, subtitles};
return "Invalid type provided in config";
}
@ -121,6 +137,7 @@ async function getEpisodes(slug) {
}
async function getStreamUrl(slug, type, season, episode) {
const url = `${BASE_URL}/${type}s/view/${slug}`;
const pageReq = await fetch(url).then((d) => d.text());
@ -155,7 +172,7 @@ async function getStreamUrl(slug, type, season, episode) {
type: type,
});
return { url: videoUrl }
return { url: videoUrl.videoUrl, subtitles: videoUrl.subs };
}