Implement torrents/files endpoint
It seems that recently sonarr and radarr have changed the qbittorrent inegration such at the torrents/files endpoint is required for file mapping to work. I've tested this against both sonarr and radarr, and things seem to be working.
This commit is contained in:
parent
a3c96809ef
commit
4d92a6f42d
3 changed files with 56 additions and 1 deletions
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace RdtClient.Service.Models.QBittorrent
|
||||
{
|
||||
public class TorrentFileItem
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public String Name { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@ namespace RdtClient.Service.Services
|
|||
Task<AppPreferences> AppPreferences();
|
||||
Task<String> AppDefaultSavePath();
|
||||
Task<IList<TorrentInfo>> TorrentInfo();
|
||||
Task<IList<TorrentFileItem>> TorrentFileContents(String hash);
|
||||
Task<TorrentProperties> 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<IList<TorrentFileItem>> TorrentFileContents(String hash)
|
||||
{
|
||||
var results = new List<TorrentFileItem>();
|
||||
|
||||
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> TorrentProperties(String hash)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -139,7 +139,30 @@ namespace RdtClient.Web.Controllers
|
|||
var result = await _qBittorrent.TorrentInfo();
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
||||
[Authorize]
|
||||
[Route("torrents/files")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IList<TorrentFileItem>>> 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<ActionResult<IList<TorrentFileItem>>> TorrentsFilesPost([FromForm] QBTorrentsHashRequest request)
|
||||
{
|
||||
return await TorrentsFiles(request);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[Route("torrents/properties")]
|
||||
[HttpGet]
|
||||
|
|
|
|||
Loading…
Reference in a new issue