From 9b3640407180871439774c52835d7f2d4c578b77 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 14 Oct 2023 20:10:10 +0300 Subject: [PATCH] Fixed: Don't die in Collections when a collection doesn't have movies --- .../Collections/CollectionController.cs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Radarr.Api.V3/Collections/CollectionController.cs b/src/Radarr.Api.V3/Collections/CollectionController.cs index f2c888e67..be7e4767b 100644 --- a/src/Radarr.Api.V3/Collections/CollectionController.cs +++ b/src/Radarr.Api.V3/Collections/CollectionController.cs @@ -159,19 +159,22 @@ namespace Radarr.Api.V3.Collections allCollectionMovies.TryGetValue(collection.TmdbId, out var collectionMovies); - foreach (var movie in collectionMovies) + if (collectionMovies != null) { - var translation = GetTranslationFromDict(tdict, movie, configLanguage); + foreach (var movie in collectionMovies) + { + var translation = GetTranslationFromDict(tdict, movie, configLanguage); - var movieResource = movie.ToResource(translation); - movieResource.Folder = _fileNameBuilder.GetMovieFolder(new Movie { MovieMetadata = movie }, namingConfig); + var movieResource = movie.ToResource(translation); + movieResource.Folder = _fileNameBuilder.GetMovieFolder(new Movie { MovieMetadata = movie }, namingConfig); - if (!existingMoviesTmdbIds.Contains(movie.TmdbId)) - { - resource.MissingMovies++; - } + if (!existingMoviesTmdbIds.Contains(movie.TmdbId)) + { + resource.MissingMovies++; + } - resource.Movies.Add(movieResource); + resource.Movies.Add(movieResource); + } } yield return resource;