1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-10 04:52:42 +01:00

Removed code duplication in IndexerBase

This commit is contained in:
kay.one 2011-12-07 19:54:31 -08:00
parent a877312b1a
commit ba12465bb0

View File

@ -85,10 +85,9 @@ public virtual IList<EpisodeParseResult> FetchRss()
var result = new List<EpisodeParseResult>(); var result = new List<EpisodeParseResult>();
foreach (var url in Urls)
{ result = Fetch(Urls);
result.AddRange(Fetch(url));
}
_logger.Info("Finished processing feeds from " + Name); _logger.Info("Finished processing feeds from " + Name);
return result; return result;
@ -98,14 +97,8 @@ public virtual IList<EpisodeParseResult> FetchSeason(string seriesTitle, int sea
{ {
_logger.Debug("Searching {0} for {1}-Season {2}", Name, seriesTitle, seasonNumber); _logger.Debug("Searching {0} for {1}-Season {2}", Name, seriesTitle, seasonNumber);
var result = new List<EpisodeParseResult>();
var searchUrls = GetSeasonSearchUrls(GetQueryTitle(seriesTitle), seasonNumber); var searchUrls = GetSeasonSearchUrls(GetQueryTitle(seriesTitle), seasonNumber);
var result = Fetch(searchUrls);
foreach (var url in searchUrls)
{
result.AddRange(Fetch(url));
}
result = result.Where(e => e.CleanTitle == Parser.NormalizeTitle(seriesTitle)).ToList(); result = result.Where(e => e.CleanTitle == Parser.NormalizeTitle(seriesTitle)).ToList();
@ -117,14 +110,10 @@ public virtual IList<EpisodeParseResult> FetchPartialSeason(string seriesTitle,
{ {
_logger.Debug("Searching {0} for {1}-Season {2}, Prefix: {3}", Name, seriesTitle, seasonNumber, episodePrefix); _logger.Debug("Searching {0} for {1}-Season {2}, Prefix: {3}", Name, seriesTitle, seasonNumber, episodePrefix);
var result = new List<EpisodeParseResult>();
var searchUrls = GetPartialSeasonSearchUrls(GetQueryTitle(seriesTitle), seasonNumber, episodePrefix); var searchUrls = GetPartialSeasonSearchUrls(GetQueryTitle(seriesTitle), seasonNumber, episodePrefix);
foreach (var url in searchUrls) var result = Fetch(searchUrls);
{
result.AddRange(Fetch(url));
}
result = result.Where(e => e.CleanTitle == Parser.NormalizeTitle(seriesTitle)).ToList(); result = result.Where(e => e.CleanTitle == Parser.NormalizeTitle(seriesTitle)).ToList();
@ -136,14 +125,9 @@ public virtual IList<EpisodeParseResult> FetchEpisode(string seriesTitle, int se
{ {
_logger.Debug("Searching {0} for {1}-S{2:00}E{3:00}", Name, seriesTitle, seasonNumber, episodeNumber); _logger.Debug("Searching {0} for {1}-S{2:00}E{3:00}", Name, seriesTitle, seasonNumber, episodeNumber);
var result = new List<EpisodeParseResult>();
var searchUrls = GetEpisodeSearchUrls(GetQueryTitle(seriesTitle), seasonNumber, episodeNumber); var searchUrls = GetEpisodeSearchUrls(GetQueryTitle(seriesTitle), seasonNumber, episodeNumber);
foreach (var url in searchUrls) var result = Fetch(searchUrls);
{
result.AddRange(Fetch(url));
}
result = result.Where(e => e.CleanTitle == Parser.NormalizeTitle(seriesTitle)).ToList(); result = result.Where(e => e.CleanTitle == Parser.NormalizeTitle(seriesTitle)).ToList();
@ -156,14 +140,9 @@ public virtual IList<EpisodeParseResult> FetchDailyEpisode(string seriesTitle, D
{ {
_logger.Debug("Searching {0} for {1}-{2}", Name, seriesTitle, airDate.ToShortDateString()); _logger.Debug("Searching {0} for {1}-{2}", Name, seriesTitle, airDate.ToShortDateString());
var result = new List<EpisodeParseResult>();
var searchUrls = GetDailyEpisodeSearchUrls(GetQueryTitle(seriesTitle), airDate); var searchUrls = GetDailyEpisodeSearchUrls(GetQueryTitle(seriesTitle), airDate);
foreach (var url in searchUrls) var result = Fetch(searchUrls);
{
result.AddRange(Fetch(url));
}
result = result.Where(e => e.CleanTitle == Parser.NormalizeTitle(seriesTitle)).ToList(); result = result.Where(e => e.CleanTitle == Parser.NormalizeTitle(seriesTitle)).ToList();
@ -172,10 +151,12 @@ public virtual IList<EpisodeParseResult> FetchDailyEpisode(string seriesTitle, D
} }
private IEnumerable<EpisodeParseResult> Fetch(string url) private List<EpisodeParseResult> Fetch(IEnumerable<string> urls)
{ {
var result = new List<EpisodeParseResult>(); var result = new List<EpisodeParseResult>();
foreach (var url in urls)
{
try try
{ {
_logger.Trace("Downloading RSS " + url); _logger.Trace("Downloading RSS " + url);
@ -207,6 +188,7 @@ private IEnumerable<EpisodeParseResult> Fetch(string url)
{ {
_logger.ErrorException("An error occurred while processing feed", feedEx); _logger.ErrorException("An error occurred while processing feed", feedEx);
} }
}
return result; return result;
} }