mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-28 04:51:45 +02:00
XbmcProvider updated to include new Json API methods.
EventClient is used for sending CleanLibrary and Notifications (With NzbDrone Logo - Internal Resource). Support for Dharma's HTTP Server (Deprecated), since Dharma doesn't support Json as well.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Core.Providers.Core
|
||||
@@ -64,5 +65,33 @@ namespace NzbDrone.Core.Providers.Core
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string PostCommand(string address, string username, string password, string command)
|
||||
{
|
||||
address += "/jsonrpc";
|
||||
|
||||
byte[] byteArray = Encoding.ASCII.GetBytes(command);
|
||||
|
||||
var request = WebRequest.Create(address);
|
||||
request.Method = "POST";
|
||||
request.Credentials = new NetworkCredential(username, password);
|
||||
request.ContentLength = byteArray.Length;
|
||||
request.ContentType = "application/x-www-form-urlencoded";
|
||||
var dataStream = request.GetRequestStream();
|
||||
dataStream.Write(byteArray, 0, byteArray.Length);
|
||||
dataStream.Close();
|
||||
|
||||
var response = request.GetResponse();
|
||||
dataStream = response.GetResponseStream();
|
||||
var reader = new StreamReader(dataStream);
|
||||
// Read the content.
|
||||
string responseFromServer = reader.ReadToEnd();
|
||||
|
||||
reader.Close();
|
||||
dataStream.Close();
|
||||
response.Close();
|
||||
|
||||
return responseFromServer.Replace(" ", " ");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user