1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-29 16:07:40 +01:00

it actually continues watching now!

This commit is contained in:
James Hawkins 2021-08-06 19:08:49 +01:00
parent b3cd011bfa
commit 2dd3a3f82a
2 changed files with 51 additions and 18 deletions

View file

@ -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") || "{}")

View file

@ -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 <Redirect to="/movie" />
@ -229,17 +229,26 @@ export function SearchView() {
{/* Continue watching */}
{continueWatching.length > 0 && page === 'watching' ? <Card>
<Title>Continue watching</Title>
{continueWatching?.map((v, i) => (
<MovieRow key={i} title={v.data.meta.title} slug={v.data.meta.slug} type={v.type} year={v.data.meta.year} source={v.source} place={v.data.show} percentage={v.percentageDone} onClick={() => {
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 => (
<div key={v[0]}>
<p className="source">{v[0]}</p>
{v[1].map((v, i) => (
<MovieRow key={i} title={v.data.meta.title} slug={v.data.meta.slug} type={v.type} year={v.data.meta.year} source={v.source} place={v.data.show} percentage={v.percentageDone} onClick={() => {
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)
}} />
))}
</div>
))}
</Card> : <React.Fragment></React.Fragment>}