mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-10-26 08:12:35 -04:00
Type video in the front
This commit is contained in:
parent
6877b340b1
commit
e122f251c9
@ -1,4 +1,46 @@
|
|||||||
import { z } from "zod/v4";
|
import { z } from "zod/v4";
|
||||||
|
import { Entry } from "./entry";
|
||||||
|
import { Extra } from "./extra";
|
||||||
|
import { zdate } from "./utils/utils";
|
||||||
|
|
||||||
|
export const Video = z.object({
|
||||||
|
id: z.string(),
|
||||||
|
path: z.string(),
|
||||||
|
rendering: z.string(),
|
||||||
|
part: z.int().min(0).nullable(),
|
||||||
|
version: z.int().min(0).default(1),
|
||||||
|
guess: z.object({
|
||||||
|
title: z.string(),
|
||||||
|
kind: z.enum(["episode", "movie", "extra"]).nullable().optional(),
|
||||||
|
extraKind: Extra.shape.kind.optional().nullable(),
|
||||||
|
years: z.array(z.int()).default([]),
|
||||||
|
episodes: z
|
||||||
|
.array(
|
||||||
|
z.object({
|
||||||
|
season: z.int().nullable(),
|
||||||
|
episode: z.int(),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.default([]),
|
||||||
|
externalId: z.record(z.string(), z.string()).default({}),
|
||||||
|
|
||||||
|
// Name of the tool that made the guess
|
||||||
|
from: z.string(),
|
||||||
|
get history() {
|
||||||
|
return z.array(Video.shape.guess.omit({ history: true })).default([]);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
createdAt: zdate(),
|
||||||
|
updatedAt: zdate(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const FullVideo = Video.extend({
|
||||||
|
slugs: z.array(z.string()),
|
||||||
|
entries: z.array(Entry),
|
||||||
|
previous: z.object({ video: z.string(), entry: Entry }).nullable().optional(),
|
||||||
|
next: z.object({ video: z.string(), entry: Entry }).nullable().optional(),
|
||||||
|
});
|
||||||
|
export type FullVideo = z.infer<typeof FullVideo>;
|
||||||
|
|
||||||
export const EmbeddedVideo = z.object({
|
export const EmbeddedVideo = z.object({
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
|
|||||||
@ -3,15 +3,9 @@ import { type ComponentProps, useEffect, useState } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Platform, StyleSheet, View } from "react-native";
|
import { Platform, StyleSheet, View } from "react-native";
|
||||||
import { useYoshiki } from "yoshiki/native";
|
import { useYoshiki } from "yoshiki/native";
|
||||||
import {
|
import { type Episode, FullVideo, type Movie, VideoInfo } from "~/models";
|
||||||
Episode,
|
|
||||||
Movie,
|
|
||||||
type QueryIdentifier,
|
|
||||||
useFetch,
|
|
||||||
type WatchInfo,
|
|
||||||
WatchInfoP,
|
|
||||||
} from "~/models";
|
|
||||||
import { Head } from "~/primitives";
|
import { Head } from "~/primitives";
|
||||||
|
import type { QueryIdentifier } from "~/query";
|
||||||
import { Back, Hover, LoadingIndicator } from "./components/hover";
|
import { Back, Hover, LoadingIndicator } from "./components/hover";
|
||||||
import { useVideoKeyboard } from "./keyboard";
|
import { useVideoKeyboard } from "./keyboard";
|
||||||
import { durationAtom, fullscreenAtom, Video } from "./state";
|
import { durationAtom, fullscreenAtom, Video } from "./state";
|
||||||
@ -181,30 +175,15 @@ export const Player = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Player.query = (
|
Player.query = (slug: string): QueryIdentifier<FullVideo> => ({
|
||||||
type: "episode" | "movie",
|
path: ["api", "videos", slug],
|
||||||
slug: string,
|
|
||||||
): QueryIdentifier<Item> =>
|
|
||||||
type === "episode"
|
|
||||||
? {
|
|
||||||
path: ["episode", slug],
|
|
||||||
params: {
|
params: {
|
||||||
fields: ["nextEpisode", "previousEpisode", "show", "watchStatus"],
|
fields: ["next", "previous", "serie"],
|
||||||
},
|
},
|
||||||
parser: EpisodeP.transform((x) => ({ ...x, type: "episode" })),
|
parser: FullVideo,
|
||||||
}
|
});
|
||||||
: {
|
|
||||||
path: ["movie", slug],
|
Player.infoQuery = (slug: string): QueryIdentifier<VideoInfo> => ({
|
||||||
params: {
|
path: ["api", "videos", slug, "info"],
|
||||||
fields: ["watchStatus"],
|
parser: VideoInfo,
|
||||||
},
|
|
||||||
parser: MovieP.transform((x) => ({ ...x, type: "movie" })),
|
|
||||||
};
|
|
||||||
|
|
||||||
Player.infoQuery = (
|
|
||||||
type: "episode" | "movie",
|
|
||||||
slug: string,
|
|
||||||
): QueryIdentifier<WatchInfo> => ({
|
|
||||||
path: [type, slug, "info"],
|
|
||||||
parser: WatchInfoP,
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user