mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-11 02:45:09 +01:00
even more continue watching
This commit is contained in:
parent
764d673897
commit
7a85f05c47
@ -3,14 +3,15 @@ import { TypeSelector } from './TypeSelector';
|
||||
import { NumberSelector } from './NumberSelector';
|
||||
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 => {
|
||||
let progressData = JSON.parse(localStorage.getItem('video-progress') || "{}")
|
||||
|
||||
let currentlyAt = 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) {
|
||||
currentlyAt = progress.currentlyAt
|
||||
totalDuration = progress.totalDuration
|
||||
|
@ -6,13 +6,14 @@ import { PercentageOverlay } from './PercentageOverlay'
|
||||
// title: string
|
||||
// onClick: () => void
|
||||
export function MovieRow(props) {
|
||||
|
||||
const progressData = JSON.parse(localStorage.getItem("video-progress") || "{}")
|
||||
let progress;
|
||||
let percentage = null;
|
||||
if(props.type === "movie") {
|
||||
|
||||
if (props.type === "movie") {
|
||||
progress = progressData?.[props.source]?.movie?.[props.slug]?.full
|
||||
if(progress) {
|
||||
|
||||
if (progress) {
|
||||
percentage = Math.floor((progress.currentlyAt / progress.totalDuration) * 100)
|
||||
}
|
||||
}
|
||||
@ -20,13 +21,15 @@ export function MovieRow(props) {
|
||||
return (
|
||||
<div className="movieRow" onClick={() => props.onClick && props.onClick()}>
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<div className="watch">
|
||||
<p>Watch {props.type}</p>
|
||||
<Arrow/>
|
||||
</div>
|
||||
|
||||
<PercentageOverlay percentage={props.percentage || percentage} />
|
||||
</div>
|
||||
)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useCallback } from 'react'
|
||||
import React from 'react'
|
||||
import { useRouteMatch, useHistory } from 'react-router-dom'
|
||||
import { Helmet } from 'react-helmet';
|
||||
import { Title } from '../components/Title'
|
||||
|
@ -56,7 +56,6 @@ export function SearchView() {
|
||||
|
||||
let realUrl = '';
|
||||
if (type === "movie") {
|
||||
// getStreamUrl(slug, type, source, season, episode)
|
||||
const { url } = await getStreamUrl(slug, type, source);
|
||||
|
||||
if (url === '') {
|
||||
@ -65,6 +64,8 @@ export function SearchView() {
|
||||
realUrl = url;
|
||||
}
|
||||
|
||||
console.log(year)
|
||||
|
||||
setProgress(maxSteps);
|
||||
setStreamUrl(realUrl);
|
||||
setStreamData({
|
||||
@ -227,12 +228,16 @@ export function SearchView() {
|
||||
{/* Continue watching */}
|
||||
{continueWatching.length > 0 && page === 'watching' ? <Card>
|
||||
<Title>Continue watching</Title>
|
||||
{console.log(continueWatching)}
|
||||
{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={() => {
|
||||
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)
|
||||
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>}
|
||||
|
Loading…
Reference in New Issue
Block a user