Commit
·
826955b
1
Parent(s):
5a8b2b7
ESlint patch
Browse files
frontend/app/watch/tvshow/[title]/[season]/[episode]/page.tsx
CHANGED
|
@@ -5,54 +5,60 @@ import TvShowPlayer from '@/components/tvshow/TvShowPlayerv2';
|
|
| 5 |
import { useParams } from 'next/navigation';
|
| 6 |
import { useEffect, useState } from 'react';
|
| 7 |
import { getTvShowMetadata } from '@/lib/lb';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
const TvShowPlayerPage = () => {
|
| 9 |
-
// Assuming you get the movie title from the route params
|
| 10 |
const router = useRouter();
|
| 11 |
const { title, season, episode } = useParams();
|
| 12 |
const videoTitle = Array.isArray(title) ? title[0] : title;
|
| 13 |
const decodedTitle = decodeURIComponent(videoTitle);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
const handleClose = () => {
|
| 15 |
router.back();
|
| 16 |
};
|
| 17 |
|
|
|
|
| 18 |
if (!title || !season || !episode) {
|
| 19 |
return <div>tvshow title, season or episode is missing.</div>;
|
| 20 |
}
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
artworks?: any[];
|
| 31 |
-
file_structure?: any;
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
interface FileStructure {
|
| 35 |
-
contents?: any[];
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
const [tvshow, setTvShow] = useState<TvShow | null>(null);
|
| 39 |
-
const [fileStructure, setFileStructure] = useState<FileStructure>({});
|
| 40 |
-
|
| 41 |
-
useEffect(() => {
|
| 42 |
-
async function fetchMovie() {
|
| 43 |
-
try {
|
| 44 |
-
const data = await getTvShowMetadata(decodedTitle);
|
| 45 |
-
setTvShow(data.data);
|
| 46 |
-
setFileStructure(data.file_structure);
|
| 47 |
-
} catch (error) {
|
| 48 |
-
console.error('Failed to fetch movie details', error);
|
| 49 |
-
}
|
| 50 |
}
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
| 53 |
return (
|
| 54 |
<TvShowPlayer
|
| 55 |
-
videoTitle={
|
| 56 |
season={season as string}
|
| 57 |
episode={episode as string}
|
| 58 |
fileStructure={fileStructure}
|
|
|
|
| 5 |
import { useParams } from 'next/navigation';
|
| 6 |
import { useEffect, useState } from 'react';
|
| 7 |
import { getTvShowMetadata } from '@/lib/lb';
|
| 8 |
+
|
| 9 |
+
interface TvShow {
|
| 10 |
+
name: string;
|
| 11 |
+
image: string;
|
| 12 |
+
translations?: any;
|
| 13 |
+
year?: number;
|
| 14 |
+
genres?: any[];
|
| 15 |
+
score?: number;
|
| 16 |
+
contentRatings?: any[];
|
| 17 |
+
characters?: any;
|
| 18 |
+
artworks?: any[];
|
| 19 |
+
file_structure?: any;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
interface FileStructure {
|
| 23 |
+
contents?: any[];
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
const TvShowPlayerPage = () => {
|
|
|
|
| 28 |
const router = useRouter();
|
| 29 |
const { title, season, episode } = useParams();
|
| 30 |
const videoTitle = Array.isArray(title) ? title[0] : title;
|
| 31 |
const decodedTitle = decodeURIComponent(videoTitle);
|
| 32 |
+
|
| 33 |
+
// State hooks, they should be outside the conditional logic
|
| 34 |
+
const [tvshow, setTvShow] = useState<TvShow | null>(null);
|
| 35 |
+
const [fileStructure, setFileStructure] = useState<FileStructure>({});
|
| 36 |
+
|
| 37 |
const handleClose = () => {
|
| 38 |
router.back();
|
| 39 |
};
|
| 40 |
|
| 41 |
+
// Early return if title, season, or episode is missing
|
| 42 |
if (!title || !season || !episode) {
|
| 43 |
return <div>tvshow title, season or episode is missing.</div>;
|
| 44 |
}
|
| 45 |
+
|
| 46 |
+
useEffect(() => {
|
| 47 |
+
async function fetchTvShow() {
|
| 48 |
+
try {
|
| 49 |
+
const data = await getTvShowMetadata(decodedTitle);
|
| 50 |
+
setTvShow(data.data);
|
| 51 |
+
setFileStructure(data.file_structure);
|
| 52 |
+
} catch (error) {
|
| 53 |
+
console.error('Failed to fetch TV show details', error);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
}
|
| 55 |
+
}
|
| 56 |
+
fetchTvShow();
|
| 57 |
+
}, [decodedTitle]);
|
| 58 |
+
|
| 59 |
return (
|
| 60 |
<TvShowPlayer
|
| 61 |
+
videoTitle={decodedTitle}
|
| 62 |
season={season as string}
|
| 63 |
episode={episode as string}
|
| 64 |
fileStructure={fileStructure}
|