Use posters instead of thumbnails when no thumbnails exist

This commit is contained in:
Zoe Roux 2023-09-02 17:20:34 +02:00
parent 70466aba7e
commit b89617d125
No known key found for this signature in database
3 changed files with 125 additions and 104 deletions

View File

@ -25,64 +25,74 @@ import { Genre } from "./genre";
import { StudioP } from "./studio"; import { StudioP } from "./studio";
import { Status } from "./show"; import { Status } from "./show";
export const MovieP = ResourceP.merge(ImagesP).extend({ export const MovieP = ResourceP.merge(ImagesP)
/** .extend({
* The title of this movie.
*/
name: z.string(),
/**
* A catchphrase for this show.
*/
tagline: z.string().nullable(),
/**
* The list of alternative titles of this movie.
*/
aliases: z.array(z.string()),
/**
* The summary of this movie.
*/
overview: z.string().nullable(),
/**
* A list of tags that match this movie.
*/
tags: z.array(z.string()),
/**
/**
* Is this movie not aired yet or finished?
*/
status: z.nativeEnum(Status),
/**
* The date this movie aired. It can also be null if this is unknown.
*/
airDate: zdate().nullable(),
/**
* A youtube url for the trailer.
*/
trailer: z.string().optional().nullable(),
/**
* The list of genres (themes) this movie has.
*/
genres: z.array(z.nativeEnum(Genre)),
/**
* The studio that made this movie.
*/
studio: StudioP.optional().nullable(),
/**
* The links to see a movie or an episode.
*/
links: z.object({
/** /**
* The direct link to the unprocessed video (pristine quality). * The title of this movie.
*/ */
direct: z.string().transform(imageFn), name: z.string(),
/**
* A catchphrase for this show.
*/
tagline: z.string().nullable(),
/**
* The list of alternative titles of this movie.
*/
aliases: z.array(z.string()),
/**
* The summary of this movie.
*/
overview: z.string().nullable(),
/**
* A list of tags that match this movie.
*/
tags: z.array(z.string()),
/**
* /** Is this movie not aired yet or finished?
*/
status: z.nativeEnum(Status),
/**
* The date this movie aired. It can also be null if this is unknown.
*/
airDate: zdate().nullable(),
/**
* A youtube url for the trailer.
*/
trailer: z.string().optional().nullable(),
/**
* The list of genres (themes) this movie has.
*/
genres: z.array(z.nativeEnum(Genre)),
/**
* The studio that made this movie.
*/
studio: StudioP.optional().nullable(),
/** /**
* The link to an HLS master playlist containing all qualities available for this video. * The links to see a movie or an episode.
*/ */
hls: z.string().transform(imageFn), links: z.object({
}), /**
}); * The direct link to the unprocessed video (pristine quality).
*/
direct: z.string().transform(imageFn),
/**
* The link to an HLS master playlist containing all qualities available for this video.
*/
hls: z.string().transform(imageFn),
}),
})
.transform((x) => {
if (!x.thumbnail && x.poster) {
x.thumbnail = { ...x.poster };
if (x.thumbnail) {
x.thumbnail.low = x.thumbnail.high;
x.thumbnail.medium = x.thumbnail.high;
}
}
return x;
});
/** /**
* A Movie type * A Movie type

View File

@ -35,56 +35,67 @@ export enum Status {
Planned = "Planned", Planned = "Planned",
} }
export const ShowP = ResourceP.merge(ImagesP).extend({ export const ShowP = ResourceP.merge(ImagesP)
/** .extend({
* The title of this show. /**
*/ * The title of this show.
name: z.string(), */
/** name: z.string(),
* A catchphrase for this show. /**
*/ * A catchphrase for this show.
tagline: z.string().nullable(), */
/** tagline: z.string().nullable(),
* The list of alternative titles of this show. /**
*/ * The list of alternative titles of this show.
aliases: z.array(z.string()), */
/** aliases: z.array(z.string()),
* The summary of this show. /**
*/ * The summary of this show.
overview: z.string().nullable(), */
/** overview: z.string().nullable(),
* A list of tags that match this movie. /**
*/ * A list of tags that match this movie.
tags: z.array(z.string()), */
/** tags: z.array(z.string()),
* Is this show airing, not aired yet or finished? /**
*/ * Is this show airing, not aired yet or finished?
status: z.nativeEnum(Status), */
/** status: z.nativeEnum(Status),
* The date this show started airing. It can be null if this is unknown. /**
*/ * The date this show started airing. It can be null if this is unknown.
startAir: zdate().nullable(), */
/** startAir: zdate().nullable(),
* The date this show finished airing. It can also be null if this is unknown. /**
*/ * The date this show finished airing. It can also be null if this is unknown.
endAir: zdate().nullable(), */
/** endAir: zdate().nullable(),
* The list of genres (themes) this show has. /**
*/ * The list of genres (themes) this show has.
genres: z.array(z.nativeEnum(Genre)), */
/** genres: z.array(z.nativeEnum(Genre)),
* A youtube url for the trailer. /**
*/ * A youtube url for the trailer.
trailer: z.string().optional().nullable(), */
/** trailer: z.string().optional().nullable(),
* The studio that made this show. /**
*/ * The studio that made this show.
studio: StudioP.optional().nullable(), */
/** studio: StudioP.optional().nullable(),
* The list of seasons of this show. /**
*/ * The list of seasons of this show.
seasons: z.array(SeasonP).optional(), */
}); seasons: z.array(SeasonP).optional(),
})
.transform((x) => {
if (!x.thumbnail && x.poster) {
x.thumbnail = { ...x.poster };
if (x.thumbnail) {
x.thumbnail.low = x.thumbnail.high;
x.thumbnail.medium = x.thumbnail.high;
}
}
return x;
});
/** /**
* A tv serie or an anime. * A tv serie or an anime.

View File

@ -46,7 +46,7 @@ export const ItemList = ({
<ImageBackground <ImageBackground
src={thumbnail} src={thumbnail}
alt={name} alt={name}
quality="low" quality="medium"
as={Link} as={Link}
href={href ?? ""} href={href ?? ""}
onFocus={() => setHovered((i) => i + 1)} onFocus={() => setHovered((i) => i + 1)}