You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.5 KiB
49 lines
1.5 KiB
3 years ago
|
using System;
|
||
7 years ago
|
using System.Collections.Generic;
|
||
3 years ago
|
using Lidarr.Http.REST;
|
||
5 years ago
|
using NzbDrone.Core.DecisionEngine;
|
||
7 years ago
|
|
||
7 years ago
|
namespace Lidarr.Api.V1.Indexers
|
||
7 years ago
|
{
|
||
3 years ago
|
public abstract class ReleaseControllerBase : RestController<ReleaseResource>
|
||
7 years ago
|
{
|
||
3 years ago
|
public override ReleaseResource GetResourceById(int id)
|
||
|
{
|
||
|
throw new NotImplementedException();
|
||
|
}
|
||
|
|
||
7 years ago
|
protected virtual List<ReleaseResource> MapDecisions(IEnumerable<DownloadDecision> decisions)
|
||
|
{
|
||
|
var result = new List<ReleaseResource>();
|
||
|
|
||
|
foreach (var downloadDecision in decisions)
|
||
|
{
|
||
|
var release = MapDecision(downloadDecision, result.Count);
|
||
|
|
||
|
result.Add(release);
|
||
|
}
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
protected virtual ReleaseResource MapDecision(DownloadDecision decision, int initialWeight)
|
||
|
{
|
||
|
var release = decision.ToResource();
|
||
|
|
||
|
release.ReleaseWeight = initialWeight;
|
||
|
|
||
|
if (decision.RemoteAlbum.Artist != null)
|
||
|
{
|
||
6 years ago
|
release.QualityWeight = decision.RemoteAlbum
|
||
|
.Artist
|
||
5 years ago
|
.QualityProfile.Value.GetIndex(release.Quality.Quality).Index * 100;
|
||
7 years ago
|
}
|
||
|
|
||
|
release.QualityWeight += release.Quality.Revision.Real * 10;
|
||
|
release.QualityWeight += release.Quality.Revision.Version;
|
||
|
|
||
|
return release;
|
||
|
}
|
||
|
}
|
||
|
}
|