mirror of
https://github.com/lidarr/Lidarr
synced 2025-01-30 19:02:06 +00:00
Search all missing fixes
Fixed: Searching for missing episodes excludes unmonitored episodes Fixed: Searching for missing episodes episodes with files
This commit is contained in:
parent
ccfd66260d
commit
0adea0ded6
6 changed files with 40 additions and 19 deletions
|
@ -138,7 +138,7 @@ public void scene_seasonsearch()
|
|||
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, 1);
|
||||
Subject.SeasonSearch(_xemSeries.Id, 1, false);
|
||||
|
||||
var criteria = allCriteria.OfType<SeasonSearchCriteria>().ToList();
|
||||
|
||||
|
@ -153,7 +153,7 @@ public void scene_seasonsearch_should_search_multiple_seasons()
|
|||
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, 2);
|
||||
Subject.SeasonSearch(_xemSeries.Id, 2, false);
|
||||
|
||||
var criteria = allCriteria.OfType<SeasonSearchCriteria>().ToList();
|
||||
|
||||
|
@ -169,7 +169,7 @@ public void scene_seasonsearch_should_search_single_episode_if_possible()
|
|||
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, 4);
|
||||
Subject.SeasonSearch(_xemSeries.Id, 4, false);
|
||||
|
||||
var criteria1 = allCriteria.OfType<SeasonSearchCriteria>().ToList();
|
||||
var criteria2 = allCriteria.OfType<SingleEpisodeSearchCriteria>().ToList();
|
||||
|
@ -189,7 +189,7 @@ public void scene_seasonsearch_should_use_seasonnumber_if_no_scene_number_is_ava
|
|||
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, 7);
|
||||
Subject.SeasonSearch(_xemSeries.Id, 7, false);
|
||||
|
||||
var criteria = allCriteria.OfType<SeasonSearchCriteria>().ToList();
|
||||
|
||||
|
@ -202,11 +202,12 @@ public void season_search_for_anime_should_search_for_each_monitored_episode()
|
|||
{
|
||||
WithEpisodes();
|
||||
_xemSeries.SeriesType = SeriesTypes.Anime;
|
||||
_xemEpisodes.ForEach(e => e.EpisodeFileId = 0);
|
||||
|
||||
var seasonNumber = 1;
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, seasonNumber);
|
||||
Subject.SeasonSearch(_xemSeries.Id, seasonNumber, true);
|
||||
|
||||
var criteria = allCriteria.OfType<AnimeEpisodeSearchCriteria>().ToList();
|
||||
|
||||
|
@ -219,11 +220,29 @@ public void season_search_for_anime_should_not_search_for_unmonitored_episodes()
|
|||
WithEpisodes();
|
||||
_xemSeries.SeriesType = SeriesTypes.Anime;
|
||||
_xemEpisodes.ForEach(e => e.Monitored = false);
|
||||
_xemEpisodes.ForEach(e => e.EpisodeFileId = 0);
|
||||
|
||||
var seasonNumber = 1;
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, seasonNumber);
|
||||
Subject.SeasonSearch(_xemSeries.Id, seasonNumber, true);
|
||||
|
||||
var criteria = allCriteria.OfType<AnimeEpisodeSearchCriteria>().ToList();
|
||||
|
||||
criteria.Count.Should().Be(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void season_search_for_anime_should_not_search_for_episodes_with_files()
|
||||
{
|
||||
WithEpisodes();
|
||||
_xemSeries.SeriesType = SeriesTypes.Anime;
|
||||
_xemEpisodes.ForEach(e => e.EpisodeFileId = 1);
|
||||
|
||||
var seasonNumber = 1;
|
||||
var allCriteria = WatchForSearchCriteria();
|
||||
|
||||
Subject.SeasonSearch(_xemSeries.Id, seasonNumber, true);
|
||||
|
||||
var criteria = allCriteria.OfType<AnimeEpisodeSearchCriteria>().ToList();
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public void Setup()
|
|||
.Returns(_series);
|
||||
|
||||
Mocker.GetMock<ISearchForNzb>()
|
||||
.Setup(s => s.SeasonSearch(_series.Id, It.IsAny<Int32>()))
|
||||
.Setup(s => s.SeasonSearch(_series.Id, It.IsAny<Int32>(), false))
|
||||
.Returns(new List<DownloadDecision>());
|
||||
|
||||
Mocker.GetMock<IProcessDownloadDecisions>()
|
||||
|
@ -52,7 +52,7 @@ public void should_only_include_monitored_seasons()
|
|||
Subject.Execute(new SeriesSearchCommand{ SeriesId = _series.Id });
|
||||
|
||||
Mocker.GetMock<ISearchForNzb>()
|
||||
.Verify(v => v.SeasonSearch(_series.Id, It.IsAny<Int32>()), Times.Exactly(_series.Seasons.Count(s => s.Monitored)));
|
||||
.Verify(v => v.SeasonSearch(_series.Id, It.IsAny<Int32>(), false), Times.Exactly(_series.Seasons.Count(s => s.Monitored)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -68,9 +68,9 @@ public void should_start_with_lower_seasons_first()
|
|||
};
|
||||
|
||||
Mocker.GetMock<ISearchForNzb>()
|
||||
.Setup(s => s.SeasonSearch(_series.Id, It.IsAny<Int32>()))
|
||||
.Setup(s => s.SeasonSearch(_series.Id, It.IsAny<Int32>(), false))
|
||||
.Returns(new List<DownloadDecision>())
|
||||
.Callback<Int32, Int32>((seriesId, seasonNumber) => seasonOrder.Add(seasonNumber));
|
||||
.Callback<int, int, bool>((seriesId, seasonNumber, missingOnly) => seasonOrder.Add(seasonNumber));
|
||||
|
||||
Subject.Execute(new SeriesSearchCommand { SeriesId = _series.Id });
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ private void SearchForMissingEpisodes(List<Episode> episodes)
|
|||
|
||||
if (season.Count() > 1)
|
||||
{
|
||||
decisions = _nzbSearchService.SeasonSearch(series.Key, season.Key);
|
||||
decisions = _nzbSearchService.SeasonSearch(series.Key, season.Key, true);
|
||||
}
|
||||
|
||||
else
|
||||
|
|
|
@ -19,7 +19,7 @@ public interface ISearchForNzb
|
|||
{
|
||||
List<DownloadDecision> EpisodeSearch(int episodeId);
|
||||
List<DownloadDecision> EpisodeSearch(Episode episode);
|
||||
List<DownloadDecision> SeasonSearch(int seriesId, int seasonNumber);
|
||||
List<DownloadDecision> SeasonSearch(int seriesId, int seasonNumber, bool missingOnly);
|
||||
}
|
||||
|
||||
public class NzbSearchService : ISearchForNzb
|
||||
|
@ -80,11 +80,16 @@ public List<DownloadDecision> EpisodeSearch(Episode episode)
|
|||
return SearchSingle(series, episode);
|
||||
}
|
||||
|
||||
public List<DownloadDecision> SeasonSearch(int seriesId, int seasonNumber)
|
||||
public List<DownloadDecision> SeasonSearch(int seriesId, int seasonNumber, bool missingOnly)
|
||||
{
|
||||
var series = _seriesService.GetSeries(seriesId);
|
||||
var episodes = _episodeService.GetEpisodesBySeason(seriesId, seasonNumber);
|
||||
|
||||
if (missingOnly)
|
||||
{
|
||||
episodes = episodes.Where(e => e.Monitored && !e.HasFile).ToList();
|
||||
}
|
||||
|
||||
if (series.SeriesType == SeriesTypes.Anime)
|
||||
{
|
||||
return SearchAnimeSeason(series, episodes);
|
||||
|
@ -217,10 +222,7 @@ private List<DownloadDecision> SearchAnimeSeason(Series series, List<Episode> ep
|
|||
|
||||
foreach (var episode in episodes)
|
||||
{
|
||||
if (episode.Monitored)
|
||||
{
|
||||
downloadDecisions.AddRange(SearchAnime(series, episode));
|
||||
}
|
||||
downloadDecisions.AddRange(SearchAnime(series, episode));
|
||||
}
|
||||
|
||||
return downloadDecisions;
|
||||
|
|
|
@ -22,7 +22,7 @@ public SeasonSearchService(ISearchForNzb nzbSearchService,
|
|||
|
||||
public void Execute(SeasonSearchCommand message)
|
||||
{
|
||||
var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, message.SeasonNumber);
|
||||
var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, message.SeasonNumber, false);
|
||||
var processed = _processDownloadDecisions.ProcessDecisions(decisions);
|
||||
|
||||
_logger.ProgressInfo("Season search completed. {0} reports downloaded.", processed.Grabbed.Count);
|
||||
|
|
|
@ -39,7 +39,7 @@ public void Execute(SeriesSearchCommand message)
|
|||
continue;
|
||||
}
|
||||
|
||||
var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, season.SeasonNumber);
|
||||
var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, season.SeasonNumber, false);
|
||||
downloadedCount += _processDownloadDecisions.ProcessDecisions(decisions).Grabbed.Count;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue