mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-20 14:37:43 +01:00
Update lookmovie.js
This commit is contained in:
parent
4878238143
commit
fbd0f57a73
1 changed files with 24 additions and 7 deletions
|
@ -50,9 +50,19 @@ async function findContent(searchTerm, type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function getVideoUrl(config) {
|
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);
|
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 = '';
|
let url = '';
|
||||||
|
|
||||||
if (config.type === 'movie') {
|
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) {
|
async function getAccessToken(config) {
|
||||||
|
@ -88,7 +102,9 @@ async function getAccessToken(config) {
|
||||||
const data = await fetch(url).then((d) => d.json());
|
const data = await fetch(url).then((d) => d.json());
|
||||||
|
|
||||||
const token = data?.data?.accessToken;
|
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";
|
return "Invalid type provided in config";
|
||||||
}
|
}
|
||||||
|
@ -121,6 +137,7 @@ async function getEpisodes(slug) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getStreamUrl(slug, type, season, episode) {
|
async function getStreamUrl(slug, type, season, episode) {
|
||||||
|
|
||||||
const url = `${BASE_URL}/${type}s/view/${slug}`;
|
const url = `${BASE_URL}/${type}s/view/${slug}`;
|
||||||
const pageReq = await fetch(url).then((d) => d.text());
|
const pageReq = await fetch(url).then((d) => d.text());
|
||||||
|
|
||||||
|
@ -155,7 +172,7 @@ async function getStreamUrl(slug, type, season, episode) {
|
||||||
type: type,
|
type: type,
|
||||||
});
|
});
|
||||||
|
|
||||||
return { url: videoUrl }
|
return { url: videoUrl.videoUrl, subtitles: videoUrl.subs };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue