mirror of
https://github.com/lantean-code/qbtmud.git
synced 2025-10-23 04:52:22 +00:00
Update to use v5 api only.
This commit is contained in:
@@ -53,7 +53,7 @@ namespace Lantean.QBTMud.Components.Dialogs
|
|||||||
|
|
||||||
TorrentManagementMode = preferences.AutoTmmEnabled;
|
TorrentManagementMode = preferences.AutoTmmEnabled;
|
||||||
SavePath = preferences.SavePath;
|
SavePath = preferences.SavePath;
|
||||||
StartTorrent = !preferences.StartPausedEnabled;
|
StartTorrent = !preferences.AddStoppedEnabled;
|
||||||
AddToTopOfQueue = preferences.AddToTopOfQueue;
|
AddToTopOfQueue = preferences.AddToTopOfQueue;
|
||||||
StopCondition = preferences.TorrentStopCondition;
|
StopCondition = preferences.TorrentStopCondition;
|
||||||
ContentLayout = preferences.TorrentContentLayout;
|
ContentLayout = preferences.TorrentContentLayout;
|
||||||
|
@@ -65,8 +65,8 @@
|
|||||||
{
|
{
|
||||||
return __builder =>
|
return __builder =>
|
||||||
{
|
{
|
||||||
<MudMenuItem Icon="@Icons.Material.Filled.PlayArrow" IconColor="Color.Success" OnClick="@(e => ResumeTorrents(type))">Resume torrents</MudMenuItem>
|
<MudMenuItem Icon="@Icons.Material.Filled.PlayArrow" IconColor="Color.Success" OnClick="@(e => StartTorrents(type))">Start torrents</MudMenuItem>
|
||||||
<MudMenuItem Icon="@Icons.Material.Filled.Pause" IconColor="Color.Warning" OnClick="@(e => PauseTorrents(type))">Pause torrents</MudMenuItem>
|
<MudMenuItem Icon="@Icons.Material.Filled.Pause" IconColor="Color.Warning" OnClick="@(e => StopTorrents(type))">Stop torrents</MudMenuItem>
|
||||||
<MudMenuItem Icon="@Icons.Material.Filled.Delete" IconColor="Color.Error" OnClick="@(e => RemoveTorrents(type))">Remove torrents</MudMenuItem>
|
<MudMenuItem Icon="@Icons.Material.Filled.Delete" IconColor="Color.Error" OnClick="@(e => RemoveTorrents(type))">Remove torrents</MudMenuItem>
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@ using Lantean.QBTMud.Models;
|
|||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.AspNetCore.Components.Web;
|
using Microsoft.AspNetCore.Components.Web;
|
||||||
using MudBlazor;
|
using MudBlazor;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Lantean.QBTMud.Components
|
namespace Lantean.QBTMud.Components
|
||||||
{
|
{
|
||||||
@@ -352,18 +353,18 @@ namespace Lantean.QBTMud.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task ResumeTorrents(string type)
|
protected async Task StartTorrents(string type)
|
||||||
{
|
{
|
||||||
var torrents = GetAffectedTorrentHashes(type);
|
var torrents = GetAffectedTorrentHashes(type);
|
||||||
|
|
||||||
await ApiClient.ResumeTorrents(torrents);
|
await ApiClient.StartTorrents(hashes: torrents.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task PauseTorrents(string type)
|
protected async Task StopTorrents(string type)
|
||||||
{
|
{
|
||||||
var torrents = GetAffectedTorrentHashes(type);
|
var torrents = GetAffectedTorrentHashes(type);
|
||||||
|
|
||||||
await ApiClient.PauseTorrents(torrents);
|
await ApiClient.StopTorrents(hashes: torrents.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task RemoveTorrents(string type)
|
protected async Task RemoveTorrents(string type)
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
<FieldSwitch Label="Add to top of queue" Value="AddToTopOfQueue" ValueChanged="AddToTopOfQueueChanged" />
|
<FieldSwitch Label="Add to top of queue" Value="AddToTopOfQueue" ValueChanged="AddToTopOfQueueChanged" />
|
||||||
</MudItem>
|
</MudItem>
|
||||||
<MudItem xs="12">
|
<MudItem xs="12">
|
||||||
<FieldSwitch Label="Do not start the download automatically" Value="StartPausedEnabled" ValueChanged="StartPausedEnabledChanged" />
|
<FieldSwitch Label="Do not start the download automatically" Value="AddStoppedEnabled" ValueChanged="AddStoppedEnabledChanged" />
|
||||||
</MudItem>
|
</MudItem>
|
||||||
<MudItem xs="12">
|
<MudItem xs="12">
|
||||||
<MudSelect T="string" Label="Torrent stop condition" Value="TorrentStopCondition" ValueChanged="TorrentStopConditionChanged" Variant="Variant.Outlined">
|
<MudSelect T="string" Label="Torrent stop condition" Value="TorrentStopCondition" ValueChanged="TorrentStopConditionChanged" Variant="Variant.Outlined">
|
||||||
|
@@ -6,7 +6,7 @@ namespace Lantean.QBTMud.Components.Options
|
|||||||
{
|
{
|
||||||
protected string? TorrentContentLayout { get; set; }
|
protected string? TorrentContentLayout { get; set; }
|
||||||
protected bool AddToTopOfQueue { get; set; }
|
protected bool AddToTopOfQueue { get; set; }
|
||||||
protected bool StartPausedEnabled { get; set; }
|
protected bool AddStoppedEnabled { get; set; }
|
||||||
protected string? TorrentStopCondition { get; set; }
|
protected string? TorrentStopCondition { get; set; }
|
||||||
protected bool AutoDeleteMode { get; set; }
|
protected bool AutoDeleteMode { get; set; }
|
||||||
protected bool PreallocateAll { get; set; }
|
protected bool PreallocateAll { get; set; }
|
||||||
@@ -51,7 +51,7 @@ namespace Lantean.QBTMud.Components.Options
|
|||||||
// when adding a torrent
|
// when adding a torrent
|
||||||
TorrentContentLayout = Preferences.TorrentContentLayout;
|
TorrentContentLayout = Preferences.TorrentContentLayout;
|
||||||
AddToTopOfQueue = Preferences.AddToTopOfQueue;
|
AddToTopOfQueue = Preferences.AddToTopOfQueue;
|
||||||
StartPausedEnabled = Preferences.StartPausedEnabled;
|
AddStoppedEnabled = Preferences.AddStoppedEnabled;
|
||||||
TorrentStopCondition = Preferences.TorrentStopCondition;
|
TorrentStopCondition = Preferences.TorrentStopCondition;
|
||||||
AutoDeleteMode = Preferences.AutoDeleteMode == 1;
|
AutoDeleteMode = Preferences.AutoDeleteMode == 1;
|
||||||
PreallocateAll = Preferences.PreallocateAll;
|
PreallocateAll = Preferences.PreallocateAll;
|
||||||
@@ -116,10 +116,10 @@ namespace Lantean.QBTMud.Components.Options
|
|||||||
await PreferencesChanged.InvokeAsync(UpdatePreferences);
|
await PreferencesChanged.InvokeAsync(UpdatePreferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task StartPausedEnabledChanged(bool value)
|
protected async Task AddStoppedEnabledChanged(bool value)
|
||||||
{
|
{
|
||||||
StartPausedEnabled = value;
|
AddStoppedEnabled = value;
|
||||||
UpdatePreferences.StartPausedEnabled = value;
|
UpdatePreferences.AddStoppedEnabled = value;
|
||||||
await PreferencesChanged.InvokeAsync(UpdatePreferences);
|
await PreferencesChanged.InvokeAsync(UpdatePreferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@ using Lantean.QBTMud.Services;
|
|||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.JSInterop;
|
using Microsoft.JSInterop;
|
||||||
using MudBlazor;
|
using MudBlazor;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Lantean.QBTMud.Components
|
namespace Lantean.QBTMud.Components
|
||||||
{
|
{
|
||||||
@@ -77,8 +78,8 @@ namespace Lantean.QBTMud.Components
|
|||||||
{
|
{
|
||||||
_actions =
|
_actions =
|
||||||
[
|
[
|
||||||
new("start", "Start", Icons.Material.Filled.PlayArrow, Color.Success, CreateCallback(Resume)),
|
new("start", "Start", Icons.Material.Filled.PlayArrow, Color.Success, CreateCallback(Start)),
|
||||||
new("pause", "Pause", MajorVersion < 5 ? Icons.Material.Filled.Pause : Icons.Material.Filled.Stop, Color.Warning, CreateCallback(Pause)),
|
new("stop", "Stop", Icons.Material.Filled.Stop, Color.Warning, CreateCallback(Stop)),
|
||||||
new("forceStart", "Force start", Icons.Material.Filled.Forward, Color.Warning, CreateCallback(ForceStart)),
|
new("forceStart", "Force start", Icons.Material.Filled.Forward, Color.Warning, CreateCallback(ForceStart)),
|
||||||
new("delete", "Remove", Icons.Material.Filled.Delete, Color.Error, CreateCallback(Remove), separatorBefore: true),
|
new("delete", "Remove", Icons.Material.Filled.Delete, Color.Error, CreateCallback(Remove), separatorBefore: true),
|
||||||
new("setLocation", "Set location", Icons.Material.Filled.MyLocation, Color.Info, CreateCallback(SetLocation), separatorBefore: true),
|
new("setLocation", "Set location", Icons.Material.Filled.MyLocation, Color.Info, CreateCallback(SetLocation), separatorBefore: true),
|
||||||
@@ -146,32 +147,16 @@ namespace Lantean.QBTMud.Components
|
|||||||
OverlayVisible = value;
|
OverlayVisible = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task Pause()
|
protected async Task Stop()
|
||||||
{
|
{
|
||||||
if (MajorVersion < 5)
|
await ApiClient.StopTorrents(hashes: Hashes.ToArray());
|
||||||
{
|
Snackbar.Add(MajorVersion < 5 ? "Torrent paused." : "Torrent stopped.");
|
||||||
await ApiClient.PauseTorrents(Hashes);
|
|
||||||
Snackbar.Add("Torrent paused.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await ApiClient.StopTorrents(Hashes);
|
|
||||||
Snackbar.Add("Torrent stopped.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task Resume()
|
protected async Task Start()
|
||||||
{
|
{
|
||||||
if (MajorVersion < 5)
|
await ApiClient.StartTorrents(hashes: Hashes.ToArray());
|
||||||
{
|
Snackbar.Add(MajorVersion < 5 ? "Torrent resumed." : "Torrent started.");
|
||||||
await ApiClient.ResumeTorrents(Hashes);
|
|
||||||
Snackbar.Add("Torrent resumed.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await ApiClient.StartTorrents(Hashes);
|
|
||||||
Snackbar.Add("Torrent started.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task ForceStart()
|
protected async Task ForceStart()
|
||||||
|
@@ -171,7 +171,7 @@ namespace Lantean.QBTMud.Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await ApiClient.AddTrackersToTorrent(Hash, trackers);
|
await ApiClient.AddTrackersToTorrent(trackers, hashes: new[] { Hash });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Task EditTrackerToolbar()
|
protected Task EditTrackerToolbar()
|
||||||
@@ -211,7 +211,7 @@ namespace Lantean.QBTMud.Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await ApiClient.RemoveTrackers(Hash, [tracker.Url]);
|
await ApiClient.RemoveTrackers([tracker.Url], hashes: new[] { Hash });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Task CopyTrackerUrlToolbar()
|
protected Task CopyTrackerUrlToolbar()
|
||||||
|
@@ -3,6 +3,7 @@ using Lantean.QBTMud.Components.Dialogs;
|
|||||||
using Lantean.QBTMud.Filter;
|
using Lantean.QBTMud.Filter;
|
||||||
using Lantean.QBTMud.Models;
|
using Lantean.QBTMud.Models;
|
||||||
using MudBlazor;
|
using MudBlazor;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Lantean.QBTMud.Helpers
|
namespace Lantean.QBTMud.Helpers
|
||||||
{
|
{
|
||||||
@@ -56,7 +57,7 @@ namespace Lantean.QBTMud.Helpers
|
|||||||
var addTorrentParams = CreateAddTorrentParams(options);
|
var addTorrentParams = CreateAddTorrentParams(options);
|
||||||
addTorrentParams.Torrents = files;
|
addTorrentParams.Torrents = files;
|
||||||
|
|
||||||
await apiClient.AddTorrent(addTorrentParams);
|
_ = await apiClient.AddTorrent(addTorrentParams);
|
||||||
|
|
||||||
foreach (var stream in streams)
|
foreach (var stream in streams)
|
||||||
{
|
{
|
||||||
@@ -74,15 +75,10 @@ namespace Lantean.QBTMud.Helpers
|
|||||||
{
|
{
|
||||||
addTorrentParams.ContentLayout = Enum.Parse<QBitTorrentClient.Models.TorrentContentLayout>(options.ContentLayout);
|
addTorrentParams.ContentLayout = Enum.Parse<QBitTorrentClient.Models.TorrentContentLayout>(options.ContentLayout);
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(options.Cookie))
|
|
||||||
{
|
|
||||||
addTorrentParams.Cookie = options.Cookie;
|
|
||||||
}
|
|
||||||
addTorrentParams.DownloadLimit = options.DownloadLimit;
|
addTorrentParams.DownloadLimit = options.DownloadLimit;
|
||||||
addTorrentParams.DownloadPath = options.DownloadPath;
|
addTorrentParams.DownloadPath = options.DownloadPath;
|
||||||
addTorrentParams.FirstLastPiecePriority = options.DownloadFirstAndLastPiecesFirst;
|
addTorrentParams.FirstLastPiecePriority = options.DownloadFirstAndLastPiecesFirst;
|
||||||
addTorrentParams.InactiveSeedingTimeLimit = options.InactiveSeedingTimeLimit;
|
addTorrentParams.InactiveSeedingTimeLimit = options.InactiveSeedingTimeLimit;
|
||||||
addTorrentParams.Paused = !options.StartTorrent;
|
|
||||||
addTorrentParams.RatioLimit = options.RatioLimit;
|
addTorrentParams.RatioLimit = options.RatioLimit;
|
||||||
addTorrentParams.RenameTorrent = options.RenameTorrent;
|
addTorrentParams.RenameTorrent = options.RenameTorrent;
|
||||||
addTorrentParams.SavePath = options.SavePath;
|
addTorrentParams.SavePath = options.SavePath;
|
||||||
@@ -123,7 +119,7 @@ namespace Lantean.QBTMud.Helpers
|
|||||||
var addTorrentParams = CreateAddTorrentParams(options);
|
var addTorrentParams = CreateAddTorrentParams(options);
|
||||||
addTorrentParams.Urls = options.Urls;
|
addTorrentParams.Urls = options.Urls;
|
||||||
|
|
||||||
await apiClient.AddTorrent(addTorrentParams);
|
_ = await apiClient.AddTorrent(addTorrentParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<bool> InvokeDeleteTorrentDialog(this IDialogService dialogService, IApiClient apiClient, params string[] hashes)
|
public static async Task<bool> InvokeDeleteTorrentDialog(this IDialogService dialogService, IApiClient apiClient, params string[] hashes)
|
||||||
@@ -243,7 +239,7 @@ namespace Lantean.QBTMud.Helpers
|
|||||||
|
|
||||||
var shareRatio = (ShareRatio)dialogResult.Data;
|
var shareRatio = (ShareRatio)dialogResult.Data;
|
||||||
|
|
||||||
await apiClient.SetTorrentShareLimit(shareRatio.RatioLimit, shareRatio.SeedingTimeLimit, shareRatio.InactiveSeedingTimeLimit, null, torrents.Select(t => t.Hash).ToArray());
|
await apiClient.SetTorrentShareLimit(shareRatio.RatioLimit, shareRatio.SeedingTimeLimit, shareRatio.InactiveSeedingTimeLimit, hashes: torrents.Select(t => t.Hash).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task InvokeStringFieldDialog(this IDialogService dialogService, string title, string label, string? value, Func<string, Task> onSuccess)
|
public static async Task InvokeStringFieldDialog(this IDialogService dialogService, string title, string label, string? value, Func<string, Task> onSuccess)
|
||||||
|
@@ -1738,7 +1738,7 @@ namespace Lantean.QBTMud.Services
|
|||||||
SocketReceiveBufferSize = changed.SocketReceiveBufferSize,
|
SocketReceiveBufferSize = changed.SocketReceiveBufferSize,
|
||||||
SocketSendBufferSize = changed.SocketSendBufferSize,
|
SocketSendBufferSize = changed.SocketSendBufferSize,
|
||||||
SsrfMitigation = changed.SsrfMitigation,
|
SsrfMitigation = changed.SsrfMitigation,
|
||||||
StartPausedEnabled = changed.StartPausedEnabled,
|
AddStoppedEnabled = changed.AddStoppedEnabled,
|
||||||
StopTrackerTimeout = changed.StopTrackerTimeout,
|
StopTrackerTimeout = changed.StopTrackerTimeout,
|
||||||
TempPath = changed.TempPath,
|
TempPath = changed.TempPath,
|
||||||
TempPathEnabled = changed.TempPathEnabled,
|
TempPathEnabled = changed.TempPathEnabled,
|
||||||
@@ -1944,7 +1944,7 @@ namespace Lantean.QBTMud.Services
|
|||||||
original.SocketReceiveBufferSize = changed.SocketReceiveBufferSize ?? original.SocketReceiveBufferSize;
|
original.SocketReceiveBufferSize = changed.SocketReceiveBufferSize ?? original.SocketReceiveBufferSize;
|
||||||
original.SocketSendBufferSize = changed.SocketSendBufferSize ?? original.SocketSendBufferSize;
|
original.SocketSendBufferSize = changed.SocketSendBufferSize ?? original.SocketSendBufferSize;
|
||||||
original.SsrfMitigation = changed.SsrfMitigation ?? original.SsrfMitigation;
|
original.SsrfMitigation = changed.SsrfMitigation ?? original.SsrfMitigation;
|
||||||
original.StartPausedEnabled = changed.StartPausedEnabled ?? original.StartPausedEnabled;
|
original.AddStoppedEnabled = changed.AddStoppedEnabled ?? original.AddStoppedEnabled;
|
||||||
original.StopTrackerTimeout = changed.StopTrackerTimeout ?? original.StopTrackerTimeout;
|
original.StopTrackerTimeout = changed.StopTrackerTimeout ?? original.StopTrackerTimeout;
|
||||||
original.TempPath = changed.TempPath ?? original.TempPath;
|
original.TempPath = changed.TempPath ?? original.TempPath;
|
||||||
original.TempPathEnabled = changed.TempPathEnabled ?? original.TempPathEnabled;
|
original.TempPathEnabled = changed.TempPathEnabled ?? original.TempPathEnabled;
|
||||||
|
Reference in New Issue
Block a user