mirror of https://github.com/lidarr/Lidarr
Don't throw error when episode title matching doesn't find a match
This commit is contained in:
parent
f13a4b5aa5
commit
c58d607349
|
@ -59,5 +59,15 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeServiceTests
|
||||||
.Should()
|
.Should()
|
||||||
.Be(expectedTitle);
|
.Be(expectedTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_null_when_no_match_is_found()
|
||||||
|
{
|
||||||
|
GivenEpisodesWithTitles();
|
||||||
|
|
||||||
|
Subject.FindEpisodeByTitle(1, 1, "The.Walking.Dead.S04.Special.Inside.The.Walking.Dead.Walker.University.720p.HDTV.x264-W4F")
|
||||||
|
.Should()
|
||||||
|
.BeNull();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ namespace NzbDrone.Core.Tv
|
||||||
var normalizedReleaseTitle = Parser.Parser.NormalizeEpisodeTitle(releaseTitle).Replace(".", " ");
|
var normalizedReleaseTitle = Parser.Parser.NormalizeEpisodeTitle(releaseTitle).Replace(".", " ");
|
||||||
var episodes = _episodeRepository.GetEpisodes(seriesId, seasonNumber);
|
var episodes = _episodeRepository.GetEpisodes(seriesId, seasonNumber);
|
||||||
|
|
||||||
var query = episodes.Select(
|
var matches = episodes.Select(
|
||||||
episode => new
|
episode => new
|
||||||
{
|
{
|
||||||
Position = normalizedReleaseTitle.IndexOf(Parser.Parser.NormalizeEpisodeTitle(episode.Title), StringComparison.CurrentCultureIgnoreCase),
|
Position = normalizedReleaseTitle.IndexOf(Parser.Parser.NormalizeEpisodeTitle(episode.Title), StringComparison.CurrentCultureIgnoreCase),
|
||||||
|
@ -121,7 +121,12 @@ namespace NzbDrone.Core.Tv
|
||||||
.ThenByDescending(e => e.Length)
|
.ThenByDescending(e => e.Length)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return query.First().Episode;
|
if (matches.Any())
|
||||||
|
{
|
||||||
|
return matches.First().Episode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Episode> EpisodesWithFiles(int seriesId)
|
public List<Episode> EpisodesWithFiles(int seriesId)
|
||||||
|
|
Loading…
Reference in New Issue