mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
Processing of Daily Episode searching now supported.
This commit is contained in:
parent
cadccb4360
commit
726eccb0e8
3 changed files with 331 additions and 1 deletions
|
@ -146,7 +146,10 @@ namespace NzbDrone.Core.Providers
|
|||
Logger.Debug("Finished searching all indexers. Total {0}", reports.Count);
|
||||
notification.CurrentMessage = "Processing search results";
|
||||
|
||||
if (ProcessSearchResults(notification, reports, series, episode.SeasonNumber, episode.EpisodeNumber).Count == 1)
|
||||
if (!series.IsDaily && ProcessSearchResults(notification, reports, series, episode.SeasonNumber, episode.EpisodeNumber).Count == 1)
|
||||
return true;
|
||||
|
||||
if (series.IsDaily && ProcessSearchResults(notification, reports, series, episode.AirDate.Value))
|
||||
return true;
|
||||
|
||||
Logger.Warn("Unable to find {0} in any of indexers.", episode);
|
||||
|
@ -268,6 +271,54 @@ namespace NzbDrone.Core.Providers
|
|||
return successes;
|
||||
}
|
||||
|
||||
public bool ProcessSearchResults(ProgressNotification notification, IEnumerable<EpisodeParseResult> reports, Series series, DateTime airDate)
|
||||
{
|
||||
foreach (var episodeParseResult in reports.OrderByDescending(c => c.Quality))
|
||||
{
|
||||
try
|
||||
{
|
||||
Logger.Trace("Analysing report " + episodeParseResult);
|
||||
|
||||
//Get the matching series
|
||||
episodeParseResult.Series = _seriesProvider.FindSeries(episodeParseResult.CleanTitle);
|
||||
|
||||
//If series is null or doesn't match the series we're looking for return
|
||||
if (episodeParseResult.Series == null || episodeParseResult.Series.SeriesId != series.SeriesId)
|
||||
continue;
|
||||
|
||||
//If parse result doesn't have an air date or it doesn't match passed in airdate, skip the report.
|
||||
if (!episodeParseResult.AirDate.HasValue || episodeParseResult.AirDate.Value.Date != airDate.Date)
|
||||
continue;
|
||||
|
||||
if (_inventoryProvider.IsQualityNeeded(episodeParseResult))
|
||||
{
|
||||
Logger.Debug("Found '{0}'. Adding to download queue.", episodeParseResult);
|
||||
try
|
||||
{
|
||||
if (_downloadProvider.DownloadReport(episodeParseResult))
|
||||
{
|
||||
notification.CurrentMessage =
|
||||
String.Format("{0} - {1} {2}Added to download queue",
|
||||
episodeParseResult.Series.Title, episodeParseResult.AirDate.Value.ToShortDateString(), episodeParseResult.Quality);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.ErrorException("Unable to add report to download queue." + episodeParseResult, e);
|
||||
notification.CurrentMessage = String.Format("Unable to add report to download queue. {0}", episodeParseResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.ErrorException("An error has occurred while processing parse result items from " + episodeParseResult, e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<int> GetEpisodeNumberPrefixes(IEnumerable<int> episodeNumbers)
|
||||
{
|
||||
var results = new List<int>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue