private void SearchForEpisodes(List <Episode> episodes, bool monitoredOnly, bool userInvokedSearch) { _logger.ProgressInfo("Performing search for {0} episodes", episodes.Count); var downloadedCount = 0; foreach (var series in episodes.GroupBy(e => e.SeriesId)) { foreach (var season in series.Select(e => e).GroupBy(e => e.SeasonNumber)) { List <DownloadDecision> decisions; if (season.Count() > 1) { try { decisions = _releaseSearchService.SeasonSearch(series.Key, season.Key, season.ToList(), monitoredOnly, userInvokedSearch, false); } catch (Exception ex) { _logger.Error(ex, "Unable to search for episodes in season {0} of [{1}]", season.Key, series.Key); continue; } } else { try { decisions = _releaseSearchService.EpisodeSearch(season.First(), userInvokedSearch, false); } catch (Exception ex) { _logger.Error(ex, "Unable to search for episode: [{0}]", season.First()); continue; } } var processed = _processDownloadDecisions.ProcessDecisions(decisions); downloadedCount += processed.Grabbed.Count; } } _logger.ProgressInfo("Completed search for {0} episodes. {1} reports downloaded.", episodes.Count, downloadedCount); }
private List <ReleaseResource> GetEpisodeReleases(int episodeId) { try { var decisions = _releaseSearchService.EpisodeSearch(episodeId, true, true); var prioritizedDecisions = _prioritizeDownloadDecision.PrioritizeDecisions(decisions); return(MapDecisions(prioritizedDecisions)); } catch (Exception ex) { _logger.Error(ex, "Episode search failed"); } return(new List <ReleaseResource>()); }
private List <ReleaseResource> GetEpisodeReleases(int episodeId) { try { var decisions = _releaseSearchService.EpisodeSearch(episodeId, true, true); var prioritizedDecisions = _prioritizeDownloadDecision.PrioritizeDecisions(decisions); return(MapDecisions(prioritizedDecisions)); } catch (SearchFailedException ex) { throw new NzbDroneClientException(HttpStatusCode.BadRequest, ex.Message); } catch (Exception ex) { _logger.Error(ex, "Episode search failed: " + ex.Message); throw new NzbDroneClientException(HttpStatusCode.InternalServerError, ex.Message); } }