mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 13:43:25 +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);
|
||||
}
|
||||
|
||||
if (!movie.release_date) {
|
||||
throw new Error(`${movie.title} has no release_date. Assuming unreleased`);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'movie',
|
||||
title: movie.title,
|
||||
@@ -99,6 +103,10 @@ async function getShowMediaDetails(id: string, seasonNumber: string, episodeNumb
|
||||
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}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
@@ -126,7 +134,7 @@ async function getShowMediaDetails(id: string, seasonNumber: string, episodeNumb
|
||||
return {
|
||||
type: 'show',
|
||||
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,
|
||||
episode: {
|
||||
number: episode.episode_number,
|
||||
|
Reference in New Issue
Block a user