mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Some better null object handling #731
This commit is contained in:
parent
4e60b4afda
commit
2a56bd2648
3 changed files with 18 additions and 20 deletions
|
@ -47,25 +47,18 @@ namespace PlexRequests.Api
|
|||
public async Task<List<SearchMovie>> SearchMovie(string searchTerm)
|
||||
{
|
||||
var results = await Client.SearchMovie(searchTerm);
|
||||
return results.Results;
|
||||
}
|
||||
|
||||
[Obsolete("Should use TvMaze for TV")]
|
||||
public async Task<List<SearchTv>> SearchTv(string searchTerm)
|
||||
{
|
||||
var results = await Client.SearchTvShow(searchTerm);
|
||||
return results.Results;
|
||||
return results?.Results ?? new List<SearchMovie>();
|
||||
}
|
||||
|
||||
public async Task<List<MovieResult>> GetCurrentPlayingMovies()
|
||||
{
|
||||
var movies = await Client.GetMovieList(MovieListType.NowPlaying);
|
||||
return movies.Results;
|
||||
return movies?.Results ?? new List<MovieResult>();
|
||||
}
|
||||
public async Task<List<MovieResult>> GetUpcomingMovies()
|
||||
{
|
||||
var movies = await Client.GetMovieList(MovieListType.Upcoming);
|
||||
return movies.Results;
|
||||
return movies?.Results ?? new List<MovieResult>();
|
||||
}
|
||||
|
||||
public async Task<Movie> GetMovieInformation(int tmdbId)
|
||||
|
@ -77,14 +70,7 @@ namespace PlexRequests.Api
|
|||
public async Task<Movie> GetMovieInformation(string imdbId)
|
||||
{
|
||||
var movies = await Client.GetMovie(imdbId);
|
||||
return movies;
|
||||
}
|
||||
|
||||
[Obsolete("Should use TvMaze for TV")]
|
||||
public async Task<TvShow> GetTvShowInformation(int tmdbId)
|
||||
{
|
||||
var show = await Client.GetTvShow(tmdbId);
|
||||
return show;
|
||||
return movies ?? new Movie();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,7 +147,10 @@ namespace PlexRequests.Services.Jobs
|
|||
|
||||
var imdbId = PlexHelper.GetProviderIdFromPlexGuid(plexGUID);
|
||||
var info = _movieApi.GetMovieInformation(imdbId).Result;
|
||||
|
||||
if (info == null)
|
||||
{
|
||||
throw new Exception($"Movie with Imdb id {imdbId} returned null from the MovieApi");
|
||||
}
|
||||
AddImageInsideTable(sb, $"https://image.tmdb.org/t/p/w500{info.BackdropPath}");
|
||||
|
||||
sb.Append("<tr>");
|
||||
|
|
|
@ -257,7 +257,7 @@ namespace PlexRequests.UI.Modules
|
|||
var movieInfoTask = await MovieApi.GetMovieInformation(movie.Id).ConfigureAwait(false);
|
||||
// TODO needs to be careful about this, it's adding extra time to search...
|
||||
// https://www.themoviedb.org/talk/5807f4cdc3a36812160041f2
|
||||
imdbId = movieInfoTask.ImdbId;
|
||||
imdbId = movieInfoTask?.ImdbId;
|
||||
counter++;
|
||||
}
|
||||
|
||||
|
@ -492,6 +492,15 @@ namespace PlexRequests.UI.Modules
|
|||
Analytics.TrackEventAsync(Category.Search, Action.Request, "Movie", Username,
|
||||
CookieHelper.GetAnalyticClientId(Cookies));
|
||||
var movieInfo = await MovieApi.GetMovieInformation(movieId);
|
||||
if (movieInfo == null)
|
||||
{
|
||||
return
|
||||
Response.AsJson(new JsonResponseModel
|
||||
{
|
||||
Result = false,
|
||||
Message = "There was an issue adding this movie!"
|
||||
});
|
||||
}
|
||||
var fullMovieName =
|
||||
$"{movieInfo.Title}{(movieInfo.ReleaseDate.HasValue ? $" ({movieInfo.ReleaseDate.Value.Year})" : string.Empty)}";
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue