Added DownloadFile method to HttpProvider.

Fixed Link that is returned from NzbMatrixProvider.NzbDownloadUrl.
IndexerProvider will now download the NZB to the disk if SABnzbd is not configured.
This commit is contained in:
Mark McDowall 2011-04-26 23:27:15 -07:00
parent 72d3f5cef2
commit 6f46a1211e
3 changed files with 33 additions and 6 deletions

View File

@ -50,6 +50,20 @@ namespace NzbDrone.Core.Providers.Core
return response.GetResponseStream();
}
public virtual bool DownloadFile(string address, string fileName)
{
try
{
var webClient = new WebClient();
webClient.DownloadFile(address, fileName);
return true;
}
catch (Exception ex)
{
Logger.Warn("Failed to get response from: {0}", address);
Logger.TraceException(ex.Message, ex);
return false;
}
}
}
}

View File

@ -154,14 +154,27 @@ namespace NzbDrone.Core.Providers.Indexer
parseResult.EpisodeTitle = episodes[0].Title;
var sabTitle = _sabProvider.GetSabTitle(parseResult);
if (_sabProvider.IsInQueue(sabTitle))
if (Convert.ToBoolean(_configProvider.UseBlackhole))
{
return;
var blackholeDir = _configProvider.BlackholeDirectory;
var folder = !String.IsNullOrEmpty(blackholeDir) ? blackholeDir : Path.Combine(CentralDispatch.AppPath, "App_Data");
var fileName = Path.Combine(folder, sabTitle + ".nzb");
_logger.Info("Downloading NZB: {0}", sabTitle);
_httpProvider.DownloadFile(NzbDownloadUrl(feedItem), fileName);
}
if (!_sabProvider.AddByUrl(NzbDownloadUrl(feedItem), sabTitle))
//else send to SAB
else
{
return;
if (_sabProvider.IsInQueue(sabTitle))
{
return;
}
if (!_sabProvider.AddByUrl(NzbDownloadUrl(feedItem), sabTitle))
{
return;
}
}
foreach (var episode in episodes)

View File

@ -34,7 +34,7 @@ namespace NzbDrone.Core.Providers.Indexer
protected override string NzbDownloadUrl(SyndicationItem item)
{
return item.Links[0].ToString();
return item.Links[0].Uri.ToString();
}
}
}