mirror of https://github.com/Radarr/Radarr
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:
parent
72d3f5cef2
commit
6f46a1211e
|
@ -50,6 +50,20 @@ namespace NzbDrone.Core.Providers.Core
|
||||||
return response.GetResponseStream();
|
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,14 +154,27 @@ namespace NzbDrone.Core.Providers.Indexer
|
||||||
parseResult.EpisodeTitle = episodes[0].Title;
|
parseResult.EpisodeTitle = episodes[0].Title;
|
||||||
var sabTitle = _sabProvider.GetSabTitle(parseResult);
|
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)
|
foreach (var episode in episodes)
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace NzbDrone.Core.Providers.Indexer
|
||||||
|
|
||||||
protected override string NzbDownloadUrl(SyndicationItem item)
|
protected override string NzbDownloadUrl(SyndicationItem item)
|
||||||
{
|
{
|
||||||
return item.Links[0].ToString();
|
return item.Links[0].Uri.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue