mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 16:33:26 +00:00
feat: fetch and store season data
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
|||||||
extractTracksFromHLS,
|
extractTracksFromHLS,
|
||||||
findHighestQuality,
|
findHighestQuality,
|
||||||
} from "@movie-web/provider-utils";
|
} from "@movie-web/provider-utils";
|
||||||
|
import { fetchSeasonDetails } from "@movie-web/tmdb";
|
||||||
|
|
||||||
import type { ItemData } from "~/components/item/item";
|
import type { ItemData } from "~/components/item/item";
|
||||||
import type { HeaderData } from "~/components/player/Header";
|
import type { HeaderData } from "~/components/player/Header";
|
||||||
@@ -78,6 +79,7 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({ data }) => {
|
|||||||
const setIsIdle = usePlayerStore((state) => state.setIsIdle);
|
const setIsIdle = usePlayerStore((state) => state.setIsIdle);
|
||||||
const _setSourceId = usePlayerStore((state) => state.setSourceId);
|
const _setSourceId = usePlayerStore((state) => state.setSourceId);
|
||||||
const setData = usePlayerStore((state) => state.setData);
|
const setData = usePlayerStore((state) => state.setData);
|
||||||
|
const setSeasonData = usePlayerStore((state) => state.setSeasonData);
|
||||||
const presentFullscreenPlayer = usePlayerStore(
|
const presentFullscreenPlayer = usePlayerStore(
|
||||||
(state) => state.presentFullscreenPlayer,
|
(state) => state.presentFullscreenPlayer,
|
||||||
);
|
);
|
||||||
@@ -165,6 +167,16 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({ data }) => {
|
|||||||
|
|
||||||
const { item, stream, media } = data;
|
const { item, stream, media } = data;
|
||||||
|
|
||||||
|
if (media.type === "show") {
|
||||||
|
const seasonData = await fetchSeasonDetails(
|
||||||
|
media.tmdbId,
|
||||||
|
media.season.number,
|
||||||
|
);
|
||||||
|
if (seasonData) {
|
||||||
|
setSeasonData(seasonData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setStream(stream);
|
setStream(stream);
|
||||||
|
|
||||||
setHeaderData({
|
setHeaderData({
|
||||||
@@ -219,6 +231,7 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({ data }) => {
|
|||||||
presentFullscreenPlayer,
|
presentFullscreenPlayer,
|
||||||
router,
|
router,
|
||||||
setData,
|
setData,
|
||||||
|
setSeasonData,
|
||||||
setStream,
|
setStream,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@@ -12,10 +12,11 @@ import { Text } from "../ui/Text";
|
|||||||
|
|
||||||
export const SeasonEpisodeSelector = () => {
|
export const SeasonEpisodeSelector = () => {
|
||||||
const data = usePlayerStore((state) => state.interface.data);
|
const data = usePlayerStore((state) => state.interface.data);
|
||||||
|
const seasonData = usePlayerStore((state) => state.interface.seasonData);
|
||||||
const { isTrue, on, off } = useBoolean();
|
const { isTrue, on, off } = useBoolean();
|
||||||
const _router = useRouter();
|
const _router = useRouter();
|
||||||
|
|
||||||
return data?.type === "movie" ? null : (
|
return data?.type === "movie" || !seasonData ? null : (
|
||||||
<View className="max-w-36 flex-1">
|
<View className="max-w-36 flex-1">
|
||||||
<Button
|
<Button
|
||||||
title="Episode"
|
title="Episode"
|
||||||
@@ -36,21 +37,21 @@ export const SeasonEpisodeSelector = () => {
|
|||||||
supportedOrientations={["portrait", "landscape"]}
|
supportedOrientations={["portrait", "landscape"]}
|
||||||
>
|
>
|
||||||
<ScrollView className="flex-1 bg-gray-900">
|
<ScrollView className="flex-1 bg-gray-900">
|
||||||
<Text className="text-center font-bold">Select source</Text>
|
<Text className="text-center font-bold">Select episode</Text>
|
||||||
{/* {getBuiltinSources().map((source) => (
|
{seasonData.episodes.map((episode) => (
|
||||||
<Button
|
<Button
|
||||||
key={source.id}
|
key={episode.id}
|
||||||
title={source.name}
|
title={episode.name}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
off();
|
off();
|
||||||
router.push({
|
// router.push({
|
||||||
pathname: "/videoPlayer/loading",
|
// pathname: "/videoPlayer/loading",
|
||||||
params: { sourceID: source.id, data: JSON.stringify(data) },
|
// params: { sourceID: source.id, data: JSON.stringify(data) },
|
||||||
});
|
// });
|
||||||
}}
|
}}
|
||||||
className="max-w-16"
|
className="max-w-16"
|
||||||
/>
|
/>
|
||||||
))} */}
|
))}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</Modal>
|
</Modal>
|
||||||
</View>
|
</View>
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import * as ScreenOrientation from "expo-screen-orientation";
|
import * as ScreenOrientation from "expo-screen-orientation";
|
||||||
|
|
||||||
import type { Stream } from "@movie-web/provider-utils";
|
import type { Stream } from "@movie-web/provider-utils";
|
||||||
|
import type { SeasonDetails } from "@movie-web/tmdb";
|
||||||
|
|
||||||
import type { MakeSlice } from "./types";
|
import type { MakeSlice } from "./types";
|
||||||
import type { ItemData } from "~/components/item/item";
|
import type { ItemData } from "~/components/item/item";
|
||||||
@@ -12,12 +13,14 @@ export interface InterfaceSlice {
|
|||||||
stream: Stream | null;
|
stream: Stream | null;
|
||||||
sourceId: string | null;
|
sourceId: string | null;
|
||||||
data: ItemData | null;
|
data: ItemData | null;
|
||||||
|
seasonData: SeasonDetails | null;
|
||||||
selectedCaption: Stream["captions"][0] | null;
|
selectedCaption: Stream["captions"][0] | null;
|
||||||
};
|
};
|
||||||
setIsIdle(state: boolean): void;
|
setIsIdle(state: boolean): void;
|
||||||
setStream(stream: Stream): void;
|
setStream(stream: Stream): void;
|
||||||
setSourceId(sourceId: string): void;
|
setSourceId(sourceId: string): void;
|
||||||
setData(data: ItemData): void;
|
setData(data: ItemData): void;
|
||||||
|
setSeasonData(data: SeasonDetails): void;
|
||||||
lockOrientation: () => Promise<void>;
|
lockOrientation: () => Promise<void>;
|
||||||
unlockOrientation: () => Promise<void>;
|
unlockOrientation: () => Promise<void>;
|
||||||
presentFullscreenPlayer: () => Promise<void>;
|
presentFullscreenPlayer: () => Promise<void>;
|
||||||
@@ -31,6 +34,7 @@ export const createInterfaceSlice: MakeSlice<InterfaceSlice> = (set, get) => ({
|
|||||||
stream: null,
|
stream: null,
|
||||||
sourceId: null,
|
sourceId: null,
|
||||||
data: null,
|
data: null,
|
||||||
|
seasonData: null,
|
||||||
selectedCaption: null,
|
selectedCaption: null,
|
||||||
},
|
},
|
||||||
setIsIdle: (state) => {
|
setIsIdle: (state) => {
|
||||||
@@ -63,6 +67,11 @@ export const createInterfaceSlice: MakeSlice<InterfaceSlice> = (set, get) => ({
|
|||||||
s.interface.data = data;
|
s.interface.data = data;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
setSeasonData: (data: SeasonDetails) => {
|
||||||
|
set((s) => {
|
||||||
|
s.interface.seasonData = data;
|
||||||
|
});
|
||||||
|
},
|
||||||
lockOrientation: async () => {
|
lockOrientation: async () => {
|
||||||
await ScreenOrientation.lockAsync(
|
await ScreenOrientation.lockAsync(
|
||||||
ScreenOrientation.OrientationLock.LANDSCAPE,
|
ScreenOrientation.OrientationLock.LANDSCAPE,
|
||||||
|
@@ -1,4 +1,8 @@
|
|||||||
|
import type { SeasonDetails } from "tmdb-ts";
|
||||||
|
|
||||||
export const name = "tmdb";
|
export const name = "tmdb";
|
||||||
export * from "./search";
|
export * from "./search";
|
||||||
export * from "./details";
|
export * from "./details";
|
||||||
export * from "./util";
|
export * from "./util";
|
||||||
|
|
||||||
|
export type { SeasonDetails };
|
||||||
|
Reference in New Issue
Block a user