public static async Task <bool> DownloadTorrent(string hash) { using (var content = new HttpMultipartFormDataContent("-------" + DateTime.Now.ToString(CultureInfo.InvariantCulture))) { content.Add(new HttpStringContent("magnet:" + hash), "urls"); //content.Add(new HttpStringContent) save path bool result = await CoreApi.PostAsync("/command/download", content); if (result == true) { return(await Task.FromResult(true)); } else { return(await Task.FromResult(false)); } } }
public static async Task <bool> TorrentAction(ManageTorrent manager, string hash) { Dictionary <string, string> hashkey = new Dictionary <string, string> { { "hash", hash } }; var content = new HttpFormUrlEncodedContent(hashkey); string path = string.Empty; switch (manager) { case ManageTorrent.Pause: path = "/command/pause"; break; case ManageTorrent.Resume: path = "/command/resume"; break; case ManageTorrent.Delete: path = "/command/delete"; break; case ManageTorrent.DeleteWithFile: path = "/command/deletePerm"; break; case ManageTorrent.PauseAll: path = "/command/pauseAll"; content = null; break; case ManageTorrent.ResumeAll: path = "/command/resumeAll"; content = null; break; } bool result = await CoreApi.PostAsync(path, content); return(await Task.FromResult(result)); }