private TransmissionResponse GetSessionStatistics(TransmissionSettings settings) { return(ProcessRequest("session-stats", null, settings)); }
public string GetClientVersion(TransmissionSettings settings) { var config = GetConfig(settings); return(config.Version); }
private TransmissionResponse GetSessionVariables(TransmissionSettings settings) { // Retrieve transmission information such as the default download directory, bandwith throttling and seed ratio. return(ProcessRequest("session-get", null, settings)); }
public string GetProtocolVersion(TransmissionSettings settings) { var config = GetConfig(settings); return(config.RpcVersion); }
public void SetTorrentSeedingConfiguration(string hash, TorrentSeedConfiguration seedConfiguration, TransmissionSettings settings) { var arguments = new Dictionary <string, object>(); arguments.Add("ids", new string[] { hash }); if (seedConfiguration.Ratio != null) { arguments.Add("seedRatioLimit", seedConfiguration.Ratio.Value); arguments.Add("seedRatioMode", 1); } if (seedConfiguration.SeedTime != null) { arguments.Add("seedIdleLimit", Convert.ToInt32(seedConfiguration.SeedTime.Value.TotalMinutes)); arguments.Add("seedIdleMode", 1); } ProcessRequest("torrent-set", arguments, settings); }
public TransmissionResponse ProcessRequest(string action, object arguments, TransmissionSettings settings) { try { var requestBuilder = BuildRequest(settings); requestBuilder.Headers.ContentType = "application/json"; requestBuilder.SuppressHttpError = true; AuthenticateClient(requestBuilder, settings); var request = requestBuilder.Post().Build(); var data = new Dictionary <string, object>(); data.Add("method", action); if (arguments != null) { data.Add("arguments", arguments); } request.SetContent(data.ToJson()); request.ContentSummary = string.Format("{0}(...)", action); var response = _httpClient.Execute(request); if (response.StatusCode == HttpStatusCode.Conflict) { AuthenticateClient(requestBuilder, settings, true); request = requestBuilder.Post().Build(); request.SetContent(data.ToJson()); request.ContentSummary = string.Format("{0}(...)", action); response = _httpClient.Execute(request); } else if (response.StatusCode == HttpStatusCode.Unauthorized) { throw new DownloadClientAuthenticationException("User authentication failed."); } var transmissionResponse = Json.Deserialize <TransmissionResponse>(response.Content); if (transmissionResponse == null) { throw new TransmissionException("Unexpected response"); } else if (transmissionResponse.Result != "success") { throw new TransmissionException(transmissionResponse.Result); } return(transmissionResponse); } catch (HttpException ex) { throw new DownloadClientException("Unable to connect to Transmission, please check your settings", ex); } catch (WebException ex) { throw new DownloadClientUnavailableException("Unable to connect to Transmission, please check your settings", ex); } }
private TransmissionResponse GetTorrentStatus(IEnumerable <string> hashStrings, TransmissionSettings settings) { var fields = new string[] { "id", "hashString", // Unique torrent ID. Use this instead of the client id? "name", "downloadDir", "status", "totalSize", "leftUntilDone", "isFinished", "eta", "errorString" }; var arguments = new Dictionary <string, object>(); arguments.Add("fields", fields); if (hashStrings != null) { arguments.Add("ids", hashStrings); } var result = ProcessRequest("torrent-get", arguments, settings); return(result); }
private TransmissionResponse GetTorrentStatus(TransmissionSettings settings) { return(GetTorrentStatus(null, settings)); }