mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-20 14:37:43 +01:00
even more continue watching
This commit is contained in:
parent
764d673897
commit
7a85f05c47
4 changed files with 20 additions and 11 deletions
|
@ -3,14 +3,15 @@ import { TypeSelector } from './TypeSelector';
|
||||||
import { NumberSelector } from './NumberSelector';
|
import { NumberSelector } from './NumberSelector';
|
||||||
import './EpisodeSelector.css'
|
import './EpisodeSelector.css'
|
||||||
|
|
||||||
export function EpisodeSelector({ setSelectedSeason, setEpisode, seasons, selectedSeason, season, episodes, currentSeason, currentEpisode, streamData }) {
|
export function EpisodeSelector({ setSelectedSeason, selectedSeason, setEpisode, seasons, episodes, currentSeason, currentEpisode, streamData }) {
|
||||||
const choices = episodes ? episodes.map(v => {
|
const choices = episodes ? episodes.map(v => {
|
||||||
let progressData = JSON.parse(localStorage.getItem('video-progress') || "{}")
|
let progressData = JSON.parse(localStorage.getItem('video-progress') || "{}")
|
||||||
|
|
||||||
let currentlyAt = 0;
|
let currentlyAt = 0;
|
||||||
let totalDuration = 0;
|
let totalDuration = 0;
|
||||||
|
|
||||||
const progress = progressData?.[streamData.source]?.[streamData.show]?.[streamData.slug]?.[`${season}-${v}`]
|
const progress = progressData?.[streamData.source]?.[streamData.type]?.[streamData.slug]?.[`${selectedSeason}-${v}`]
|
||||||
|
|
||||||
if (progress) {
|
if (progress) {
|
||||||
currentlyAt = progress.currentlyAt
|
currentlyAt = progress.currentlyAt
|
||||||
totalDuration = progress.totalDuration
|
totalDuration = progress.totalDuration
|
||||||
|
|
|
@ -6,13 +6,14 @@ import { PercentageOverlay } from './PercentageOverlay'
|
||||||
// title: string
|
// title: string
|
||||||
// onClick: () => void
|
// onClick: () => void
|
||||||
export function MovieRow(props) {
|
export function MovieRow(props) {
|
||||||
|
|
||||||
const progressData = JSON.parse(localStorage.getItem("video-progress") || "{}")
|
const progressData = JSON.parse(localStorage.getItem("video-progress") || "{}")
|
||||||
let progress;
|
let progress;
|
||||||
let percentage = null;
|
let percentage = null;
|
||||||
if(props.type === "movie") {
|
|
||||||
|
if (props.type === "movie") {
|
||||||
progress = progressData?.[props.source]?.movie?.[props.slug]?.full
|
progress = progressData?.[props.source]?.movie?.[props.slug]?.full
|
||||||
if(progress) {
|
|
||||||
|
if (progress) {
|
||||||
percentage = Math.floor((progress.currentlyAt / progress.totalDuration) * 100)
|
percentage = Math.floor((progress.currentlyAt / progress.totalDuration) * 100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,13 +21,15 @@ export function MovieRow(props) {
|
||||||
return (
|
return (
|
||||||
<div className="movieRow" onClick={() => props.onClick && props.onClick()}>
|
<div className="movieRow" onClick={() => props.onClick && props.onClick()}>
|
||||||
<div className="left">
|
<div className="left">
|
||||||
{props.title} <span className="seasonEpisodeSubtitle">{props.place ? ` — Season ${props.place.season}: episode ${props.place.episode}` : ''}</span>
|
{props.title}<span className="seasonEpisodeSubtitle">{props.place ? ` - S${props.place.season}:E${props.place.episode}` : ''}</span>
|
||||||
<span className="year">({props.year})</span>
|
<span className="year">({props.year})</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="watch">
|
<div className="watch">
|
||||||
<p>Watch {props.type}</p>
|
<p>Watch {props.type}</p>
|
||||||
<Arrow/>
|
<Arrow/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<PercentageOverlay percentage={props.percentage || percentage} />
|
<PercentageOverlay percentage={props.percentage || percentage} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useCallback } from 'react'
|
import React from 'react'
|
||||||
import { useRouteMatch, useHistory } from 'react-router-dom'
|
import { useRouteMatch, useHistory } from 'react-router-dom'
|
||||||
import { Helmet } from 'react-helmet';
|
import { Helmet } from 'react-helmet';
|
||||||
import { Title } from '../components/Title'
|
import { Title } from '../components/Title'
|
||||||
|
|
|
@ -56,7 +56,6 @@ export function SearchView() {
|
||||||
|
|
||||||
let realUrl = '';
|
let realUrl = '';
|
||||||
if (type === "movie") {
|
if (type === "movie") {
|
||||||
// getStreamUrl(slug, type, source, season, episode)
|
|
||||||
const { url } = await getStreamUrl(slug, type, source);
|
const { url } = await getStreamUrl(slug, type, source);
|
||||||
|
|
||||||
if (url === '') {
|
if (url === '') {
|
||||||
|
@ -65,6 +64,8 @@ export function SearchView() {
|
||||||
realUrl = url;
|
realUrl = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(year)
|
||||||
|
|
||||||
setProgress(maxSteps);
|
setProgress(maxSteps);
|
||||||
setStreamUrl(realUrl);
|
setStreamUrl(realUrl);
|
||||||
setStreamData({
|
setStreamData({
|
||||||
|
@ -227,12 +228,16 @@ export function SearchView() {
|
||||||
{/* Continue watching */}
|
{/* Continue watching */}
|
||||||
{continueWatching.length > 0 && page === 'watching' ? <Card>
|
{continueWatching.length > 0 && page === 'watching' ? <Card>
|
||||||
<Title>Continue watching</Title>
|
<Title>Continue watching</Title>
|
||||||
{console.log(continueWatching)}
|
|
||||||
{continueWatching?.map((v, i) => (
|
{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={() => {
|
<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={() => {
|
||||||
history.push(`${routeMatch.url}/${v.source}/${v.data.meta.title}/${v.slug}`)
|
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)
|
setShowingOptions(false)
|
||||||
getStream(v.data.meta.title, v.data.meta.slug, v.type, v.source, v.year)
|
getStream(v.data.meta.title, v.data.meta.slug, v.type, v.source, v.data.meta.year)
|
||||||
}} />
|
}} />
|
||||||
))}
|
))}
|
||||||
</Card> : <React.Fragment></React.Fragment>}
|
</Card> : <React.Fragment></React.Fragment>}
|
||||||
|
|
Loading…
Reference in a new issue