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')) { if (!streamUrl.endsWith('.mp4')) {
return ( 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}` } />) } { 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> </video>
) )
} else { } else {
return ( 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}` } />) } { 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" /> <source src={streamUrl} type="video/mp4" />
</video> </video>

View file

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

View file

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