From 6b0e3e75776cfdbd0aec385e3698c934c8255b6c Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 8 Mar 2025 15:20:28 +0100 Subject: [PATCH] Add original name & `latinName` in series/movie --- api/src/models/examples/bubble.ts | 1 + api/src/models/movie.ts | 13 +++++++------ api/src/models/serie.ts | 27 +++++++++++++++------------ api/src/models/utils/orignial.ts | 25 +++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 18 deletions(-) create mode 100644 api/src/models/utils/orignial.ts diff --git a/api/src/models/examples/bubble.ts b/api/src/models/examples/bubble.ts index 7ea2399c..9f66f701 100644 --- a/api/src/models/examples/bubble.ts +++ b/api/src/models/examples/bubble.ts @@ -32,6 +32,7 @@ export const bubble: SeedMovie = { }, ja: { name: "バブル:2022", + latinName: "Buburu", tagline: null, description: null, aliases: ["Baburu", "Bubble"], diff --git a/api/src/models/movie.ts b/api/src/models/movie.ts index 0e70cce6..ce709318 100644 --- a/api/src/models/movie.ts +++ b/api/src/models/movie.ts @@ -1,5 +1,5 @@ import { t } from "elysia"; -import type { Prettify } from "~/utils"; +import { type Prettify, comment } from "~/utils"; import { SeedCollection } from "./collections"; import { bubble, bubbleImages, registerExamples } from "./examples"; import { SeedStudio, Studio } from "./studio"; @@ -13,6 +13,7 @@ import { SeedImage, TranslationRecord, } from "./utils"; +import { Original } from "./utils/orignial"; import { Video } from "./video"; export const MovieStatus = t.UnionEnum(["unknown", "finished", "planned"]); @@ -28,11 +29,6 @@ const BaseMovie = t.Object({ ), airDate: t.Nullable(t.String({ format: "date" })), - originalLanguage: t.Nullable( - Language({ - description: "The language code this movie was made in.", - }), - ), nextRefresh: t.String({ format: "date-time" }), @@ -60,6 +56,7 @@ export const Movie = t.Intersect([ BaseMovie, DbMetadata, t.Object({ + original: Original, isAvailable: t.Boolean(), }), ]); @@ -79,6 +76,9 @@ export const SeedMovie = t.Intersect([ t.Omit(BaseMovie, ["kind", "nextRefresh"]), t.Object({ slug: t.String({ format: "slug", examples: ["bubble"] }), + originalLanguage: Language({ + description: "The language code this movie was made in.", + }), translations: TranslationRecord( t.Intersect([ t.Omit(MovieTranslation, ["poster", "thumbnail", "banner", "logo"]), @@ -87,6 +87,7 @@ export const SeedMovie = t.Intersect([ thumbnail: t.Nullable(SeedImage), banner: t.Nullable(SeedImage), logo: t.Nullable(SeedImage), + latinName: t.Optional(Original.properties.latinName), }), ]), ), diff --git a/api/src/models/serie.ts b/api/src/models/serie.ts index e94742f8..06b38e72 100644 --- a/api/src/models/serie.ts +++ b/api/src/models/serie.ts @@ -15,6 +15,7 @@ import { SeedImage, TranslationRecord, } from "./utils"; +import { Original } from "./utils/orignial"; export const SerieStatus = t.UnionEnum([ "unknown", @@ -38,19 +39,8 @@ const BaseSerie = t.Object({ startAir: t.Nullable(t.String({ format: "date" })), endAir: t.Nullable(t.String({ format: "date" })), - originalLanguage: t.Nullable( - Language({ - description: "The language code this serie was made in.", - }), - ), nextRefresh: t.String({ format: "date-time" }), - entriesCount: t.Integer({ - description: "The number of episodes in this serie", - }), - availableCount: t.Integer({ - description: "The number of episodes that can be played right away", - }), externalId: ExternalId(), }); @@ -75,6 +65,15 @@ export const Serie = t.Intersect([ SerieTranslation, BaseSerie, DbMetadata, + t.Object({ + original: Original, + entriesCount: t.Integer({ + description: "The number of episodes in this serie", + }), + availableCount: t.Integer({ + description: "The number of episodes that can be played right away", + }), + }), ]); export type Serie = Prettify; @@ -88,9 +87,12 @@ export const FullSerie = t.Intersect([ export type FullMovie = Prettify; export const SeedSerie = t.Intersect([ - t.Omit(BaseSerie, ["kind", "nextRefresh", "entriesCount", "availableCount"]), + t.Omit(BaseSerie, ["kind", "nextRefresh"]), t.Object({ slug: t.String({ format: "slug" }), + originalLanguage: Language({ + description: "The language code this serie was made in.", + }), translations: TranslationRecord( t.Intersect([ t.Omit(SerieTranslation, ["poster", "thumbnail", "banner", "logo"]), @@ -99,6 +101,7 @@ export const SeedSerie = t.Intersect([ thumbnail: t.Nullable(SeedImage), banner: t.Nullable(SeedImage), logo: t.Nullable(SeedImage), + latinName: t.Optional(Original.properties.latinName), }), ]), ), diff --git a/api/src/models/utils/orignial.ts b/api/src/models/utils/orignial.ts new file mode 100644 index 00000000..5e51b11f --- /dev/null +++ b/api/src/models/utils/orignial.ts @@ -0,0 +1,25 @@ +import { t } from "elysia"; +import { comment } from "~/utils"; +import { Language } from "./language"; + +export const Original = t.Object({ + language: Language({ + description: "The language code this was made in.", + examples: ["ja"] + }), + name: t.String({ + description: "The name in the original language", + examples: ["進撃の巨人"], + }), + latinName: t.Nullable( + t.String({ + description: comment` + The original name but using latin scripts. + This is only set if the original language is written with another + alphabet (like japanase, korean, chineses...) + `, + examples: ["Shingeki no Kyojin"], + }), + ), +}); +export type Original = typeof Original.static;