1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-20 14:37:43 +01:00

Merge pull request #37 from JamesHawkinss/feature/fix-lookmovie-shows

further lookmovie fixes
This commit is contained in:
James Hawkins 2021-10-22 13:37:27 +01:00 committed by GitHub
commit 6465bdc7ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 19 deletions

View file

@ -48,13 +48,13 @@ export function VideoElement({ streamUrl, loading, setProgress, videoRef, startT
if (!streamUrl.endsWith('.mp4')) {
return (
<video crossorigin="anonymous" className="videoElement" ref={videoRef} controls autoPlay onProgress={setProgress} onLoadedData={onLoad}>
<video crossOrigin="anonymous" className="videoElement" ref={videoRef} controls autoPlay onProgress={setProgress} onLoadedData={onLoad}>
{ streamData.subtitles && streamData.subtitles.map((sub, index) => <track key={index} kind="captions" label={sub.language} src={`${process.env.REACT_APP_CORS_PROXY_URL}https://lookmovie.io${sub.file}` } />) }
</video>
)
} else {
return (
<video crossorigin="anonymous" className="videoElement" ref={videoRef} controls autoPlay onProgress={setProgress} onLoadedData={onLoad}>
<video crossOrigin="anonymous" className="videoElement" ref={videoRef} controls autoPlay onProgress={setProgress} onLoadedData={onLoad}>
{ streamData.subtitles && streamData.subtitles.map((sub, index) => <track key={index} kind="captions" label={sub.language} src={`${process.env.REACT_APP_CORS_PROXY_URL}https://lookmovie.io${sub.file}` } />) }
<source src={streamUrl} type="video/mp4" />
</video>

View file

@ -61,20 +61,17 @@ async function getVideoUrl(config) {
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`;
url = `${CORS_URL}/api/v1/security/episode-access?id_episode=${config.id}`;
}
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;
}
const subs = data?.subtitles.filter((sub) => {
if (typeof sub.file === 'object') return false;
return true;
})
// Find video URL and return it (with a check for a full url if needed)
const opts = ["1080p", "1080", "720p", "720", "480p", "480", "auto"];
@ -88,16 +85,10 @@ async function getVideoUrl(config) {
return {
videoUrl: videoUrl.startsWith("/") ? `${BASE_URL}${videoUrl}` : videoUrl,
subs,
subs: subs,
};
}
async function getEpisodeSubs (config) {
return await fetch(`${CORS_URL}/api/v1/shows/episode-subtitles/?id_episode=${config.id}`, {
headers: { phpsessid },
}).then(res => res.json());
}
async function getEpisodes(slug) {
const url = `${CORS_URL}/shows/view/${slug}`;
const pageReq = await fetch(url, {

View file

@ -57,9 +57,9 @@ export function MovieView(props) {
setLoading(true);
getStreamUrl(streamData.slug, streamData.type, streamData.source, season, episode)
.then(({ url }) => {
.then(({ url, subtitles }) => {
if (cancel) return;
streamData.subtitles = [];
streamData.subtitles = subtitles;
setStreamUrl(url)
setLoading(false);
})