added Deluge label creation

This commit is contained in:
Flaminel
2025-03-25 16:11:53 +02:00
parent 3b63d1b7e5
commit 5e362d4af8
2 changed files with 19 additions and 2 deletions
@@ -1,4 +1,4 @@
using System.Net.Http.Headers;
using System.Net.Http.Headers;
using System.Text.Json.Serialization;
using Common.Configuration;
using Common.Configuration.DownloadClient;
@@ -194,6 +194,16 @@ public sealed class DelugeClient
return webResponse.Result;
}
public async Task<IReadOnlyList<string>> GetLabels()
{
return await SendRequest<IReadOnlyList<string>>("label.label.get_labels");
}
public async Task CreateLabel(string label)
{
await SendRequest<DelugeResponse<object>>("label.add", label);
}
public async Task SetTorrentLabel(string hash, string newLabel)
{
// TODO
@@ -298,7 +298,14 @@ public class DelugeService : DownloadService, IDelugeService
public override async Task CreateCategoryAsync(string name)
{
throw new NotImplementedException();
IReadOnlyList<string> existingLabels = await _client.GetLabels();
if (existingLabels.Contains(name, StringComparer.InvariantCultureIgnoreCase))
{
return;
}
await _client.CreateLabel(name);
}
public override async Task ChangeCategoryForNoHardLinksAsync(List<object>? downloads, HashSet<string> excludedHashes, IReadOnlyList<string> ignoredDownloads)