diff --git a/src/Lidarr.Api.V1/Indexers/ReleaseController.cs b/src/Lidarr.Api.V1/Indexers/ReleaseController.cs index 49e81e8677..fd0ca68317 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 class ReleaseController : ReleaseControllerBase 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 9570f3ec89..37644e0e50 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 9e0cd1b309..494a9976d1 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 fcb7f8cebc..3f2bcb016f 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 188255bd24..8df7cd2feb 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 10dd4b27f6..0be9b5fcf6 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 class ImportDecisionMaker : IMakeImportDecision IAugmentingService augmentingService, IIdentificationService identificationService, IRootFolderService rootFolderService, - IProfileService qualityProfileService, + IQualityProfileService qualityProfileService, Logger logger) { _trackSpecifications = trackSpecifications; diff --git a/src/NzbDrone.Core/Music/Services/AlbumCutoffService.cs b/src/NzbDrone.Core/Music/Services/AlbumCutoffService.cs index a83252fcbc..fc6b325bd0 100644 --- a/src/NzbDrone.Core/Music/Services/AlbumCutoffService.cs +++ b/src/NzbDrone.Core/Music/Services/AlbumCutoffService.cs @@ -14,9 +14,9 @@ public interface IAlbumCutoffService public class AlbumCutoffService : IAlbumCutoffService { private readonly IAlbumRepository _albumRepository; - private readonly IProfileService _profileService; + private readonly IQualityProfileService _profileService; - public AlbumCutoffService(IAlbumRepository albumRepository, IProfileService profileService) + public AlbumCutoffService(IAlbumRepository albumRepository, IQualityProfileService profileService) { _albumRepository = albumRepository; _profileService = profileService; diff --git a/src/NzbDrone.Core/Profiles/Qualities/QualityProfileService.cs b/src/NzbDrone.Core/Profiles/Qualities/QualityProfileService.cs index bcceaccf4c..1520ed7008 100644 --- a/src/NzbDrone.Core/Profiles/Qualities/QualityProfileService.cs +++ b/src/NzbDrone.Core/Profiles/Qualities/QualityProfileService.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Profiles.Qualities { - public interface IProfileService + public interface IQualityProfileService { QualityProfile Add(QualityProfile profile); void Update(QualityProfile profile); @@ -21,7 +21,7 @@ public interface IProfileService QualityProfile GetDefaultProfile(string name, Quality cutoff = null, params Quality[] allowed); } - public class QualityProfileService : IProfileService, IHandle + 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 657260dd4e..ba22b31749 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;