1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-20 18:02:44 +01:00

Fixed: Remove buggy CF import check

This commit is contained in:
Qstick 2022-10-15 12:01:09 -05:00
parent 76f0c54b3c
commit 9662495fa2

View File

@ -1,5 +1,3 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.CustomFormats;
using NzbDrone.Core.DecisionEngine;
@ -11,19 +9,16 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Specifications
{
public class UpgradeSpecification : IImportDecisionEngineSpecification
{
private readonly ICustomFormatCalculationService _customFormatCalculationService;
private readonly Logger _logger;
public UpgradeSpecification(ICustomFormatCalculationService customFormatCalculationService, Logger logger)
{
_customFormatCalculationService = customFormatCalculationService;
_logger = logger;
}
public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem)
{
var qualityComparer = new QualityModelComparer(localMovie.Movie.Profile);
var preferredWordScore = GetCustomFormatScore(localMovie);
if (localMovie.Movie.MovieFileId > 0)
{
@ -42,47 +37,9 @@ public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem download
_logger.Debug("This file isn't a quality upgrade for movie. Skipping {0}", localMovie.Path);
return Decision.Reject("Not a quality upgrade for existing movie file(s)");
}
movieFile.Movie = localMovie.Movie;
var customFormats = _customFormatCalculationService.ParseCustomFormat(movieFile);
var movieFileCustomFormatScore = localMovie.Movie.Profile.CalculateCustomFormatScore(customFormats);
if (qualityCompare == 0 && preferredWordScore < movieFileCustomFormatScore)
{
_logger.Debug("This file isn't a custom format upgrade for movie. Skipping {0}", localMovie.Path);
return Decision.Reject("Not a custom format upgrade for existing movie file(s)");
}
}
return Decision.Accept();
}
private int GetCustomFormatScore(LocalMovie localMovie)
{
var movie = localMovie.Movie;
var fileFormats = new List<CustomFormat>();
var folderFormats = new List<CustomFormat>();
var clientFormats = new List<CustomFormat>();
if (localMovie.FileMovieInfo != null)
{
fileFormats = _customFormatCalculationService.ParseCustomFormat(localMovie.FileMovieInfo, movie);
}
if (localMovie.FolderMovieInfo != null)
{
folderFormats = _customFormatCalculationService.ParseCustomFormat(localMovie.FolderMovieInfo, movie);
}
if (localMovie.DownloadClientMovieInfo != null)
{
clientFormats = _customFormatCalculationService.ParseCustomFormat(localMovie.DownloadClientMovieInfo, movie);
}
var formats = fileFormats.Union(folderFormats.Union(clientFormats)).ToList();
return movie.Profile.CalculateCustomFormatScore(formats);
}
}
}