diff --git a/api/src/models/entry/movie-entry.ts b/api/src/models/entry/movie-entry.ts index d7ca4fc2..7e6e9e14 100644 --- a/api/src/models/entry/movie-entry.ts +++ b/api/src/models/entry/movie-entry.ts @@ -4,8 +4,8 @@ import { bubbleImages, madeInAbyss, registerExamples } from "../examples"; import { Progress } from "../history"; import { DbMetadata, - ExternalId, Image, + MovieEpisodeId, Resource, SeedImage, TranslationRecord, @@ -20,7 +20,7 @@ export const BaseMovieEntry = t.Composite( order: t.Number({ description: "Absolute playback order. Can be mixed with episodes.", }), - externalId: ExternalId(), + externalId: MovieEpisodeId, }), BaseEntry(), ], diff --git a/api/src/models/utils/external-id.ts b/api/src/models/utils/external-id.ts index 806c790d..39f6451e 100644 --- a/api/src/models/utils/external-id.ts +++ b/api/src/models/utils/external-id.ts @@ -30,6 +30,31 @@ export const EpisodeId = t.Record( ); export type EpisodeId = typeof EpisodeId.static; +export const MovieEpisodeId = t.Record( + t.String(), + t.Union([ + t.Object({ + dataId: t.String(), + link: t.Nullable(t.String({ format: "uri" })), + }), + t.Object({ + serieId: t.String({ + descrpition: comment` + Id on the external website. + We store the serie's id because episode id are rarely stable. + `, + }), + season: t.Nullable( + t.Integer({ + description: "Null if the external website uses absolute numbering.", + }), + ), + episode: t.Integer(), + link: t.Nullable(t.String({ format: "uri" })), + }), + ]), +); + export const SeasonId = t.Record( t.String(), t.Object({