From 0a414f37dccffd81d3d56cd1cd141e17baa0718e Mon Sep 17 00:00:00 2001 From: Qstick Date: Thu, 23 Jul 2020 20:06:42 -0400 Subject: [PATCH] Use Radarr API change feed for changed movies (#4629) * Use Radarr API change feed for changed movies * Adjust StartTime for cache overlap --- .../MetadataSource/SkyHook/SkyHookProxy.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 05f883771..0c65abbc7 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -16,7 +16,6 @@ using NzbDrone.Core.Movies.AlternativeTitles; using NzbDrone.Core.Movies.Credits; using NzbDrone.Core.Movies.Translations; -using NzbDrone.Core.NetImport.TMDb; using NzbDrone.Core.Parser; namespace NzbDrone.Core.MetadataSource.SkyHook @@ -51,22 +50,21 @@ public SkyHookProxy(IHttpClient httpClient, public HashSet GetChangedMovies(DateTime startTime) { - var startDate = startTime.ToString("o"); + // Round down to the hour to ensure we cover gap and don't kill cache every call + var cacheAdjustedStart = startTime.AddMinutes(-15); + var startDate = cacheAdjustedStart.Date.AddHours(cacheAdjustedStart.Hour).ToString("s"); - var request = _movieBuilder.Create() - .SetSegment("api", "3") - .SetSegment("route", "movie") - .SetSegment("id", "") - .SetSegment("secondaryRoute", "changes") - .AddQueryParam("start_date", startDate) + var request = _radarrMetadata.Create() + .SetSegment("route", "movie/changed") + .AddQueryParam("since", startDate) .Build(); request.AllowAutoRedirect = true; request.SuppressHttpError = true; - var response = _httpClient.Get(request); + var response = _httpClient.Get>(request); - return new HashSet(response.Resource.Results.Select(c => c.Id)); + return new HashSet(response.Resource); } public Tuple> GetMovieInfo(int tmdbId)