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.
pull/4/head
Mark McDowall 14 years ago
parent 72d3f5cef2
commit 6f46a1211e

@ -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;
}
}
}
}

@ -154,6 +154,18 @@ namespace NzbDrone.Core.Providers.Indexer
parseResult.EpisodeTitle = episodes[0].Title;
var sabTitle = _sabProvider.GetSabTitle(parseResult);
if (Convert.ToBoolean(_configProvider.UseBlackhole))
{
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);
}
//else send to SAB
else
{
if (_sabProvider.IsInQueue(sabTitle))
{
return;
@ -163,6 +175,7 @@ namespace NzbDrone.Core.Providers.Indexer
{
return;
}
}
foreach (var episode in episodes)
{

@ -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();
}
}
}
Loading…
Cancel
Save