diff --git a/src/components/Dropdown.tsx b/src/components/Dropdown.tsx index e1e46aa1..32c89cb8 100644 --- a/src/components/Dropdown.tsx +++ b/src/components/Dropdown.tsx @@ -16,7 +16,7 @@ interface DropdownProps { export const Dropdown = React.forwardRef( (props: DropdownProps) => ( -
+
{({ open }) => ( <> @@ -37,7 +37,7 @@ export const Dropdown = React.forwardRef( leaveFrom="opacity-100" leaveTo="opacity-0" > - + {props.options.map((opt) => ( diff --git a/src/components/layout/Seasons.tsx b/src/components/layout/Seasons.tsx index ddfef7b9..51ada962 100644 --- a/src/components/layout/Seasons.tsx +++ b/src/components/layout/Seasons.tsx @@ -1,4 +1,6 @@ +import { IconPatch } from "components/buttons/IconPatch"; import { Dropdown, OptionItem } from "components/Dropdown"; +import { Icons } from "components/Icon"; import { WatchedEpisode } from "components/media/WatchedEpisodeButton"; import { useLoading } from "hooks/useLoading"; import { serializePortableMedia } from "hooks/usePortableMedia"; @@ -17,6 +19,28 @@ export interface SeasonsProps { media: MWMedia; } +export function LoadingSeasons(props: { error?: boolean }) { + return ( +
+
+
+
+ {!props.error ? ( + <> +
+
+
+ + ) : ( +
+ +

Failed to load seasons and episodes

+
+ )} +
+ ); +} + export function Seasons(props: SeasonsProps) { const [searchSeasons, loading, error, success] = useLoading( (portableMedia: MWPortableMedia) => getSeasonDataFromMedia(portableMedia) @@ -58,8 +82,8 @@ export function Seasons(props: SeasonsProps) { return ( <> - {loading ?

Loading...

: null} - {error ?

error!

: null} + {loading ? : null} + {error ? : null} {success && seasons.seasons.length ? ( <> { - return { - ...media, - year: "1234", - title: "temp", - }; - }, - - async searchForMedia(query: MWQuery): Promise { - return []; - }, - - async getStream(media: MWPortableMedia): Promise { - return { - url: "hi", - type: "mp4", - }; - }, - - async getSeasonDataFromMedia(media): Promise { - return { - seasons: [], - }; - }, -}; diff --git a/src/providers/list/theflix/index.ts b/src/providers/list/theflix/index.ts index 38441c1e..fadfd53b 100644 --- a/src/providers/list/theflix/index.ts +++ b/src/providers/list/theflix/index.ts @@ -84,13 +84,22 @@ export const theFlixScraper: MWMediaProvider = { .querySelectorAll(`script[id="__NEXT_DATA__"]`) )[0]; - const data = JSON.parse(node.innerHTML).props.pageProps.selectedTv.seasons; + let data = JSON.parse(node.innerHTML).props.pageProps.selectedTv.seasons; + + data = data.filter((season: any) => season.releaseDate != null); + data = data.map((season: any) => { + const episodes = season.episodes.filter( + (episode: any) => episode.releaseDate != null + ); + return { ...season, episodes }; + }); + return { seasons: data.map((d: any) => ({ sort: d.seasonNumber === 0 ? 999 : d.seasonNumber, id: d.seasonNumber.toString(), type: d.seasonNumber === 0 ? "special" : "season", - title: d.seasonNumber === 0 ? "Specials" : undefined, + title: d.name, episodes: d.episodes.map((e: any) => ({ title: e.name, sort: e.episodeNumber, diff --git a/src/views/MediaView.tsx b/src/views/MediaView.tsx index 69a2ccfc..cfceedf3 100644 --- a/src/views/MediaView.tsx +++ b/src/views/MediaView.tsx @@ -2,7 +2,7 @@ import { IconPatch } from "components/buttons/IconPatch"; import { Icons } from "components/Icon"; import { Navigation } from "components/layout/Navigation"; import { Paper } from "components/layout/Paper"; -import { Seasons } from "components/layout/Seasons"; +import { LoadingSeasons, Seasons } from "components/layout/Seasons"; import { SkeletonVideoPlayer, VideoPlayer } from "components/media/VideoPlayer"; import { ArrowLink } from "components/text/ArrowLink"; import { DotList } from "components/text/DotList"; @@ -110,7 +110,14 @@ function LoadingMediaFooter(props: { error?: boolean }) {
- {props.error ? "error!" : null} + {props.error ? ( +
+ +

Your url may be invalid

+
+ ) : ( + + )}