1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-03-05 13:20:20 -05:00

New: Improve parsing of releases with contain multiple titles

This commit is contained in:
Mark McDowall
2026-02-21 12:34:12 -08:00
parent 7add5aafad
commit 965b6144e3
2 changed files with 63 additions and 1 deletions

View File

@@ -343,5 +343,49 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests
Mocker.GetMock<ISeriesService>()
.Verify(v => v.FindByTvdbId(It.IsAny<int>()), Times.Once());
}
[Test]
public void should_use_year_when_looking_up_by_all_titles_in_release_title()
{
var alias = "Series Alias";
var title = "Series Title";
_parsedEpisodeInfo.SeriesTitle = $"Series Title AKA Series Alias {_series.Year}";
_parsedEpisodeInfo.SeriesTitleInfo.AllTitles = [
title,
alias
];
_parsedEpisodeInfo.SeriesTitleInfo.Year = _series.Year;
Mocker.GetMock<ISeriesService>()
.Setup(s => s.FindByTitle(title, _series.Year))
.Returns(_series);
var result = Subject.Map(_parsedEpisodeInfo, 0, 0, "", null);
result.Series.Should().Be(_series);
}
[Test]
public void should_use_title_with_year_when_looking_up_by_all_titles_in_release_title()
{
var alias = "Series Alias";
var title = "Series Title";
_parsedEpisodeInfo.SeriesTitle = $"Series Title AKA Series Alias {_series.Year}";
_parsedEpisodeInfo.SeriesTitleInfo.AllTitles = [
title,
alias
];
_parsedEpisodeInfo.SeriesTitleInfo.Year = _series.Year;
Mocker.GetMock<ISeriesService>()
.Setup(s => s.FindByTitle($"{title} {_series.Year}"))
.Returns(_series);
var result = Subject.Map(_parsedEpisodeInfo, 0, 0, "", null);
result.Series.Should().Be(_series);
}
}
}

View File

@@ -74,13 +74,31 @@ namespace NzbDrone.Core.Parser
private Series GetSeriesByAllTitles(ParsedEpisodeInfo parsedEpisodeInfo)
{
var year = parsedEpisodeInfo.SeriesTitleInfo.Year;
Series foundSeries = null;
int? foundTvdbId = null;
// Match each title individually, they must all resolve to the same tvdbid
foreach (var title in parsedEpisodeInfo.SeriesTitleInfo.AllTitles)
{
var series = _seriesService.FindByTitle(title);
Series series = null;
if (year > 0)
{
series = _seriesService.FindByTitle(title, year);
// Fall back to title + year being part of the title, this will allow
// matching series with the same name that include the year in the title.
if (series == null)
{
series = _seriesService.FindByTitle($"{title} {year}");
}
}
else
{
series = _seriesService.FindByTitle(title);
}
var tvdbId = series?.TvdbId;
if (series == null)