added some error handing around the GetMovie area #517

This commit is contained in:
tidusjar 2016-09-18 17:21:24 +01:00
commit 465b24e6b0

View file

@ -195,9 +195,18 @@ namespace PlexRequests.Services.Jobs
public PlexMovie GetMovie(PlexMovie[] plexMovies, string title, string year, string providerId = null) public PlexMovie GetMovie(PlexMovie[] plexMovies, string title, string year, string providerId = null)
{ {
if (plexMovies.Length == 0)
{
return null;
}
var advanced = !string.IsNullOrEmpty(providerId); var advanced = !string.IsNullOrEmpty(providerId);
foreach (var movie in plexMovies) foreach (var movie in plexMovies)
{ {
if (string.IsNullOrEmpty(movie.Title) || string.IsNullOrEmpty(movie.ReleaseYear))
{
continue;
}
if (advanced) if (advanced)
{ {
if (!string.IsNullOrEmpty(movie.ProviderId) && if (!string.IsNullOrEmpty(movie.ProviderId) &&