1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-12 11:15:43 +02: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>();
foreach (var url in Urls)
{
result.AddRange(Fetch(url));
}
result = Fetch(Urls);
_logger.Info("Finished processing feeds from " + Name);
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);
var result = new List<EpisodeParseResult>();
var searchUrls = GetSeasonSearchUrls(GetQueryTitle(seriesTitle), seasonNumber);
foreach (var url in searchUrls)
{
result.AddRange(Fetch(url));
}
var result = Fetch(searchUrls);
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);
var result = new List<EpisodeParseResult>();
var searchUrls = GetPartialSeasonSearchUrls(GetQueryTitle(seriesTitle), seasonNumber, episodePrefix);
foreach (var url in searchUrls)
{
result.AddRange(Fetch(url));
}
var result = Fetch(searchUrls);
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);
var result = new List<EpisodeParseResult>();
var searchUrls = GetEpisodeSearchUrls(GetQueryTitle(seriesTitle), seasonNumber, episodeNumber);
foreach (var url in searchUrls)
{
result.AddRange(Fetch(url));
}
var result = Fetch(searchUrls);
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());
var result = new List<EpisodeParseResult>();
var searchUrls = GetDailyEpisodeSearchUrls(GetQueryTitle(seriesTitle), airDate);
foreach (var url in searchUrls)
{
result.AddRange(Fetch(url));
}
var result = Fetch(searchUrls);
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>();
foreach (var url in urls)
{
try
{
_logger.Trace("Downloading RSS " + url);
@ -207,6 +188,7 @@ private IEnumerable<EpisodeParseResult> Fetch(string url)
{
_logger.ErrorException("An error occurred while processing feed", feedEx);
}
}
return result;
}