コード例 #1
0
ファイル: HadoukenProxy.cs プロジェクト: zamil2200/Sonarr
        private T ProcessRequest <T>(HadoukenSettings settings, string method, params object[] parameters)
        {
            var baseUrl        = HttpRequestBuilder.BuildBaseUrl(settings.UseSsl, settings.Host, settings.Port, "api");
            var requestBuilder = new JsonRpcRequestBuilder(baseUrl, method, parameters);

            requestBuilder.LogResponseContent = true;
            requestBuilder.NetworkCredential  = new NetworkCredential(settings.Username, settings.Password);
            requestBuilder.Headers.Add("Accept-Encoding", "gzip,deflate");

            var          httpRequest = requestBuilder.Build();
            HttpResponse response;

            try
            {
                response = _httpClient.Execute(httpRequest);
            }
            catch (HttpException ex)
            {
                throw new DownloadClientException("Unable to connect to Hadouken, please check your settings", ex);
            }
            catch (WebException ex)
            {
                throw new DownloadClientUnavailableException("Unable to connect to Hadouken, please check your settings", ex);
            }

            var result = Json.Deserialize <JsonRpcResponse <T> >(response.Content);

            if (result.Error != null)
            {
                throw new DownloadClientException("Error response received from Hadouken: {0}", result.Error.ToString());
            }

            return(result.Result);
        }
コード例 #2
0
ファイル: HadoukenProxy.cs プロジェクト: debbielobo1/Lidarr
 public void RemoveTorrentAndData(HadoukenSettings settings, string downloadId)
 {
     ProcessRequest <bool>(settings, "webui.perform", "removedata", new string[] { downloadId });
 }
コード例 #3
0
ファイル: HadoukenProxy.cs プロジェクト: debbielobo1/Lidarr
 public void AddTorrentUri(HadoukenSettings settings, string torrentUrl)
 {
     ProcessRequest <string>(settings, "webui.addTorrent", "url", torrentUrl, new { label = settings.Category });
 }
コード例 #4
0
ファイル: HadoukenProxy.cs プロジェクト: debbielobo1/Lidarr
 public string AddTorrentFile(HadoukenSettings settings, byte[] fileContent)
 {
     return(ProcessRequest <string>(settings, "webui.addTorrent", "file", Convert.ToBase64String(fileContent), new { label = settings.Category }));
 }
コード例 #5
0
ファイル: HadoukenProxy.cs プロジェクト: debbielobo1/Lidarr
 public IReadOnlyDictionary <string, object> GetConfig(HadoukenSettings settings)
 {
     return(ProcessRequest <IReadOnlyDictionary <string, object> >(settings, "webui.getSettings"));
 }
コード例 #6
0
ファイル: HadoukenProxy.cs プロジェクト: debbielobo1/Lidarr
        public HadoukenTorrent[] GetTorrents(HadoukenSettings settings)
        {
            var result = ProcessRequest <HadoukenTorrentResponse>(settings, "webui.list");

            return(GetTorrents(result.Torrents));
        }
コード例 #7
0
ファイル: HadoukenProxy.cs プロジェクト: debbielobo1/Lidarr
 public HadoukenSystemInfo GetSystemInfo(HadoukenSettings settings)
 {
     return(ProcessRequest <HadoukenSystemInfo>(settings, "core.getSystemInfo"));
 }