diff --git a/src/views/Movie.js b/src/views/Movie.js index 2e8d4ed2..936ed8ad 100644 --- a/src/views/Movie.js +++ b/src/views/Movie.js @@ -88,6 +88,30 @@ export function MovieView(props) { } }, [streamData, selectedSeason]) + React.useEffect(() => { + let cancel = false; + + if (!cancel) { + let ls = JSON.parse(localStorage.getItem("video-progress") || "{}") + let key = streamData.type === "show" ? `${season}-${episode}` : "full" + let time = ls?.[streamData.source]?.[streamData.type]?.[streamData.slug]?.[key]?.currentlyAt; + + if (time) { + const element = document.getElementsByClassName('videoElement')[0]; + + if (!element) { + return () => { cancel = false } + } + + element.currentTime = time; + } + } + + return () => { + cancel = true; + } + }) + const setProgress = (evt) => { let ls = JSON.parse(localStorage.getItem("video-progress") || "{}") diff --git a/src/views/Search.js b/src/views/Search.js index bc4360fd..adedda73 100644 --- a/src/views/Search.js +++ b/src/views/Search.js @@ -1,16 +1,16 @@ import React from 'react'; -import { Redirect, useRouteMatch, useHistory } from 'react-router-dom'; import { Helmet } from 'react-helmet'; -import { InputBox } from '../components/InputBox'; -import { Title } from '../components/Title'; +import { Redirect, useHistory, useRouteMatch } from 'react-router-dom'; +import { Arrow } from '../components/Arrow'; import { Card } from '../components/Card'; import { ErrorBanner } from '../components/ErrorBanner'; +import { InputBox } from '../components/InputBox'; import { MovieRow } from '../components/MovieRow'; -import { Arrow } from '../components/Arrow'; import { Progress } from '../components/Progress'; -import { findContent, getStreamUrl, getEpisodes } from '../lib/index'; -import { useMovie } from '../hooks/useMovie'; +import { Title } from '../components/Title'; import { TypeSelector } from '../components/TypeSelector'; +import { useMovie } from '../hooks/useMovie'; +import { findContent, getEpisodes, getStreamUrl } from '../lib/index'; import './Search.css'; @@ -161,7 +161,7 @@ export function SearchView() { setContinueWatching(newContinueWatching) }) - }); + }, []); if (!type || (type !== 'movie' && type !== 'show')) { return @@ -229,17 +229,26 @@ export function SearchView() { {/* Continue watching */} {continueWatching.length > 0 && page === 'watching' ? Continue watching - {continueWatching?.map((v, i) => ( - { - if (v.type === 'show') { - history.push(`${routeMatch.url}/${v.source}/${v.data.meta.title}/${v.slug}/season/${v.data.show.season}/episode/${v.data.show.episode}`) - } else { - history.push(`${routeMatch.url}/${v.source}/${v.data.meta.title}/${v.slug}`) - } - - setShowingOptions(false) - getStream(v.data.meta.title, v.data.meta.slug, v.type, v.source, v.data.meta.year) - }} /> + {Object.entries(continueWatching.reduce((a, v) => { + if (!a[v.source]) a[v.source] = [] + a[v.source].push(v) + return a; + }, {})).map(v => ( +
+

{v[0]}

+ {v[1].map((v, i) => ( + { + if (v.type === 'show') { + history.push(`${routeMatch.url}/${v.source}/${v.data.meta.title}/${v.slug}/season/${v.data.show.season}/episode/${v.data.show.episode}`) + } else { + history.push(`${routeMatch.url}/${v.source}/${v.data.meta.title}/${v.slug}`) + } + + setShowingOptions(false) + getStream(v.data.meta.title, v.data.meta.slug, v.type, v.source, v.data.meta.year) + }} /> + ))} +
))}
: }