/// <summary> /// Gets the specified fields of all recently-active torrents. /// </summary> /// <param name="fields">fields to get, multiple fields can be combined with "|"</param> public Task <TorrentGetResponse> TorrentGetRecentAsync(TorrentFields fields) { var request = new TorrentGetRequest <string> { Fields = fields.ToStringRepresentation(), IDs = "recently-active" }; return(GetResponseAsync <TorrentGetResponse, TorrentGetRequest <string> >(request)); }
/// <summary> /// Gets the specified fields for torrents matching any type of torrent-identifier (see supported values in transmission-rpc spec or <paramref name="ids"/>). /// </summary> /// <typeparam name="T">type of IDs</typeparam> /// <param name="fields">fields to get, multiple fields can be combined with "|"</param> /// <param name="ids">any type of supported value as ID (list of ints, hashstrings, or both in one list, int, (the string "recently-active" is a valid argument, but is handled in <see cref="TorrentGetRecentAsync"/>, because it causes the result to have a new array with recently-deleted IDs))</param> private async Task <Torrent[]> TorrentGetAsync <T>(TorrentFields fields, T ids) { var request = new TorrentGetRequest <T> { Fields = fields.ToStringRepresentation(), IDs = ids }; var response = await GetResponseAsync <TorrentGetResponse, TorrentGetRequest <T> >(request); return(response.Torrents); }
/// <summary> /// Returns all torrents, optionally filtered by 'filter'. /// </summary> /// <param name='filter'> /// Torrent Filter. /// </param> /// <param name='fields'> /// Fields to return by TorrentField. /// </param> /// <param name='callback'> /// Method Callback (Dictionary(string, object) torrents) /// </param> public void GetTorrentsStatus(Dictionary<string, object> filter, TorrentFields[] fields, object state, GetTorrentsStatusCallback callback) { List<string> _keys = new List<string>(); foreach(TorrentFields field in fields) { if(TorrentFieldMap.ContainsKey(field)) _keys.Add(TorrentFieldMap[field]); else Console.WriteLine("No Map found for: " + field); } GetTorrentsStatus(filter, _keys, state, callback); }
/// <summary> /// Returns all torrents, optionally filtered by 'filter'. /// </summary> /// <param name='filter'> /// Torrent Filter. /// </param> /// <param name='fields'> /// Fields to return by TorrentField. /// </param> /// <param name='callback'> /// Method Callback (Dictionary(string, object) torrents) /// </param> public void GetTorrentsStatus(Dictionary<string, object> filter, TorrentFields[] fields, GetTorrentsStatusCallback callback) { GetTorrentsStatus(filter, fields, null, callback); }
/// <summary> /// Gets the specified fields for those torrents matching the hashes. /// </summary> /// <param name="fields">fields to get, multiple fields can be combined with "|"</param> /// <param name="hashes">collection of torrent-hashes</param> public Task <Torrent[]> TorrentGetAsync(TorrentFields fields, IEnumerable <string> hashes) { return(TorrentGetAsync(fields, hashes.ToArray())); }
/// <summary> /// Gets the specified fields for those torrents matching the torrent IDs. /// </summary> /// <param name="fields">fields to get, multiple fields can be combined with "|"</param> /// <param name="ids">collection of torrent IDs</param> public Task <Torrent[]> TorrentGetAsync(TorrentFields fields, IEnumerable <int> ids) { return(TorrentGetAsync(fields, ids.ToArray())); }
/// <summary> /// Gets the specified fields for the single torrent matching the ID. /// </summary> /// <param name="fields">fields to get, multiple fields can be combined with "|"</param> /// <param name="id">single torrent ID</param> public Task <Torrent[]> TorrentGetAsync(TorrentFields fields, int id) { return(TorrentGetAsync <int>(fields, id)); }
/// <summary> /// Gets all torrents with the specified fields. /// </summary> /// <param name="fields">fields to get, multiple fields can be combined with "|"</param> public Task <Torrent[]> TorrentGetAsync(TorrentFields fields) { return(TorrentGetAsync(fields, (string)null)); }
/// <summary> /// Gets the specified fields for those torrents matching either the IDs or hashes. /// </summary> /// <param name="fields">fields to get, multiple fields can be combined with "|"</param> /// <param name="ids">collection of torrent IDs</param> /// <param name="hashes">collection of torrent-hashes</param> public Task <Torrent[]> TorrentGetAsync(TorrentFields fields, IEnumerable <int> ids, IEnumerable <string> hashes) { return(TorrentGetAsync(fields, ((IEnumerable <object>)ids).Concat(hashes).ToArray())); }