diff --git a/src/Lidarr.Api.V1/Indexers/ReleaseController.cs b/src/Lidarr.Api.V1/Indexers/ReleaseController.cs index 49e81e867..fd0ca6831 100644 --- a/src/Lidarr.Api.V1/Indexers/ReleaseController.cs +++ b/src/Lidarr.Api.V1/Indexers/ReleaseController.cs @@ -14,6 +14,7 @@ using NzbDrone.Core.Music; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Profiles.Qualities; using NzbDrone.Core.Validation; using HttpStatusCode = System.Net.HttpStatusCode; @@ -43,7 +44,9 @@ public ReleaseController(IAlbumService albumService, IParsingService parsingService, IDownloadService downloadService, ICacheManager cacheManager, + IQualityProfileService qualityProfileService, Logger logger) + : base(qualityProfileService) { _albumService = albumService; _artistService = artistService; diff --git a/src/Lidarr.Api.V1/Indexers/ReleaseControllerBase.cs b/src/Lidarr.Api.V1/Indexers/ReleaseControllerBase.cs index 9570f3ec8..37644e0e5 100644 --- a/src/Lidarr.Api.V1/Indexers/ReleaseControllerBase.cs +++ b/src/Lidarr.Api.V1/Indexers/ReleaseControllerBase.cs @@ -2,11 +2,19 @@ using System.Collections.Generic; using Lidarr.Http.REST; using NzbDrone.Core.DecisionEngine; +using NzbDrone.Core.Profiles.Qualities; namespace Lidarr.Api.V1.Indexers { public abstract class ReleaseControllerBase : RestController { + private readonly QualityProfile _qualityProfile; + + public ReleaseControllerBase(IQualityProfileService qualityProfileService) + { + _qualityProfile = qualityProfileService.GetDefaultProfile(string.Empty); + } + public override ReleaseResource GetResourceById(int id) { throw new NotImplementedException(); @@ -32,12 +40,7 @@ protected virtual ReleaseResource MapDecision(DownloadDecision decision, int ini release.ReleaseWeight = initialWeight; - if (decision.RemoteAlbum.Artist != null) - { - release.QualityWeight = decision.RemoteAlbum - .Artist - .QualityProfile.Value.GetIndex(release.Quality.Quality).Index * 100; - } + release.QualityWeight = _qualityProfile.GetIndex(release.Quality.Quality).Index * 100; release.QualityWeight += release.Quality.Revision.Real * 10; release.QualityWeight += release.Quality.Revision.Version; diff --git a/src/Lidarr.Api.V1/Indexers/ReleasePushController.cs b/src/Lidarr.Api.V1/Indexers/ReleasePushController.cs index 9e0cd1b30..494a9976d 100644 --- a/src/Lidarr.Api.V1/Indexers/ReleasePushController.cs +++ b/src/Lidarr.Api.V1/Indexers/ReleasePushController.cs @@ -11,6 +11,7 @@ using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Profiles.Qualities; namespace Lidarr.Api.V1.Indexers { @@ -25,7 +26,9 @@ public class ReleasePushController : ReleaseControllerBase public ReleasePushController(IMakeDownloadDecision downloadDecisionMaker, IProcessDownloadDecisions downloadDecisionProcessor, IIndexerFactory indexerFactory, + IQualityProfileService qualityProfileService, Logger logger) + : base(qualityProfileService) { _downloadDecisionMaker = downloadDecisionMaker; _downloadDecisionProcessor = downloadDecisionProcessor; diff --git a/src/Lidarr.Api.V1/Profiles/Quality/QualityProfileController.cs b/src/Lidarr.Api.V1/Profiles/Quality/QualityProfileController.cs index fcb7f8ceb..3f2bcb016 100644 --- a/src/Lidarr.Api.V1/Profiles/Quality/QualityProfileController.cs +++ b/src/Lidarr.Api.V1/Profiles/Quality/QualityProfileController.cs @@ -11,11 +11,11 @@ namespace Lidarr.Api.V1.Profiles.Quality [V1ApiController] public class QualityProfileController : RestController { - private readonly IProfileService _profileService; + private readonly IQualityProfileService _qualityProfileService; - public QualityProfileController(IProfileService profileService) + public QualityProfileController(IQualityProfileService qualityProfileService) { - _profileService = profileService; + _qualityProfileService = qualityProfileService; SharedValidator.RuleFor(c => c.Name).NotEmpty(); SharedValidator.RuleFor(c => c.Cutoff).ValidCutoff(); SharedValidator.RuleFor(c => c.Items).ValidItems(); @@ -25,14 +25,14 @@ public QualityProfileController(IProfileService profileService) public ActionResult Create(QualityProfileResource resource) { var model = resource.ToModel(); - model = _profileService.Add(model); + model = _qualityProfileService.Add(model); return Created(model.Id); } [RestDeleteById] public void DeleteProfile(int id) { - _profileService.Delete(id); + _qualityProfileService.Delete(id); } [RestPutById] @@ -40,20 +40,20 @@ public ActionResult Update(QualityProfileResource resour { var model = resource.ToModel(); - _profileService.Update(model); + _qualityProfileService.Update(model); return Accepted(model.Id); } public override QualityProfileResource GetResourceById(int id) { - return _profileService.Get(id).ToResource(); + return _qualityProfileService.Get(id).ToResource(); } [HttpGet] public List GetAll() { - return _profileService.All().ToResource(); + return _qualityProfileService.All().ToResource(); } } } diff --git a/src/Lidarr.Api.V1/Profiles/Quality/QualityProfileSchemaController.cs b/src/Lidarr.Api.V1/Profiles/Quality/QualityProfileSchemaController.cs index 188255bd2..8df7cd2fe 100644 --- a/src/Lidarr.Api.V1/Profiles/Quality/QualityProfileSchemaController.cs +++ b/src/Lidarr.Api.V1/Profiles/Quality/QualityProfileSchemaController.cs @@ -7,9 +7,9 @@ namespace Lidarr.Api.V1.Profiles.Quality [V1ApiController("qualityprofile/schema")] public class QualityProfileSchemaController : Controller { - private readonly IProfileService _profileService; + private readonly IQualityProfileService _profileService; - public QualityProfileSchemaController(IProfileService profileService) + public QualityProfileSchemaController(IQualityProfileService profileService) { _profileService = profileService; } diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportDecisionMaker.cs b/src/NzbDrone.Core/MediaFiles/TrackImport/ImportDecisionMaker.cs index 10dd4b27f..0be9b5fcf 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportDecisionMaker.cs +++ b/src/NzbDrone.Core/MediaFiles/TrackImport/ImportDecisionMaker.cs @@ -52,7 +52,7 @@ public class ImportDecisionMaker : IMakeImportDecision private readonly IAugmentingService _augmentingService; private readonly IIdentificationService _identificationService; private readonly IRootFolderService _rootFolderService; - private readonly IProfileService _qualityProfileService; + private readonly IQualityProfileService _qualityProfileService; private readonly Logger _logger; public ImportDecisionMaker(IEnumerable> trackSpecifications, @@ -62,7 +62,7 @@ public ImportDecisionMaker(IEnumerable + public class QualityProfileService : IQualityProfileService, IHandle { private readonly IProfileRepository _profileRepository; private readonly IArtistService _artistService; diff --git a/src/NzbDrone.Core/Validation/QualityProfileExistsValidator.cs b/src/NzbDrone.Core/Validation/QualityProfileExistsValidator.cs index 657260dd4..ba22b3174 100644 --- a/src/NzbDrone.Core/Validation/QualityProfileExistsValidator.cs +++ b/src/NzbDrone.Core/Validation/QualityProfileExistsValidator.cs @@ -5,9 +5,9 @@ namespace NzbDrone.Core.Validation { public class QualityProfileExistsValidator : PropertyValidator { - private readonly IProfileService _profileService; + private readonly IQualityProfileService _profileService; - public QualityProfileExistsValidator(IProfileService profileService) + public QualityProfileExistsValidator(IQualityProfileService profileService) : base("Quality Profile does not exist") { _profileService = profileService;