mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
parent
3fdc7c8346
commit
89270ad7a1
@ -74,7 +74,7 @@ public void Setup()
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<ICustomFormatCalculationService>()
|
||||
.Setup(x => x.ParseCustomFormat(It.IsAny<ParsedEpisodeInfo>()))
|
||||
.Setup(x => x.ParseCustomFormat(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<Series>()))
|
||||
.Returns(new List<CustomFormat>());
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ private void GivenEmptyQueue()
|
||||
private void GivenQueueFormats(List<CustomFormat> formats)
|
||||
{
|
||||
Mocker.GetMock<ICustomFormatCalculationService>()
|
||||
.Setup(x => x.ParseCustomFormat(It.IsAny<ParsedEpisodeInfo>()))
|
||||
.Setup(x => x.ParseCustomFormat(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<Series>()))
|
||||
.Returns(formats);
|
||||
}
|
||||
|
||||
|
@ -272,7 +272,7 @@ public void should_return_true_if_it_is_a_preferred_word_downgrade_and_language_
|
||||
.Returns(new List<CustomFormat>());
|
||||
|
||||
Mocker.GetMock<ICustomFormatCalculationService>()
|
||||
.Setup(s => s.ParseCustomFormat(It.IsAny<ParsedEpisodeInfo>()))
|
||||
.Setup(s => s.ParseCustomFormat(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<Series>()))
|
||||
.Returns(new List<CustomFormat>());
|
||||
|
||||
_localEpisode.Quality = new QualityModel(Quality.Bluray2160p);
|
||||
@ -306,7 +306,7 @@ public void should_return_true_if_it_is_a_preferred_word_downgrade_but_a_languag
|
||||
.Returns(new List<CustomFormat>());
|
||||
|
||||
Mocker.GetMock<ICustomFormatCalculationService>()
|
||||
.Setup(s => s.ParseCustomFormat(It.IsAny<ParsedEpisodeInfo>()))
|
||||
.Setup(s => s.ParseCustomFormat(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<Series>()))
|
||||
.Returns(new List<CustomFormat>());
|
||||
|
||||
_localEpisode.Quality = new QualityModel(Quality.Bluray1080p);
|
||||
@ -384,7 +384,7 @@ public void should_return_true_if_it_is_a_preferred_word_upgrade()
|
||||
.Returns(new List<CustomFormat>());
|
||||
|
||||
Mocker.GetMock<ICustomFormatCalculationService>()
|
||||
.Setup(s => s.ParseCustomFormat(It.IsAny<ParsedEpisodeInfo>()))
|
||||
.Setup(s => s.ParseCustomFormat(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<Series>()))
|
||||
.Returns(new List<CustomFormat>());
|
||||
|
||||
_localEpisode.Quality = new QualityModel(Quality.Bluray1080p);
|
||||
@ -417,7 +417,7 @@ public void should_return_true_if_it_has_an_equal_preferred_word_score()
|
||||
.Returns(new List<CustomFormat>());
|
||||
|
||||
Mocker.GetMock<ICustomFormatCalculationService>()
|
||||
.Setup(s => s.ParseCustomFormat(It.IsAny<ParsedEpisodeInfo>()))
|
||||
.Setup(s => s.ParseCustomFormat(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<Series>()))
|
||||
.Returns(new List<CustomFormat>());
|
||||
|
||||
_localEpisode.Quality = new QualityModel(Quality.Bluray1080p);
|
||||
|
@ -14,8 +14,8 @@ namespace NzbDrone.Core.CustomFormats
|
||||
{
|
||||
public interface ICustomFormatCalculationService
|
||||
{
|
||||
List<CustomFormat> ParseCustomFormat(ParsedEpisodeInfo movieInfo);
|
||||
List<CustomFormat> ParseCustomFormat(EpisodeFile movieFile);
|
||||
List<CustomFormat> ParseCustomFormat(ParsedEpisodeInfo episodeInfo, Series series);
|
||||
List<CustomFormat> ParseCustomFormat(EpisodeFile episodeFile);
|
||||
List<CustomFormat> ParseCustomFormat(Blocklist blocklist);
|
||||
List<CustomFormat> ParseCustomFormat(EpisodeHistory history);
|
||||
}
|
||||
@ -92,24 +92,25 @@ public static List<CustomFormat> ParseCustomFormat(EpisodeFile episodeFile, List
|
||||
return ParseCustomFormat(info, allCustomFormats);
|
||||
}
|
||||
|
||||
public List<CustomFormat> ParseCustomFormat(ParsedEpisodeInfo movieInfo)
|
||||
public List<CustomFormat> ParseCustomFormat(ParsedEpisodeInfo episodeInfo, Series series)
|
||||
{
|
||||
return ParseCustomFormat(movieInfo, _formatService.All());
|
||||
episodeInfo.ExtraInfo["OriginalLanguage"] = series.OriginalLanguage;
|
||||
return ParseCustomFormat(episodeInfo, _formatService.All());
|
||||
}
|
||||
|
||||
public List<CustomFormat> ParseCustomFormat(EpisodeFile wpisodeFile)
|
||||
public List<CustomFormat> ParseCustomFormat(EpisodeFile episodeFile)
|
||||
{
|
||||
return ParseCustomFormat(wpisodeFile, _formatService.All());
|
||||
return ParseCustomFormat(episodeFile, _formatService.All());
|
||||
}
|
||||
|
||||
public List<CustomFormat> ParseCustomFormat(Blocklist blocklist)
|
||||
{
|
||||
var movie = _seriesService.GetSeries(blocklist.SeriesId);
|
||||
var series = _seriesService.GetSeries(blocklist.SeriesId);
|
||||
var parsed = Parser.Parser.ParseTitle(blocklist.SourceTitle);
|
||||
|
||||
var info = new ParsedEpisodeInfo
|
||||
{
|
||||
SeriesTitle = movie.Title,
|
||||
SeriesTitle = series.Title,
|
||||
ReleaseTitle = parsed?.ReleaseTitle ?? blocklist.SourceTitle,
|
||||
Quality = blocklist.Quality,
|
||||
Languages = blocklist.Languages,
|
||||
@ -120,19 +121,19 @@ public List<CustomFormat> ParseCustomFormat(Blocklist blocklist)
|
||||
}
|
||||
};
|
||||
|
||||
return ParseCustomFormat(info);
|
||||
return ParseCustomFormat(info, series);
|
||||
}
|
||||
|
||||
public List<CustomFormat> ParseCustomFormat(EpisodeHistory history)
|
||||
{
|
||||
var movie = _seriesService.GetSeries(history.SeriesId);
|
||||
var series = _seriesService.GetSeries(history.SeriesId);
|
||||
var parsed = Parser.Parser.ParseTitle(history.SourceTitle);
|
||||
|
||||
long.TryParse(history.Data.GetValueOrDefault("size"), out var size);
|
||||
|
||||
var info = new ParsedEpisodeInfo
|
||||
{
|
||||
SeriesTitle = movie.Title,
|
||||
SeriesTitle = series.Title,
|
||||
ReleaseTitle = parsed?.ReleaseTitle ?? history.SourceTitle,
|
||||
Quality = history.Quality,
|
||||
Languages = history.Languages,
|
||||
@ -143,7 +144,7 @@ public List<CustomFormat> ParseCustomFormat(EpisodeHistory history)
|
||||
}
|
||||
};
|
||||
|
||||
return ParseCustomFormat(info);
|
||||
return ParseCustomFormat(info, series);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ private IEnumerable<DownloadDecision> GetDecisions(List<ReleaseInfo> reports, Se
|
||||
var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, report.TvdbId, report.TvRageId, searchCriteria);
|
||||
remoteEpisode.Release = report;
|
||||
|
||||
remoteEpisode.CustomFormats = _formatCalculator.ParseCustomFormat(parsedEpisodeInfo);
|
||||
remoteEpisode.CustomFormats = _formatCalculator.ParseCustomFormat(parsedEpisodeInfo, remoteEpisode.Series);
|
||||
remoteEpisode.CustomFormatScore = remoteEpisode?.Series?.QualityProfile?.Value.CalculateCustomFormatScore(remoteEpisode.CustomFormats) ?? 0;
|
||||
|
||||
if (remoteEpisode.Series == null)
|
||||
|
@ -52,7 +52,7 @@ public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCr
|
||||
continue;
|
||||
}
|
||||
|
||||
var queuedItemCustomFormats = _formatService.ParseCustomFormat(remoteEpisode.ParsedEpisodeInfo);
|
||||
var queuedItemCustomFormats = _formatService.ParseCustomFormat(remoteEpisode.ParsedEpisodeInfo, subject.Series);
|
||||
|
||||
_logger.Debug("Checking if existing release in queue meets cutoff. Queued: {0}", remoteEpisode.ParsedEpisodeInfo.Quality);
|
||||
|
||||
|
@ -147,7 +147,7 @@ public TrackedDownload TrackDownload(DownloadClientDefinition downloadClient, Do
|
||||
// Calculate custom formats
|
||||
if (trackedDownload.RemoteEpisode != null)
|
||||
{
|
||||
trackedDownload.RemoteEpisode.CustomFormats = _formatCalculator.ParseCustomFormat(parsedEpisodeInfo);
|
||||
trackedDownload.RemoteEpisode.CustomFormats = _formatCalculator.ParseCustomFormat(parsedEpisodeInfo, trackedDownload.RemoteEpisode.Series);
|
||||
}
|
||||
|
||||
// Track it so it can be displayed in the queue even though we can't determine which series it is for
|
||||
|
Loading…
Reference in New Issue
Block a user