diff --git a/app/components/ReleasePlayer/EpisodeSelector.tsx b/app/components/ReleasePlayer/EpisodeSelector.tsx
index 80ac9ca..2d391da 100644
--- a/app/components/ReleasePlayer/EpisodeSelector.tsx
+++ b/app/components/ReleasePlayer/EpisodeSelector.tsx
@@ -1,3 +1,122 @@
-export const EpisodeSelector = () => {
- return
EPISODES
+"use client";
+
+import { ENDPOINTS } from "#/api/config";
+import { useState, useEffect } from "react";
+import { Swiper, SwiperSlide } from "swiper/react";
+import "swiper/css";
+import "swiper/css/navigation";
+import "swiper/css/mousewheel";
+import "swiper/css/scrollbar";
+import { Navigation, Mousewheel, Scrollbar } from "swiper/modules";
+import { Button } from "flowbite-react";
+
+import {
+ getAnonEpisodesWatched,
+ saveAnonEpisodeWatched,
+} from "./ReleasePlayer";
+
+interface Episode {
+ id: number;
+ position: number;
+ name: string;
+ is_watched: boolean;
}
+
+interface Source {
+ id: number;
+ name: string;
+ episodes_count: number;
+}
+
+export const EpisodeSelector = (props: {
+ availableEpisodes: Episode[];
+ episode: Episode;
+ setEpisode: any;
+ source: Source;
+ release: any;
+ voiceover: any;
+ token: string | null;
+}) => {
+ let anonEpisodesWatched = getAnonEpisodesWatched(
+ props.release,
+ props.source.id,
+ props.voiceover.id
+ );
+ anonEpisodesWatched =
+ anonEpisodesWatched[props.release][props.source.id][props.voiceover.id];
+
+ async function saveEpisodeToHistory(episode: Episode) {
+ if (episode && props.token) {
+ fetch(
+ `${ENDPOINTS.statistic.addHistory}/${props.release}/${props.source.id}/${episode.position}?token=${props.token}`
+ );
+ fetch(
+ `${ENDPOINTS.statistic.markWatched}/${props.release}/${props.source.id}/${episode.position}?token=${props.token}`
+ );
+ }
+ }
+
+ return (
+
+
+ {props.availableEpisodes.map((episode: Episode) => (
+
+
+
+ ))}
+
+
+ );
+};
diff --git a/app/components/ReleasePlayer/ReleasePlayer.tsx b/app/components/ReleasePlayer/ReleasePlayer.tsx
index f6c13d5..7f103e5 100644
--- a/app/components/ReleasePlayer/ReleasePlayer.tsx
+++ b/app/components/ReleasePlayer/ReleasePlayer.tsx
@@ -32,7 +32,7 @@ async function _fetch(url: string) {
return data;
}
-const getAnonEpisodesWatched = (
+export const getAnonEpisodesWatched = (
Release: number,
Source: number,
Voiceover: number
@@ -80,7 +80,7 @@ const getAnonCurrentEpisodeWatched = (
return anonEpisodesWatched[Release][Source][Voiceover][Episode];
};
-const saveAnonEpisodeWatched = (
+export const saveAnonEpisodeWatched = (
Release: number,
Source: number,
Voiceover: number,
diff --git a/app/components/ReleasePlayer/ReleasePlayerCustom.tsx b/app/components/ReleasePlayer/ReleasePlayerCustom.tsx
index a32deeb..31eedc4 100644
--- a/app/components/ReleasePlayer/ReleasePlayerCustom.tsx
+++ b/app/components/ReleasePlayer/ReleasePlayerCustom.tsx
@@ -57,9 +57,11 @@ export const ReleasePlayerCustom = (props: {
voiceover_id: number,
source_id: number
) => {
- const response = await fetch(
- `${ENDPOINTS.release.episode}/${release_id}/${voiceover_id}/${source_id}`
- );
+ let url = `${ENDPOINTS.release.episode}/${release_id}/${voiceover_id}/${source_id}`
+ if (props.token) {
+ url += `?token=${props.token}`;
+ }
+ const response = await fetch(url);
const data = await response.json();
return data;
};
@@ -196,7 +198,7 @@ export const ReleasePlayerCustom = (props: {
episode.selected.url
);
SetPlayerProps({
- src: `${manifest}`,
+ src: manifest,
poster: poster,
useCustom: true,
});
@@ -214,7 +216,7 @@ export const ReleasePlayerCustom = (props: {
}, [episode.selected]);
return (
-
+
{(
!voiceover.selected ||
!source.selected ||
@@ -237,27 +239,24 @@ export const ReleasePlayerCustom = (props: {
setSource={setSource}
/>
- {
- playerProps.useCustom ?
-
-
-
- // @ts-ignore
- //
- :
- }
+ {playerProps.useCustom ?
+
+
+
+ : }
+
}