mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Add unknown video example
This commit is contained in:
parent
c96365fe0a
commit
6402b3cae6
@ -342,6 +342,6 @@ export const entriesH = new Elysia({ tags: ["series"] })
|
||||
200: Page(UnknownEntry),
|
||||
422: KError,
|
||||
},
|
||||
tags: [],
|
||||
tags: ["videos"],
|
||||
},
|
||||
);
|
||||
|
@ -1,18 +1,22 @@
|
||||
import { t } from "elysia";
|
||||
import { Image } from "../utils/image";
|
||||
|
||||
export const BaseEntry = t.Object({
|
||||
airDate: t.Nullable(t.String({ format: "date" })),
|
||||
runtime: t.Nullable(
|
||||
t.Number({ minimum: 0, description: "Runtime of the episode in minutes" }),
|
||||
),
|
||||
thumbnail: t.Nullable(Image),
|
||||
export const BaseEntry = () =>
|
||||
t.Object({
|
||||
airDate: t.Nullable(t.String({ format: "date" })),
|
||||
runtime: t.Nullable(
|
||||
t.Number({
|
||||
minimum: 0,
|
||||
description: "Runtime of the episode in minutes",
|
||||
}),
|
||||
),
|
||||
thumbnail: t.Nullable(Image),
|
||||
|
||||
createdAt: t.String({ format: "date-time" }),
|
||||
nextRefresh: t.String({ format: "date-time" }),
|
||||
});
|
||||
createdAt: t.String({ format: "date-time" }),
|
||||
nextRefresh: t.String({ format: "date-time" }),
|
||||
});
|
||||
|
||||
export const EntryTranslation = t.Object({
|
||||
export const EntryTranslation = () => t.Object({
|
||||
name: t.Nullable(t.String()),
|
||||
description: t.Nullable(t.String()),
|
||||
});
|
||||
|
@ -12,17 +12,17 @@ export const BaseEpisode = t.Intersect([
|
||||
episodeNumber: t.Integer(),
|
||||
externalId: EpisodeId,
|
||||
}),
|
||||
BaseEntry,
|
||||
BaseEntry(),
|
||||
]);
|
||||
|
||||
export const Episode = t.Intersect([Resource(), EntryTranslation, BaseEpisode]);
|
||||
export const Episode = t.Intersect([Resource(), EntryTranslation(), BaseEpisode]);
|
||||
export type Episode = Prettify<typeof Episode.static>;
|
||||
|
||||
export const SeedEpisode = t.Intersect([
|
||||
t.Omit(BaseEpisode, ["thumbnail", "createdAt", "nextRefresh"]),
|
||||
t.Object({
|
||||
thumbnail: t.Nullable(SeedImage),
|
||||
translations: TranslationRecord(EntryTranslation),
|
||||
translations: TranslationRecord(EntryTranslation()),
|
||||
videos: t.Optional(t.Array(t.String({ format: "uuid" }))),
|
||||
}),
|
||||
]);
|
||||
|
@ -21,7 +21,7 @@ export const BaseExtra = t.Intersect(
|
||||
kind: ExtraType,
|
||||
name: t.String(),
|
||||
}),
|
||||
t.Omit(BaseEntry, ["nextRefresh", "airDate"]),
|
||||
t.Omit(BaseEntry(), ["nextRefresh", "airDate"]),
|
||||
],
|
||||
{
|
||||
description: comment`
|
||||
|
@ -20,7 +20,7 @@ export const BaseMovieEntry = t.Intersect(
|
||||
}),
|
||||
externalId: ExternalId,
|
||||
}),
|
||||
BaseEntry,
|
||||
BaseEntry(),
|
||||
],
|
||||
{
|
||||
description: comment`
|
||||
@ -31,7 +31,7 @@ export const BaseMovieEntry = t.Intersect(
|
||||
);
|
||||
|
||||
export const MovieEntryTranslation = t.Intersect([
|
||||
EntryTranslation,
|
||||
EntryTranslation(),
|
||||
t.Object({
|
||||
tagline: t.Nullable(t.String()),
|
||||
poster: t.Nullable(Image),
|
||||
|
@ -15,7 +15,7 @@ export const BaseSpecial = t.Intersect(
|
||||
number: t.Integer({ minimum: 1 }),
|
||||
externalId: EpisodeId,
|
||||
}),
|
||||
BaseEntry,
|
||||
BaseEntry(),
|
||||
],
|
||||
{
|
||||
description: comment`
|
||||
@ -25,14 +25,14 @@ export const BaseSpecial = t.Intersect(
|
||||
},
|
||||
);
|
||||
|
||||
export const Special = t.Intersect([Resource(), EntryTranslation, BaseSpecial]);
|
||||
export const Special = t.Intersect([Resource(), EntryTranslation(), BaseSpecial]);
|
||||
export type Special = Prettify<typeof Special.static>;
|
||||
|
||||
export const SeedSpecial = t.Intersect([
|
||||
t.Omit(BaseSpecial, ["thumbnail", "createdAt", "nextRefresh"]),
|
||||
t.Object({
|
||||
thumbnail: t.Nullable(SeedImage),
|
||||
translations: TranslationRecord(EntryTranslation),
|
||||
translations: TranslationRecord(EntryTranslation()),
|
||||
videos: t.Optional(t.Array(t.String({ format: "uuid" }))),
|
||||
}),
|
||||
]);
|
||||
|
@ -1,14 +1,16 @@
|
||||
import { t } from "elysia";
|
||||
import { type Prettify, comment } from "~/utils";
|
||||
import { bubbleImages, registerExamples } from "../examples";
|
||||
import { youtubeExample } from "../examples/others";
|
||||
import { Resource } from "../utils/resource";
|
||||
import { BaseEntry, EntryTranslation } from "./base-entry";
|
||||
|
||||
export const BaseUnknownEntry = t.Intersect(
|
||||
[
|
||||
t.Omit(BaseEntry, ["airDate"]),
|
||||
t.Object({
|
||||
kind: t.Literal("unknown"),
|
||||
}),
|
||||
t.Omit(BaseEntry(), ["airDate"]),
|
||||
],
|
||||
{
|
||||
description: comment`
|
||||
@ -18,13 +20,15 @@ export const BaseUnknownEntry = t.Intersect(
|
||||
},
|
||||
);
|
||||
|
||||
export const UnknownEntryTranslation = t.Omit(EntryTranslation, [
|
||||
export const UnknownEntryTranslation = t.Omit(EntryTranslation(), [
|
||||
"description",
|
||||
]);
|
||||
|
||||
export const UnknownEntry = t.Intersect([
|
||||
Resource(),
|
||||
BaseUnknownEntry,
|
||||
UnknownEntryTranslation,
|
||||
BaseUnknownEntry,
|
||||
]);
|
||||
export type UnknownEntry = Prettify<typeof UnknownEntry.static>;
|
||||
|
||||
registerExamples(UnknownEntry, { ...youtubeExample, ...bubbleImages });
|
||||
|
10
api/src/models/examples/others.ts
Normal file
10
api/src/models/examples/others.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import type { UnknownEntry } from "~/models/entry";
|
||||
|
||||
export const youtubeExample: Partial<UnknownEntry> = {
|
||||
kind: "unknown",
|
||||
// idk if we'll keep non-ascii characters or if we can find a way to convert them
|
||||
slug: "lisa-炎-the-first-take",
|
||||
name: "LiSA - 炎 / THE FIRST TAKE",
|
||||
runtime: 10,
|
||||
thumbnail: null,
|
||||
};
|
@ -1,5 +1,5 @@
|
||||
import { beforeAll, describe, expect, it } from "bun:test";
|
||||
import { getEntries, getExtras } from "tests/helpers";
|
||||
import { getEntries, getExtras, getUnknowns } from "tests/helpers";
|
||||
import { expectStatus } from "tests/utils";
|
||||
import { seedSerie } from "~/controllers/seed/series";
|
||||
import { madeInAbyss } from "~/models/examples";
|
||||
|
Loading…
x
Reference in New Issue
Block a user