diff --git a/package.json b/package.json index 29118a46..b0bec93e 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", + "crypto-js": "^4.0.0", "fuse.js": "^6.4.6", "hls.js": "^1.0.7", "json5": "^2.2.0", diff --git a/src/components/EpisodeSelector.js b/src/components/EpisodeSelector.js index aac45e27..e1f98117 100644 --- a/src/components/EpisodeSelector.js +++ b/src/components/EpisodeSelector.js @@ -3,7 +3,7 @@ import { TypeSelector } from './TypeSelector'; import { NumberSelector } from './NumberSelector'; import './EpisodeSelector.css' -export function EpisodeSelector({ setSeason, setEpisode, seasons, season, episodes, currentSeason, currentEpisode, slug }) { +export function EpisodeSelector({ setSeason, setEpisode, seasons, season, episodes, currentSeason, currentEpisode, slug, source }) { const choices = episodes.map(v => { @@ -12,7 +12,7 @@ export function EpisodeSelector({ setSeason, setEpisode, seasons, season, episod let currentlyAt = 0; let totalDuration = 0; - const progress = progressData?.lookmovie?.show?.slug?.[`${season}-${v}`] + const progress = progressData?.[source]?.show?.slug?.[`${season}-${v}`] if(progress) { currentlyAt = progress.currentlyAt totalDuration = progress.totalDuration diff --git a/src/components/MovieRow.js b/src/components/MovieRow.js index 9473dfa0..00219e19 100644 --- a/src/components/MovieRow.js +++ b/src/components/MovieRow.js @@ -11,7 +11,7 @@ export function MovieRow(props) { let progress; let percentage = null; if(props.type === "movie") { - progress = progressData?.lookmovie?.movie?.[props.slug]?.full + progress = progressData?.[props.source]?.movie?.[props.slug]?.full if(progress) { percentage = Math.floor((progress.currentlyAt / progress.totalDuration) * 100) } @@ -24,6 +24,7 @@ export function MovieRow(props) { ({props.year})
+ {props.source}

Watch {props.type}

diff --git a/src/components/TypeSelector.js b/src/components/TypeSelector.js index 05f545e3..2af819f4 100644 --- a/src/components/TypeSelector.js +++ b/src/components/TypeSelector.js @@ -1,5 +1,4 @@ import React from 'react'; -// import { Arrow } from './Arrow'; import './TypeSelector.css' // setType: (txt: string) => void diff --git a/src/components/VideoElement.js b/src/components/VideoElement.js index 35ec011a..2f3863fc 100644 --- a/src/components/VideoElement.js +++ b/src/components/VideoElement.js @@ -1,8 +1,9 @@ import React from 'react' import Hls from 'hls.js' -import './VideoElement.css' import { VideoPlaceholder } from './VideoPlaceholder' +import './VideoElement.css' + // streamUrl: string // loading: boolean export function VideoElement({ streamUrl, loading, setProgress }) { @@ -10,21 +11,23 @@ export function VideoElement({ streamUrl, loading, setProgress }) { const [error, setError] = React.useState(false); React.useEffect(() => { - setError(false) - if (!videoRef || !videoRef.current || !streamUrl || streamUrl.length === 0 || loading) return; - - const hls = new Hls(); - - if (!Hls.isSupported() && videoRef.current.canPlayType('application/vnd.apple.mpegurl')) { - videoRef.current.src = streamUrl; - return; - } else if (!Hls.isSupported()) { - setError(true) - return; + if (!streamUrl.endsWith('.mp4')) { + setError(false) + if (!videoRef || !videoRef.current || !streamUrl || streamUrl.length === 0 || loading) return; + + const hls = new Hls(); + + if (!Hls.isSupported() && videoRef.current.canPlayType('application/vnd.apple.mpegurl')) { + videoRef.current.src = streamUrl; + return; + } else if (!Hls.isSupported()) { + setError(true) + return; + } + + hls.attachMedia(videoRef.current); + hls.loadSource(streamUrl); } - - hls.attachMedia(videoRef.current); - hls.loadSource(streamUrl); }, [videoRef, streamUrl, loading]) if (error) @@ -36,7 +39,15 @@ export function VideoElement({ streamUrl, loading, setProgress }) { if (!streamUrl || streamUrl.length === 0) return No video selected - return ( -