mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-30 11:48:26 -07:00
New: Implemented Torrent Download Clients: uTorrent, Transmission and Deluge. And several public and private Torrent Indexers.
This commit is contained in:
parent
ffa814f387
commit
67cd5703a1
134 changed files with 11018 additions and 99 deletions
44
src/NzbDrone.Common/Http/JsonRpcRequestBuilder.cs
Normal file
44
src/NzbDrone.Common/Http/JsonRpcRequestBuilder.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue