New: Implemented Torrent Download Clients: uTorrent, Transmission and Deluge. And several public and private Torrent Indexers.

This commit is contained in:
MythJuha 2014-05-13 19:57:46 +02:00 committed by Taloth Saldono
parent ffa814f387
commit 67cd5703a1
134 changed files with 11018 additions and 99 deletions

View file

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Common.Serializer;
namespace NzbDrone.Common.Http
{
public class JsonRpcRequestBuilder : HttpRequestBuilder
{
public String Method { get; private set; }
public List<Object> Parameters { get; private set; }
public JsonRpcRequestBuilder(String baseUri, String method, Object[] parameters)
: base (baseUri)
{
Method = method;
Parameters = parameters.ToList();
}
public override HttpRequest Build(String path)
{
var request = base.Build(path);
request.Method = HttpMethod.POST;
request.Headers.Accept = "application/json-rpc, application/json";
request.Headers.ContentType = "application/json-rpc";
var message = new Dictionary<String, Object>();
message["jsonrpc"] = "2.0";
message["method"] = Method;
message["params"] = Parameters;
message["id"] = CreateNextId();
request.Body = message.ToJson();
return request;
}
public String CreateNextId()
{
return Guid.NewGuid().ToString().Substring(0, 8);
}
}
}