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:
Mark McDowall
2011-07-09 11:19:33 -07:00
parent 5bbc9a6f59
commit 348ff5a386
26 changed files with 1312 additions and 158 deletions

View File

@@ -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(" ", " ");
}
}
}