Type guess from videos

This commit is contained in:
Zoe Roux 2025-01-27 18:48:41 +01:00
parent b262aeed5d
commit b0637aeb6a
No known key found for this signature in database

View File

@ -1,7 +1,10 @@
import { t } from "elysia";
import { type TSchema, t } from "elysia";
import { comment } from "../utils";
import { bubbleVideo, registerExamples } from "./examples";
const Guess = <T extends TSchema>(schema: T) =>
t.Optional(t.Union([schema, t.Array(schema)]));
export const Video = t.Object({
id: t.String({ format: "uuid" }),
slug: t.String({ format: "slug" }),
@ -31,6 +34,26 @@ export const Video = t.Object({
}),
createdAt: t.String({ format: "date-time" }),
guess: t.Optional(
t.Object(
{
title: t.Optional(t.String()),
year: Guess(t.Integer()),
season: Guess(t.Integer()),
episode: Guess(t.Integer()),
},
{
additionalProperties: true,
description: comment`
Metadata guessed from the filename. Kyoo can use those informations to bypass
the scanner/metadata fetching and just register videos to movies/entries that already
exists. If Kyoo can't find a matching movie/entry, this information will be sent to
the scanner.
`,
},
),
),
});
export type Video = typeof Video.static;
registerExamples(Video, bubbleVideo);