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.
65 lines
2.6 KiB
65 lines
2.6 KiB
using NLog;
|
|
using NzbDrone.Core.Download;
|
|
using NzbDrone.Core.Download.History;
|
|
using NzbDrone.Core.Parser;
|
|
using NzbDrone.Core.Parser.Model;
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
namespace NzbDrone.Core.MediaFiles.MovieImport.Aggregation.Aggregators.Augmenters.Quality
|
|
{
|
|
public class AugmentQualityFromReleaseName : IAugmentQuality
|
|
{
|
|
public int Order => 5;
|
|
public string Name => "ReleaseName";
|
|
|
|
private readonly IDownloadHistoryService _downloadHistoryService;
|
|
private readonly ILogger _logger;
|
|
|
|
public AugmentQualityFromReleaseName(IDownloadHistoryService downloadHistoryService, Logger logger)
|
|
{
|
|
_downloadHistoryService = downloadHistoryService;
|
|
_logger = logger;
|
|
}
|
|
|
|
public AugmentQualityResult AugmentQuality(LocalMovie localMovie, DownloadClientItem downloadClientItem)
|
|
{
|
|
// Don't try to augment if we can't lookup the grabbed history by downloadId
|
|
if (downloadClientItem == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
_logger.Warn("Attempt to augment quality for Download ID '{0}'", downloadClientItem.DownloadId);
|
|
|
|
var history = _downloadHistoryService.GetLatestGrab(downloadClientItem.DownloadId);
|
|
if (history == null)
|
|
{
|
|
_logger.Warn("No grabbed history found for '{0}'", downloadClientItem.DownloadId);
|
|
return null;
|
|
}
|
|
|
|
_logger.Warn("Attempt to augment quality for release title '{0}'", history.SourceTitle);
|
|
|
|
var historyQuality = QualityParser.ParseQuality(history.SourceTitle);
|
|
|
|
var sourceConfidence = historyQuality.SourceDetectionSource == QualityDetectionSource.Name
|
|
? Confidence.Tag
|
|
: Confidence.Fallback;
|
|
|
|
var resolutionConfidence = historyQuality.ResolutionDetectionSource == QualityDetectionSource.Name
|
|
? Confidence.Tag
|
|
: Confidence.Fallback;
|
|
|
|
var modifierConfidence = historyQuality.ModifierDetectionSource == QualityDetectionSource.Name
|
|
? Confidence.Tag
|
|
: Confidence.Fallback;
|
|
|
|
var revisionConfidence = historyQuality.RevisionDetectionSource == QualityDetectionSource.Name
|
|
? Confidence.Tag
|
|
: Confidence.Fallback;
|
|
|
|
return new AugmentQualityResult(historyQuality.Quality.Source, sourceConfidence, historyQuality.Quality.Resolution, resolutionConfidence, historyQuality.Quality.Modifier, modifierConfidence, historyQuality.Revision, revisionConfidence);
|
|
}
|
|
}
|
|
}
|