From 727347331f6e494195d011f50a22fe7aec378acd Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 5 Apr 2020 03:30:03 -0400 Subject: [PATCH] Fixed: More robust Certification Logic --- .../MetadataSource/SkyHook/SkyHookProxy.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 0012904d6..0a2cfd021 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -206,15 +206,19 @@ namespace NzbDrone.Core.MetadataSource.SkyHook movie.PhysicalReleaseNote = releaseDate.note; } } - - // Set Certification from Theatrical Release - if (releaseDate.type == 3 && releaseDates.iso_3166_1 == _configService.CertificationCountry.ToString()) - { - movie.Certification = releaseDate.certification; - } } } + var countryReleases = resource.release_dates.results.FirstOrDefault(m => m.iso_3166_1 == _configService.CertificationCountry.ToString()); + + // Set Certification from Theatrical Release(Type 3), if not fall back to Limited Threatrical(Type 2) and then Premiere(Type 1) + if (countryReleases != null && countryReleases.release_dates.Any()) + { + var certRelease = countryReleases.release_dates.OrderByDescending(c => c.type).Where(d => d.type <= 3).FirstOrDefault(c => c.certification.IsNotNullOrWhiteSpace()); + + movie.Certification = certRelease?.certification; + } + movie.Ratings = new Ratings(); movie.Ratings.Votes = resource.vote_count; movie.Ratings.Value = (decimal)resource.vote_average;