From f33f004aa97f277d6d0db23d58bfd8740d36ed36 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 31 Jan 2021 00:39:44 -0500 Subject: [PATCH] Fixed: Sorting interactive search by quality for unknown movie results Fixes #5026 --- src/Radarr.Api.V3/Indexers/ReleaseModule.cs | 3 +++ src/Radarr.Api.V3/Indexers/ReleaseModuleBase.cs | 14 +++++++++----- src/Radarr.Api.V3/Indexers/ReleasePushModule.cs | 3 +++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Radarr.Api.V3/Indexers/ReleaseModule.cs b/src/Radarr.Api.V3/Indexers/ReleaseModule.cs index 7b2610706..65be669ed 100644 --- a/src/Radarr.Api.V3/Indexers/ReleaseModule.cs +++ b/src/Radarr.Api.V3/Indexers/ReleaseModule.cs @@ -11,6 +11,7 @@ using NzbDrone.Core.Indexers; using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Movies; using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Profiles; using NzbDrone.Core.Validation; using HttpStatusCode = System.Net.HttpStatusCode; @@ -35,7 +36,9 @@ namespace Radarr.Api.V3.Indexers IDownloadService downloadService, IMovieService movieService, ICacheManager cacheManager, + IProfileService qualityProfileService, Logger logger) + : base(qualityProfileService) { _rssFetcherAndParser = rssFetcherAndParser; _nzbSearchService = nzbSearchService; diff --git a/src/Radarr.Api.V3/Indexers/ReleaseModuleBase.cs b/src/Radarr.Api.V3/Indexers/ReleaseModuleBase.cs index 65ecadc5c..224d15f22 100644 --- a/src/Radarr.Api.V3/Indexers/ReleaseModuleBase.cs +++ b/src/Radarr.Api.V3/Indexers/ReleaseModuleBase.cs @@ -1,11 +1,19 @@ using System.Collections.Generic; using NzbDrone.Core.DecisionEngine; +using NzbDrone.Core.Profiles; using Radarr.Http; namespace Radarr.Api.V3.Indexers { public abstract class ReleaseModuleBase : RadarrRestModule { + private readonly Profile _qualityProfie; + + public ReleaseModuleBase(IProfileService qualityProfileService) + { + _qualityProfie = qualityProfileService.GetDefaultProfile(string.Empty); + } + protected virtual List MapDecisions(IEnumerable decisions) { var result = new List(); @@ -26,11 +34,7 @@ namespace Radarr.Api.V3.Indexers release.ReleaseWeight = initialWeight; - if (decision.RemoteMovie.Movie != null) - { - release.QualityWeight = decision.RemoteMovie.Movie - .Profile.GetIndex(release.Quality.Quality).Index * 100; - } + release.QualityWeight = _qualityProfie.GetIndex(release.Quality.Quality).Index * 100; release.QualityWeight += release.Quality.Revision.Real * 10; release.QualityWeight += release.Quality.Revision.Version; diff --git a/src/Radarr.Api.V3/Indexers/ReleasePushModule.cs b/src/Radarr.Api.V3/Indexers/ReleasePushModule.cs index 63148d1c3..aef10580c 100644 --- a/src/Radarr.Api.V3/Indexers/ReleasePushModule.cs +++ b/src/Radarr.Api.V3/Indexers/ReleasePushModule.cs @@ -9,6 +9,7 @@ using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Profiles; namespace Radarr.Api.V3.Indexers { @@ -22,7 +23,9 @@ namespace Radarr.Api.V3.Indexers public ReleasePushModule(IMakeDownloadDecision downloadDecisionMaker, IProcessDownloadDecisions downloadDecisionProcessor, IIndexerFactory indexerFactory, + IProfileService qualityProfileService, Logger logger) + : base(qualityProfileService) { _downloadDecisionMaker = downloadDecisionMaker; _downloadDecisionProcessor = downloadDecisionProcessor;