mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
XbmcProvider will use HttpProvider.
Added DownloadString for HttpProvider that allows for authenticaion (required for XBMC with username/password).
This commit is contained in:
parent
2f8ad5db45
commit
9e15b27e3a
4 changed files with 42 additions and 19 deletions
|
@ -1,12 +1,43 @@
|
|||
using System.Net;
|
||||
using System;
|
||||
using System.Net;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
internal class HttpProvider : IHttpProvider
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public string DownloadString(string request)
|
||||
{
|
||||
return new WebClient().DownloadString(request);
|
||||
try
|
||||
{
|
||||
return new WebClient().DownloadString(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Warn("Failed to get response from: {0}", request);
|
||||
Logger.TraceException(ex.Message, ex);
|
||||
}
|
||||
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
public string DownloadString(string request, string username, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
var webClient = new WebClient();
|
||||
webClient.Credentials = new NetworkCredential(username, password);
|
||||
return webClient.DownloadString(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Warn("Failed to get response from: {0}", request);
|
||||
Logger.TraceException(ex.Message, ex);
|
||||
}
|
||||
|
||||
return String.Empty;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue