diff --git a/back/src/Kyoo.Abstractions/Models/Resources/Episode.cs b/back/src/Kyoo.Abstractions/Models/Resources/Episode.cs
index 6c714956..6d7ab289 100644
--- a/back/src/Kyoo.Abstractions/Models/Resources/Episode.cs
+++ b/back/src/Kyoo.Abstractions/Models/Resources/Episode.cs
@@ -41,7 +41,7 @@ namespace Kyoo.Abstractions.Models
);
///
- public Guid Id { get; set; } = Guid.Empty;
+ public Guid Id { get; set; }
///
[Computed]
diff --git a/front/packages/models/src/resources/metadata.ts b/front/packages/models/src/resources/metadata.ts
index e8c3ad2d..082155a7 100644
--- a/front/packages/models/src/resources/metadata.ts
+++ b/front/packages/models/src/resources/metadata.ts
@@ -20,18 +20,22 @@
import { z } from "zod";
-export const MetadataP = z.record(
- z.object({
- /*
- * The ID of the resource on the external provider.
- */
- dataId: z.string(),
+export const MetadataP = z.preprocess(
+ (x) =>
+ typeof x === "object" && x ? Object.fromEntries(Object.entries(x).filter(([_, v]) => v)) : x,
+ z.record(
+ z.object({
+ /*
+ * The ID of the resource on the external provider.
+ */
+ dataId: z.string(),
- /*
- * The URL of the resource on the external provider.
- */
- link: z.string().nullable(),
- }),
+ /*
+ * The URL of the resource on the external provider.
+ */
+ link: z.string().nullable(),
+ }),
+ ),
);
export type Metadata = z.infer;
diff --git a/scanner/providers/implementations/themoviedatabase.py b/scanner/providers/implementations/themoviedatabase.py
index d8bd9a77..c2bfb0ab 100644
--- a/scanner/providers/implementations/themoviedatabase.py
+++ b/scanner/providers/implementations/themoviedatabase.py
@@ -257,16 +257,22 @@ class TheMovieDatabase(Provider):
self.name: MetadataID(
show["id"], f"https://www.themoviedb.org/tv/{show['id']}"
),
- "imdb": MetadataID(
- show["external_ids"]["imdb_id"],
- f"https://www.imdb.com/title/{show['external_ids']['imdb_id']}",
- )
+ }
+ | (
+ {
+ "imdb": MetadataID(
+ show["external_ids"]["imdb_id"],
+ f"https://www.imdb.com/title/{show['external_ids']['imdb_id']}",
+ )
+ }
if show["external_ids"]["imdb_id"]
- else None,
- "tvdb": MetadataID(show["external_ids"]["tvdb_id"], link=None)
+ else {}
+ )
+ | (
+ {"tvdb": MetadataID(show["external_ids"]["tvdb_id"], link=None)}
if show["external_ids"]["tvdb_id"]
- else None,
- },
+ else {}
+ ),
seasons=[
self.to_season(x, language=lng, show_id=show["id"])
for x in show["seasons"]
diff --git a/scanner/providers/types/show.py b/scanner/providers/types/show.py
index 65a37a9c..3556f628 100644
--- a/scanner/providers/types/show.py
+++ b/scanner/providers/types/show.py
@@ -43,7 +43,7 @@ class Show:
seasons: list[Season]
# TODO: handle staff
# staff: list[Staff]
- external_id: dict[str, MetadataID | None]
+ external_id: dict[str, MetadataID]
translations: dict[str, ShowTranslation] = field(default_factory=dict)