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
9bf56c0b82
commit
be3f631ca9
1 changed files with 12 additions and 11 deletions
|
@ -50,17 +50,15 @@ async function findContent(searchTerm, type) {
|
|||
}
|
||||
}
|
||||
async function getVideoUrl(config) {
|
||||
const accessInfo = await getAccessToken(config);
|
||||
const accessToken = accessInfo.token;
|
||||
const subtitles = accessInfo.subtitles;
|
||||
const { subtitles, token: accessToken } = await getAccessInfo(config);
|
||||
const now = Math.floor(Date.now() / 1e3);
|
||||
|
||||
let subs;
|
||||
|
||||
if (config.type === "show") {
|
||||
subs = await getEpisodeSubs(config)
|
||||
subs = await getEpisodeSubs(config);
|
||||
} else if (config.type === "movie") {
|
||||
subs = subtitles
|
||||
subs = subtitles;
|
||||
}
|
||||
|
||||
let url = '';
|
||||
|
@ -83,14 +81,17 @@ async function getVideoUrl(config) {
|
|||
}
|
||||
}
|
||||
|
||||
return {videoUrl: videoUrl.startsWith("/") ? `${BASE_URL}${videoUrl}` : videoUrl, subs};
|
||||
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 getAccessInfo(config) {
|
||||
let url = '';
|
||||
|
||||
if (config.type === 'movie') {
|
||||
|
@ -102,9 +103,9 @@ async function getAccessToken(config) {
|
|||
const data = await fetch(url).then((d) => d.json());
|
||||
|
||||
const token = data?.data?.accessToken;
|
||||
let subtitles = data?.data?.subtitles;
|
||||
const subtitles = data?.data?.subtitles;
|
||||
|
||||
if (token) return {token, subtitles};
|
||||
if (token) return { token, subtitles };
|
||||
|
||||
return "Invalid type provided in config";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue