mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-27 18:17:13 +00:00
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
3 changed files with 33 additions and 6 deletions
|
@ -50,6 +50,20 @@ public virtual Stream DownloadStream(string url, NetworkCredential credential)
|
||||||
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 @@ internal void ProcessItem(SyndicationItem feedItem)
|
||||||
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 @@ public override string Name
|
||||||
|
|
||||||
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 a new issue