Fixed: Sorting interactive search by quality for unknown artist results

Fixes #1587
pull/2833/head
Qstick 2 years ago
parent 26b5db3019
commit 423b489cf8

@ -14,6 +14,7 @@ using NzbDrone.Core.IndexerSearch;
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 @@ namespace Lidarr.Api.V1.Indexers
IParsingService parsingService,
IDownloadService downloadService,
ICacheManager cacheManager,
IQualityProfileService qualityProfileService,
Logger logger)
: base(qualityProfileService)
{
_albumService = albumService;
_artistService = artistService;

@ -2,11 +2,19 @@ using System;
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<ReleaseResource>
{
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 @@ namespace Lidarr.Api.V1.Indexers
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;

@ -11,6 +11,7 @@ using NzbDrone.Core.DecisionEngine;
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 @@ namespace Lidarr.Api.V1.Indexers
public ReleasePushController(IMakeDownloadDecision downloadDecisionMaker,
IProcessDownloadDecisions downloadDecisionProcessor,
IIndexerFactory indexerFactory,
IQualityProfileService qualityProfileService,
Logger logger)
: base(qualityProfileService)
{
_downloadDecisionMaker = downloadDecisionMaker;
_downloadDecisionProcessor = downloadDecisionProcessor;

@ -11,11 +11,11 @@ namespace Lidarr.Api.V1.Profiles.Quality
[V1ApiController]
public class QualityProfileController : RestController<QualityProfileResource>
{
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 @@ namespace Lidarr.Api.V1.Profiles.Quality
public ActionResult<QualityProfileResource> 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 @@ namespace Lidarr.Api.V1.Profiles.Quality
{
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<QualityProfileResource> GetAll()
{
return _profileService.All().ToResource();
return _qualityProfileService.All().ToResource();
}
}
}

@ -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;
}

@ -52,7 +52,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
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<IImportDecisionEngineSpecification<LocalTrack>> trackSpecifications,
@ -62,7 +62,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
IAugmentingService augmentingService,
IIdentificationService identificationService,
IRootFolderService rootFolderService,
IProfileService qualityProfileService,
IQualityProfileService qualityProfileService,
Logger logger)
{
_trackSpecifications = trackSpecifications;

@ -14,9 +14,9 @@ namespace NzbDrone.Core.Music
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;

@ -10,7 +10,7 @@ using NzbDrone.Core.RootFolders;
namespace NzbDrone.Core.Profiles.Qualities
{
public interface IProfileService
public interface IQualityProfileService
{
QualityProfile Add(QualityProfile profile);
void Update(QualityProfile profile);
@ -21,7 +21,7 @@ namespace NzbDrone.Core.Profiles.Qualities
QualityProfile GetDefaultProfile(string name, Quality cutoff = null, params Quality[] allowed);
}
public class QualityProfileService : IProfileService, IHandle<ApplicationStartedEvent>
public class QualityProfileService : IQualityProfileService, IHandle<ApplicationStartedEvent>
{
private readonly IProfileRepository _profileRepository;
private readonly IArtistService _artistService;

@ -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;

Loading…
Cancel
Save