mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat(frontend/api): beginning of new request modal
also includes new api endpoints for seasons
This commit is contained in:
@@ -9,9 +9,10 @@ import {
|
||||
mapExternalIds,
|
||||
} from './common';
|
||||
import {
|
||||
TmdbTvEpisodeDetails,
|
||||
TmdbTvSeasonDetails,
|
||||
TmdbTvEpisodeResult,
|
||||
TmdbTvSeasonResult,
|
||||
TmdbTvDetails,
|
||||
TmdbSeasonWithEpisodes,
|
||||
} from '../api/themoviedb';
|
||||
import type Media from '../entity/Media';
|
||||
|
||||
@@ -39,6 +40,11 @@ interface Season {
|
||||
seasonNumber: number;
|
||||
}
|
||||
|
||||
interface SeasonWithEpisodes extends Season {
|
||||
episodes: Episode[];
|
||||
externalIds: ExternalIds;
|
||||
}
|
||||
|
||||
export interface TvDetails {
|
||||
id: number;
|
||||
backdropPath?: string;
|
||||
@@ -81,7 +87,7 @@ export interface TvDetails {
|
||||
mediaInfo?: Media;
|
||||
}
|
||||
|
||||
const mapEpisodeDetails = (episode: TmdbTvEpisodeDetails): Episode => ({
|
||||
const mapEpisodeResult = (episode: TmdbTvEpisodeResult): Episode => ({
|
||||
id: episode.id,
|
||||
airDate: episode.air_date,
|
||||
episodeNumber: episode.episode_number,
|
||||
@@ -95,7 +101,7 @@ const mapEpisodeDetails = (episode: TmdbTvEpisodeDetails): Episode => ({
|
||||
stillPath: episode.still_path,
|
||||
});
|
||||
|
||||
const mapSeasonDetails = (season: TmdbTvSeasonDetails): Season => ({
|
||||
const mapSeasonResult = (season: TmdbTvSeasonResult): Season => ({
|
||||
airDate: season.air_date,
|
||||
episodeCount: season.episode_count,
|
||||
id: season.id,
|
||||
@@ -105,6 +111,20 @@ const mapSeasonDetails = (season: TmdbTvSeasonDetails): Season => ({
|
||||
posterPath: season.poster_path,
|
||||
});
|
||||
|
||||
export const mapSeasonWithEpisodes = (
|
||||
season: TmdbSeasonWithEpisodes
|
||||
): SeasonWithEpisodes => ({
|
||||
airDate: season.air_date,
|
||||
episodeCount: season.episode_count,
|
||||
episodes: season.episodes.map(mapEpisodeResult),
|
||||
externalIds: mapExternalIds(season.external_ids),
|
||||
id: season.id,
|
||||
name: season.name,
|
||||
overview: season.overview,
|
||||
seasonNumber: season.season_number,
|
||||
posterPath: season.poster_path,
|
||||
});
|
||||
|
||||
export const mapTvDetails = (
|
||||
show: TmdbTvDetails,
|
||||
media?: Media
|
||||
@@ -141,17 +161,17 @@ export const mapTvDetails = (
|
||||
originCountry: company.origin_country,
|
||||
logoPath: company.logo_path,
|
||||
})),
|
||||
seasons: show.seasons.map(mapSeasonDetails),
|
||||
seasons: show.seasons.map(mapSeasonResult),
|
||||
status: show.status,
|
||||
type: show.type,
|
||||
voteAverage: show.vote_average,
|
||||
voteCount: show.vote_count,
|
||||
backdropPath: show.backdrop_path,
|
||||
lastEpisodeToAir: show.last_episode_to_air
|
||||
? mapEpisodeDetails(show.last_episode_to_air)
|
||||
? mapEpisodeResult(show.last_episode_to_air)
|
||||
: undefined,
|
||||
nextEpisodeToAir: show.next_episode_to_air
|
||||
? mapEpisodeDetails(show.next_episode_to_air)
|
||||
? mapEpisodeResult(show.next_episode_to_air)
|
||||
: undefined,
|
||||
posterPath: show.poster_path,
|
||||
credits: {
|
||||
|
Reference in New Issue
Block a user