diff --git a/server/RdtClient.Service/Models/QBittorrent/TorrentFileItem.cs b/server/RdtClient.Service/Models/QBittorrent/TorrentFileItem.cs new file mode 100644 index 0000000..3d54432 --- /dev/null +++ b/server/RdtClient.Service/Models/QBittorrent/TorrentFileItem.cs @@ -0,0 +1,11 @@ +using System; +using Newtonsoft.Json; + +namespace RdtClient.Service.Models.QBittorrent +{ + public class TorrentFileItem + { + [JsonProperty("name")] + public String Name { get; set; } + } +} diff --git a/server/RdtClient.Service/Services/QBittorrent.cs b/server/RdtClient.Service/Services/QBittorrent.cs index 434ef49..67c40e7 100644 --- a/server/RdtClient.Service/Services/QBittorrent.cs +++ b/server/RdtClient.Service/Services/QBittorrent.cs @@ -16,6 +16,7 @@ namespace RdtClient.Service.Services Task AppPreferences(); Task AppDefaultSavePath(); Task> TorrentInfo(); + Task> TorrentFileContents(String hash); Task TorrentProperties(String hash); Task TorrentsDelete(String hash, Boolean deleteFiles); Task TorrentsAdd(String magnetLink, Boolean autoDownload, Boolean autoDelete); @@ -290,6 +291,26 @@ namespace RdtClient.Service.Services return results; } + public async Task> TorrentFileContents(String hash) + { + var results = new List(); + + var torrent = await _torrents.GetByHash(hash); + + if (torrent == null) + { + return null; + } + + foreach (var file in torrent.Files) + { + var result = new TorrentFileItem(); + result.Name = file.Path; + results.Add(result); + } + + return results; + } public async Task TorrentProperties(String hash) { diff --git a/server/RdtClient.Web/Controllers/QBittorrentController.cs b/server/RdtClient.Web/Controllers/QBittorrentController.cs index a5e48bc..9e63fe7 100644 --- a/server/RdtClient.Web/Controllers/QBittorrentController.cs +++ b/server/RdtClient.Web/Controllers/QBittorrentController.cs @@ -139,7 +139,30 @@ namespace RdtClient.Web.Controllers var result = await _qBittorrent.TorrentInfo(); return Ok(result); } - + + [Authorize] + [Route("torrents/files")] + [HttpGet] + public async Task>> TorrentsFiles([FromQuery] QBTorrentsHashRequest request) + { + var result = await _qBittorrent.TorrentFileContents(request.Hash); + + if (result == null) + { + return NotFound(); + } + + return Ok(result); + } + + [Authorize] + [Route("torrents/files")] + [HttpPost] + public async Task>> TorrentsFilesPost([FromForm] QBTorrentsHashRequest request) + { + return await TorrentsFiles(request); + } + [Authorize] [Route("torrents/properties")] [HttpGet]