diff --git a/src/components/EpisodeSelector.js b/src/components/EpisodeSelector.js index e2281106..74a95dda 100644 --- a/src/components/EpisodeSelector.js +++ b/src/components/EpisodeSelector.js @@ -3,11 +3,34 @@ import { TypeSelector } from './TypeSelector'; import { NumberSelector } from './NumberSelector'; import './EpisodeSelector.css' -export function EpisodeSelector({ setSeason, setEpisode, seasons, episodes, currentSeason, currentEpisode }) { +export function EpisodeSelector({ setSeason, setEpisode, seasons, season, episodes, currentSeason, currentEpisode, slug }) { + + const choices = episodes.map(v => { + + let progressData = JSON.parse(localStorage.getItem('video-progress') || "{}") + + let currentlyAt = 0; + let totalDuration = 0; + + const progress = progressData?.lookmovie?.show?.[slug][`${season}-${v}`] + if(progress) { + currentlyAt = progress.currentlyAt + totalDuration = progress.totalDuration + } + + const percentage = Math.round((currentlyAt / totalDuration) * 100) + + return { + value: v.toString(), + label: v, + percentage + } + }) + return (
({ value: v.toString(), label: `Season ${v}`}))} selected={currentSeason}/>

- setEpisode({episode: e, season: currentSeason})} choices={episodes.map(v=>({ value: v.toString(), label: v}))} selected={currentEpisode.season === currentSeason?currentEpisode.episode:null}/> + setEpisode({episode: e, season: currentSeason})} choices={choices} selected={currentEpisode.season === currentSeason?currentEpisode.episode:null}/>
) } diff --git a/src/components/MovieRow.css b/src/components/MovieRow.css index 99a6cad0..a32463b5 100644 --- a/src/components/MovieRow.css +++ b/src/components/MovieRow.css @@ -1,4 +1,5 @@ .movieRow { + position: relative; display: flex; border-radius: 5px; background-color: var(--content); @@ -8,6 +9,7 @@ cursor: pointer; transition: transform 50ms ease-in-out; user-select: none; + overflow: hidden; } .movieRow p { diff --git a/src/components/MovieRow.js b/src/components/MovieRow.js index a3ae80bd..9473dfa0 100644 --- a/src/components/MovieRow.js +++ b/src/components/MovieRow.js @@ -1,10 +1,22 @@ import React from 'react' import { Arrow } from './Arrow' import './MovieRow.css' +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") { + progress = progressData?.lookmovie?.movie?.[props.slug]?.full + if(progress) { + percentage = Math.floor((progress.currentlyAt / progress.totalDuration) * 100) + } + } + return (
props.onClick && props.onClick()}>
@@ -15,6 +27,7 @@ export function MovieRow(props) {

Watch {props.type}

+
) } diff --git a/src/components/NumberSelector.css b/src/components/NumberSelector.css index 21de53d1..3c8d5f06 100644 --- a/src/components/NumberSelector.css +++ b/src/components/NumberSelector.css @@ -8,6 +8,8 @@ .numberSelector .choiceWrapper { position: relative; + border-radius: 10%; + overflow: hidden; } .numberSelector .choiceWrapper::before { @@ -34,7 +36,6 @@ font-weight: bold; cursor: pointer; user-select: none; - border-radius: 10%; box-sizing: border-box; } @@ -46,3 +47,4 @@ color: var(--choice-active-text, var(--text)); background-color: var(--choice-active); } + diff --git a/src/components/NumberSelector.js b/src/components/NumberSelector.js index ecbf9658..1bcf3d20 100644 --- a/src/components/NumberSelector.js +++ b/src/components/NumberSelector.js @@ -1,6 +1,7 @@ import React from 'react'; // import { Arrow } from './Arrow'; import './NumberSelector.css' +import { PercentageOverlay } from './PercentageOverlay'; // setType: (txt: string) => void // choices: { label: string, value: string }[] @@ -10,8 +11,9 @@ export function NumberSelector({ setType, choices, selected }) {
{choices.map(v=>(
-
setType(v.value)}> +
setType(v.value)}> {v.label} +
))} diff --git a/src/components/PercentageOverlay.css b/src/components/PercentageOverlay.css new file mode 100644 index 00000000..259f25dd --- /dev/null +++ b/src/components/PercentageOverlay.css @@ -0,0 +1,12 @@ +.progressBar { + position: absolute; + bottom: 0; + left: 0; + width: 100%; + height: 100%; + opacity: 0.2; +} +.progressBarInner { + background: var(--theme-color); + height: 100%; +} \ No newline at end of file diff --git a/src/components/PercentageOverlay.js b/src/components/PercentageOverlay.js new file mode 100644 index 00000000..50a23a0a --- /dev/null +++ b/src/components/PercentageOverlay.js @@ -0,0 +1,13 @@ +import React from 'react' +import './PercentageOverlay.css' + +export function PercentageOverlay({ percentage }) { + + if(percentage && percentage > 3) percentage = Math.max(20, percentage < 90 ? percentage : 100) + + return percentage > 0 ? ( +
+
+
+ ) : +} \ No newline at end of file diff --git a/src/components/TypeSelector.css b/src/components/TypeSelector.css index 80902e74..2a3d0743 100644 --- a/src/components/TypeSelector.css +++ b/src/components/TypeSelector.css @@ -5,6 +5,8 @@ position: relative; margin-bottom: 1.5rem; max-width: 100%; +} +.typeSelector:not(.nowrap) { flex-wrap: wrap; } @@ -52,8 +54,7 @@ } @media screen and (max-width: 700px) { - .typeSelector { - width: 80%; + .typeSelector:not(.nowrap) { display: block; } } diff --git a/src/components/TypeSelector.js b/src/components/TypeSelector.js index ee96b275..05f545e3 100644 --- a/src/components/TypeSelector.js +++ b/src/components/TypeSelector.js @@ -5,14 +5,14 @@ import './TypeSelector.css' // setType: (txt: string) => void // choices: { label: string, value: string }[] // selected: string -export function TypeSelector({ setType, choices, selected }) { +export function TypeSelector({ setType, choices, selected, noWrap = false }) { const selectedIndex = choices.findIndex(v=>v.value===selected); const transformStyles = { opacity: selectedIndex!==-1?1:0, transform: `translateX(${selectedIndex!==-1?selectedIndex*7:0}rem)` } return ( -
+
{choices.map(v=>(
setType(v.value)}> {v.label} diff --git a/src/components/VideoElement.css b/src/components/VideoElement.css index cff2fd1d..f252de55 100644 --- a/src/components/VideoElement.css +++ b/src/components/VideoElement.css @@ -1,6 +1,6 @@ .videoElement { width: 100%; - background-color: var(--content); + background-color: black; border-radius: 5px; } diff --git a/src/components/VideoElement.js b/src/components/VideoElement.js index f1aa506a..35ec011a 100644 --- a/src/components/VideoElement.js +++ b/src/components/VideoElement.js @@ -5,7 +5,7 @@ import { VideoPlaceholder } from './VideoPlaceholder' // streamUrl: string // loading: boolean -export function VideoElement({ streamUrl, loading }) { +export function VideoElement({ streamUrl, loading, setProgress }) { const videoRef = React.useRef(null); const [error, setError] = React.useState(false); @@ -37,6 +37,6 @@ export function VideoElement({ streamUrl, loading }) { return No video selected return ( -