mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 17:53:24 +00:00
throw if media has not been released yet
This commit is contained in:
@@ -76,6 +76,10 @@ async function getMovieMediaDetails(id: string): Promise<MovieMedia> {
|
|||||||
throw new Error(movie.status_message);
|
throw new Error(movie.status_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!movie.release_date) {
|
||||||
|
throw new Error(`${movie.title} has no release_date. Assuming unreleased`);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'movie',
|
type: 'movie',
|
||||||
title: movie.title,
|
title: movie.title,
|
||||||
@@ -99,6 +103,10 @@ async function getShowMediaDetails(id: string, seasonNumber: string, episodeNumb
|
|||||||
throw new Error(series.status_message);
|
throw new Error(series.status_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!series.first_air_date) {
|
||||||
|
throw new Error(`${series.name} has no first_air_date. Assuming unaired`);
|
||||||
|
}
|
||||||
|
|
||||||
response = await fetch(`https://api.themoviedb.org/3/tv/${id}/season/${seasonNumber}?api_key=${TMDB_API_KEY}`, {
|
response = await fetch(`https://api.themoviedb.org/3/tv/${id}/season/${seasonNumber}?api_key=${TMDB_API_KEY}`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -126,7 +134,7 @@ async function getShowMediaDetails(id: string, seasonNumber: string, episodeNumb
|
|||||||
return {
|
return {
|
||||||
type: 'show',
|
type: 'show',
|
||||||
title: series.name,
|
title: series.name,
|
||||||
releaseYear: Number(series.first_air_date.split('-')[0]), // * Is this really what should go here?
|
releaseYear: Number(series.first_air_date.split('-')[0]),
|
||||||
tmdbId: id,
|
tmdbId: id,
|
||||||
episode: {
|
episode: {
|
||||||
number: episode.episode_number,
|
number: episode.episode_number,
|
||||||
|
Reference in New Issue
Block a user