mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Fix externalids error with null
This commit is contained in:
parent
7dab3fd094
commit
4f7c449ea7
@ -41,7 +41,7 @@ namespace Kyoo.Abstractions.Models
|
||||
);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Guid Id { get; set; } = Guid.Empty;
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[Computed]
|
||||
|
@ -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<typeof MetadataP>;
|
||||
|
@ -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"]
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user