From 7a85f05c47fe545b194fd4abe8bcc25d01c8db86 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Fri, 6 Aug 2021 17:57:58 +0100 Subject: [PATCH] even more continue watching --- src/components/EpisodeSelector.js | 5 +++-- src/components/MovieRow.js | 11 +++++++---- src/views/Movie.js | 2 +- src/views/Search.js | 13 +++++++++---- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/components/EpisodeSelector.js b/src/components/EpisodeSelector.js index 9ba35b2a..f0fb16fe 100644 --- a/src/components/EpisodeSelector.js +++ b/src/components/EpisodeSelector.js @@ -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 diff --git a/src/components/MovieRow.js b/src/components/MovieRow.js index d15d35ef..f857f5fb 100644 --- a/src/components/MovieRow.js +++ b/src/components/MovieRow.js @@ -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 (
props.onClick && props.onClick()}>
- {props.title} {props.place ? ` — Season ${props.place.season}: episode ${props.place.episode}` : ''}  + {props.title}{props.place ? ` - S${props.place.season}:E${props.place.episode}` : ''}  ({props.year})
+

Watch {props.type}

+
) diff --git a/src/views/Movie.js b/src/views/Movie.js index ee82e4fe..2e8d4ed2 100644 --- a/src/views/Movie.js +++ b/src/views/Movie.js @@ -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' diff --git a/src/views/Search.js b/src/views/Search.js index 715534d0..9bc96e5c 100644 --- a/src/views/Search.js +++ b/src/views/Search.js @@ -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' ? Continue watching - {console.log(continueWatching)} {continueWatching?.map((v, i) => ( { - 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) }} /> ))} : }