Updates to deluge
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Elias Jansson
2026-01-27 20:10:05 +01:00
parent 9295dc2e98
commit eeeadd0ff2
2 changed files with 11 additions and 10 deletions

View File

@@ -111,7 +111,7 @@ public class RssController : Controller
{ {
try try
{ {
if (await _deluge.LoginAsync("deluge1")) if (await _deluge.LoginAsync("deluge1", "http://192.168.10.7:8112"))
{ {
var success = await _deluge.AddTorrentUrlAsync(torrentUrl); var success = await _deluge.AddTorrentUrlAsync(torrentUrl);
@@ -159,7 +159,7 @@ public class RssController : Controller
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Fel vid tillägg av torrent"); _logger.LogError(ex, "Fel vid tillägg av torrent");
return Json(new { success = false, message = "Ett fel uppstod vid tillägg av torrent." }); return Json(new { success = false, message = "Ett fel uppstod vid tillägg av torrent. Meddelande: " + ex.Message });
} }
} }

View File

@@ -6,16 +6,15 @@ namespace Aberwyn.Data
public class DelugeClient public class DelugeClient
{ {
private readonly HttpClient _http; private readonly HttpClient _http;
private readonly string _url;
private string _sessionId; private string _sessionId;
//should fix settings passwor private string _url;
public DelugeClient(HttpClient httpClient, string baseUrl = "http://192.168.10.7:8112/json") //should fix settings password
public DelugeClient(HttpClient httpClient)
{ {
_http = httpClient; _http = httpClient;
_url = baseUrl;
} }
public async Task<bool> LoginAsync(string password) public async Task<bool> LoginAsync(string password, string url)
{ {
var payload = new var payload = new
{ {
@@ -23,10 +22,10 @@ namespace Aberwyn.Data
@params = new object[] { password }, @params = new object[] { password },
id = 1 id = 1
}; };
_url = url + "/json";
var response = await _http.PostAsJsonAsync(_url, payload); var response = await _http.PostAsJsonAsync(_url, payload);
var json = await response.Content.ReadFromJsonAsync<JsonElement>(); var json = await response.Content.ReadFromJsonAsync<JsonElement>();
// spara sessioncookie för framtida requests // spara sessioncookie för framtida requests
if (response.Headers.TryGetValues("Set-Cookie", out var cookies)) if (response.Headers.TryGetValues("Set-Cookie", out var cookies))
{ {
@@ -38,6 +37,7 @@ namespace Aberwyn.Data
return json.GetProperty("result").GetBoolean(); return json.GetProperty("result").GetBoolean();
} }
/*
public async Task<bool> AddMagnetAsync(string magnetLink) public async Task<bool> AddMagnetAsync(string magnetLink)
{ {
var payload = new var payload = new
@@ -50,7 +50,8 @@ namespace Aberwyn.Data
var response = await _http.PostAsJsonAsync(_url, payload); var response = await _http.PostAsJsonAsync(_url, payload);
var json = await response.Content.ReadFromJsonAsync<JsonElement>(); var json = await response.Content.ReadFromJsonAsync<JsonElement>();
return json.GetProperty("result").ValueKind != JsonValueKind.Null; return json.GetProperty("result").ValueKind != JsonValueKind.Null;
} }*/
public async Task<bool> AddTorrentUrlAsync(string torrentUrl) public async Task<bool> AddTorrentUrlAsync(string torrentUrl)
{ {
var payload = new var payload = new