mirror of
https://github.com/lantean-code/qbtmud.git
synced 2025-10-22 20:42:24 +00:00
Fix onlongtouch after refactor
This commit is contained in:
@@ -1,7 +1,53 @@
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<MudGrid>
|
||||
<MudItem xs="12">
|
||||
<MudItem xs="4">
|
||||
<MudGrid>
|
||||
<MudItem xs="12">
|
||||
<FieldSwitch Label="Remember Multi-Rename settings" Value="RememberMultiRenameSettings" ValueChanged="RememberMultiRenameSettingsChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudTextField T="string" Label="Search files" Value="Search" ValueChanged="SearchChanged" Variant="Variant.Outlined" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<FieldSwitch Label="Use regular expressions" Value="UseRegex" ValueChanged="UseRegexChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<FieldSwitch Label="Match all occurrences" Value="MatchAllOccurrences" ValueChanged="MatchAllOccurrencesChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<FieldSwitch Label="Case sensitive" Value="CaseSensitive" ValueChanged="CaseSensitiveChanged" />
|
||||
</MudItem>
|
||||
<MudDivider />
|
||||
<MudItem xs="12">
|
||||
<MudTextField T="string" Label="Replacement" Value="Replacement" ValueChanged="ReplacementChanged" Variant="Variant.Outlined" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudSelect T="AppliesTo" Label="Applies to" Value="AppliesToValue" ValueChanged="AppliesToChanged" Variant="Variant.Outlined">
|
||||
<MudSelectItem T="AppliesTo" Value="AppliesTo.FilenameExtension">Filename + Extension</MudSelectItem>
|
||||
<MudSelectItem T="AppliesTo" Value="AppliesTo.Filename">Filename</MudSelectItem>
|
||||
<MudSelectItem T="AppliesTo" Value="AppliesTo.Extension">Extension</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<FieldSwitch Label="Include files" Value="IncludeFiles" ValueChanged="IncludeFilesChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<FieldSwitch Label="Include folders" Value="IncludeFolders" ValueChanged="IncludeFoldersChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudNumericField T="int" Label="Enumerate files" Value="FileEnumerationStart" ValueChanged="FileEnumerationStartChanged" Min="0" Variant="Variant.Outlined" />
|
||||
</MudItem>
|
||||
<MudDivider />
|
||||
<MudItem xs="12">
|
||||
<MudSelect T="bool" Label="Replace type" Value="ReplaceAll" ValueChanged="ReplaceAllChanged" Variant="Variant.Outlined">
|
||||
<MudSelectItem T="bool" Value="true">Replace</MudSelectItem>
|
||||
<MudSelectItem T="bool" Value="false">Replace all</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudItem>
|
||||
<MudItem xs="8">
|
||||
<DynamicTable T="FileRow"
|
||||
ColumnDefinitions="Columns"
|
||||
Items="Files"
|
||||
@@ -17,7 +63,7 @@
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">Close</MudButton>
|
||||
<MudButton Color="Color.Primary" OnClick="Submit">Rename</MudButton>
|
||||
<MudButton Color="Color.Primary" OnClick="Submit">@(ReplaceAll ? "Replace all" : "Replace")</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using Lantean.QBTMud.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using System.Collections.ObjectModel;
|
||||
using static MudBlazor.Colors;
|
||||
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
@@ -51,6 +52,11 @@ namespace Lantean.QBTMud.Components.Dialogs
|
||||
|
||||
private ReadOnlyCollection<FileRow> GetFiles()
|
||||
{
|
||||
if (!FileList.Any())
|
||||
{
|
||||
return new ReadOnlyCollection<FileRow>([]);
|
||||
}
|
||||
|
||||
var maxLevel = FileList.Max(f => f.Level);
|
||||
// this is a flat file structure
|
||||
if (maxLevel == 0)
|
||||
@@ -321,65 +327,107 @@ namespace Lantean.QBTMud.Components.Dialogs
|
||||
|
||||
protected bool UseRegex { get; set; }
|
||||
|
||||
protected void UseRegexChanged(bool value)
|
||||
protected async Task UseRegexChanged(bool value)
|
||||
{
|
||||
UseRegex = value;
|
||||
|
||||
await UpdatePreferences(p => p.UseRegex = value);
|
||||
}
|
||||
|
||||
protected bool MatchAllOccurrences { get; set; }
|
||||
|
||||
protected void MatchAllOccurrencesChanged(bool value)
|
||||
protected async Task MatchAllOccurrencesChanged(bool value)
|
||||
{
|
||||
MatchAllOccurrences = value;
|
||||
|
||||
await UpdatePreferences(p => p.MatchAllOccurrences = value);
|
||||
}
|
||||
|
||||
protected bool CaseSensitive { get; set; }
|
||||
|
||||
protected void CaseSensitiveChanged(bool value)
|
||||
protected async Task CaseSensitiveChanged(bool value)
|
||||
{
|
||||
CaseSensitive = value;
|
||||
|
||||
await UpdatePreferences(p => p.CaseSensitive = value);
|
||||
}
|
||||
|
||||
protected string Replacement { get; set; } = "";
|
||||
|
||||
protected void ReplacementChanged(string value)
|
||||
protected async Task ReplacementChanged(string value)
|
||||
{
|
||||
Replacement = value;
|
||||
|
||||
await UpdatePreferences(p => p.Replace = value);
|
||||
}
|
||||
|
||||
protected AppliesTo AppliesToValue { get; set; } = AppliesTo.FilenameExtension;
|
||||
|
||||
protected void AppliesToChanged(AppliesTo value)
|
||||
protected async Task AppliesToChanged(AppliesTo value)
|
||||
{
|
||||
AppliesToValue = value;
|
||||
|
||||
await UpdatePreferences(p => p.AppliesTo = value);
|
||||
}
|
||||
|
||||
protected bool IncludeFiles { get; set; } = true;
|
||||
|
||||
protected void IncludeFilesChanged(bool value)
|
||||
protected async Task IncludeFilesChanged(bool value)
|
||||
{
|
||||
IncludeFiles = value;
|
||||
|
||||
await UpdatePreferences(p => p.IncludeFiles = value);
|
||||
}
|
||||
|
||||
protected bool IncludeFolders { get; set; }
|
||||
|
||||
protected void IncludeFoldersChanged(bool value)
|
||||
protected async Task IncludeFoldersChanged(bool value)
|
||||
{
|
||||
IncludeFolders = value;
|
||||
|
||||
await UpdatePreferences(p => p.IncludeFolders = value);
|
||||
}
|
||||
|
||||
protected int FileEnumerationStart { get; set; }
|
||||
|
||||
protected void FileEnumerationStartChanged(int value)
|
||||
protected async Task FileEnumerationStartChanged(int value)
|
||||
{
|
||||
FileEnumerationStart = value;
|
||||
|
||||
await UpdatePreferences(p => p.FileEnumerationStart = value);
|
||||
}
|
||||
|
||||
protected bool ReplaceAll { get; set; }
|
||||
|
||||
protected void ReplaceAllChanged(bool value)
|
||||
protected async Task ReplaceAllChanged(bool value)
|
||||
{
|
||||
ReplaceAll = value;
|
||||
|
||||
await UpdatePreferences(p => p.ReplaceAll = value);
|
||||
}
|
||||
|
||||
protected bool RememberMultiRenameSettings { get; set; }
|
||||
|
||||
protected async Task RememberMultiRenameSettingsChanged(bool value)
|
||||
{
|
||||
RememberMultiRenameSettings = value;
|
||||
|
||||
await UpdatePreferences(p => p.RememberPreferences = value);
|
||||
}
|
||||
|
||||
private async Task UpdatePreferences(Action<MultiRenamePreferences> updateAction)
|
||||
{
|
||||
var preferences = await LocalStorage.GetItemAsync<MultiRenamePreferences>(_preferencesStorageKey) ?? new();
|
||||
updateAction(preferences);
|
||||
if (preferences.RememberPreferences)
|
||||
{
|
||||
await LocalStorage.SetItemAsync(_preferencesStorageKey, preferences);
|
||||
}
|
||||
else
|
||||
{
|
||||
await LocalStorage.RemoveItemAsync(_preferencesStorageKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
@@ -414,8 +462,43 @@ namespace Lantean.QBTMud.Components.Dialogs
|
||||
MudDialog.Cancel();
|
||||
}
|
||||
|
||||
protected void Submit()
|
||||
protected async Task Submit()
|
||||
{
|
||||
if (Hash is null)
|
||||
{
|
||||
MudDialog.Close();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var renamedFiles = FileNameMatcher.GetRenamedFiles(
|
||||
SelectedItems,
|
||||
Search,
|
||||
UseRegex,
|
||||
Replacement,
|
||||
MatchAllOccurrences,
|
||||
CaseSensitive,
|
||||
AppliesToValue,
|
||||
IncludeFiles,
|
||||
IncludeFolders,
|
||||
ReplaceAll,
|
||||
FileEnumerationStart);
|
||||
|
||||
foreach (var (_, renamedFile) in renamedFiles)
|
||||
{
|
||||
var oldPath = renamedFile.Path + renamedFile.OriginalName;
|
||||
var newPath = renamedFile.Path + renamedFile.NewName;
|
||||
if (renamedFile.IsFolder)
|
||||
{
|
||||
|
||||
await ApiClient.RenameFolder(Hash, oldPath, newPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
await ApiClient.RenameFile(Hash, oldPath, newPath);
|
||||
}
|
||||
}
|
||||
|
||||
MudDialog.Close();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Blazored.LocalStorage;
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBTMud.Components.UI;
|
||||
using Lantean.QBTMud.EventHandlers;
|
||||
using Lantean.QBTMud.Helpers;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Lantean.QBTMud.Components
|
||||
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("rename", "Rename", Icons.Material.Filled.DriveFileRenameOutline, Color.Info, CreateCallback(Rename)),
|
||||
new("renameFiles", "Rename files", Icons.Material.Filled.DriveFileRenameOutline, Color.Warning, CreateCallback(Rename)),
|
||||
new("renameFiles", "Rename files", Icons.Material.Filled.DriveFileRenameOutline, Color.Warning, CreateCallback(RenameFiles)),
|
||||
new("category", "Category", Icons.Material.Filled.List, Color.Info, CreateCallback(ShowCategories)),
|
||||
new("tags", "Tags", Icons.Material.Filled.Label, Color.Info, CreateCallback(ShowTags)),
|
||||
new("autoTorrentManagement", "Automatic Torrent Management", Icons.Material.Filled.Check, Color.Info, CreateCallback(ToggleAutoTMM)),
|
||||
@@ -174,14 +174,30 @@ namespace Lantean.QBTMud.Components
|
||||
|
||||
protected async Task Pause()
|
||||
{
|
||||
await ApiClient.PauseTorrents(Hashes);
|
||||
Snackbar.Add("Torrent paused.");
|
||||
if (MajorVersion < 5)
|
||||
{
|
||||
await ApiClient.PauseTorrents(Hashes);
|
||||
Snackbar.Add("Torrent paused.");
|
||||
}
|
||||
else
|
||||
{
|
||||
await ApiClient.StopTorrents(Hashes);
|
||||
Snackbar.Add("Torrent stopped.");
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task Resume()
|
||||
{
|
||||
await ApiClient.ResumeTorrents(Hashes);
|
||||
Snackbar.Add("Torrent resumed.");
|
||||
if (MajorVersion < 5)
|
||||
{
|
||||
await ApiClient.ResumeTorrents(Hashes);
|
||||
Snackbar.Add("Torrent resumed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
await ApiClient.StartTorrents(Hashes);
|
||||
Snackbar.Add("Torrent started.");
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task ForceStart()
|
||||
@@ -298,7 +314,7 @@ namespace Lantean.QBTMud.Components
|
||||
|
||||
protected async Task MoveToTop()
|
||||
{
|
||||
await ApiClient.MaximalTorrentPriority(null, Hashes.ToArray());
|
||||
await ApiClient.MaxTorrentPriority(null, Hashes.ToArray());
|
||||
}
|
||||
|
||||
protected async Task MoveUp()
|
||||
@@ -313,7 +329,7 @@ namespace Lantean.QBTMud.Components
|
||||
|
||||
protected async Task MoveToBottom()
|
||||
{
|
||||
await ApiClient.MinimalTorrentPriority(null, Hashes.ToArray());
|
||||
await ApiClient.MinTorrentPriority(null, Hashes.ToArray());
|
||||
}
|
||||
|
||||
protected async Task Copy(string value)
|
||||
@@ -557,18 +573,18 @@ namespace Lantean.QBTMud.Components
|
||||
|
||||
if (MajorVersion >= 5)
|
||||
{
|
||||
if (actionStates.ContainsKey("start"))
|
||||
if (actionStates.TryGetValue("start", out ActionState? startActionState))
|
||||
{
|
||||
actionStates["start"].TextOverride = "Start";
|
||||
startActionState.TextOverride = "Start";
|
||||
}
|
||||
else
|
||||
{
|
||||
actionStates["start"] = new ActionState { TextOverride = "Start" };
|
||||
}
|
||||
|
||||
if (actionStates.ContainsKey("pause"))
|
||||
if (actionStates.TryGetValue("pause", out ActionState? stopActionState))
|
||||
{
|
||||
actionStates["pause"].TextOverride = "Stop";
|
||||
stopActionState.TextOverride = "Stop";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Lantean.QBTMud.EventHandlers;
|
||||
using Lantean.QBTMud.Interop;
|
||||
using Lantean.QBTMud.Interop;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Lantean.QBTMud.EventHandlers;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using MudBlazor;
|
||||
using MudBlazor.Utilities;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Blazored.LocalStorage;
|
||||
using Lantean.QBTMud.EventHandlers;
|
||||
using Lantean.QBTMud.Helpers;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Lantean.QBTMud.EventHandlers;
|
||||
using MudBlazor;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMud.Components.UI
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Lantean.QBTMud.EventHandlers;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using MudBlazor;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Lantean.QBTMud.EventHandlers
|
||||
namespace Lantean.QBTMud
|
||||
{
|
||||
[EventHandler("onlongpress", typeof(LongPressEventArgs), enableStopPropagation: true, enablePreventDefault: true)]
|
||||
public static class EventHandlers
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Lantean.QBTMud.EventHandlers
|
||||
namespace Lantean.QBTMud
|
||||
{
|
||||
public class LongPressEventArgs : EventArgs
|
||||
{
|
||||
|
||||
@@ -53,24 +53,10 @@ namespace Lantean.QBTMud.Helpers
|
||||
files.Add(file.Name, stream);
|
||||
}
|
||||
|
||||
await apiClient.AddTorrent(
|
||||
urls: null,
|
||||
files,
|
||||
options.SavePath,
|
||||
options.Cookie,
|
||||
options.Category,
|
||||
tags: null,
|
||||
options.SkipHashCheck,
|
||||
!options.StartTorrent,
|
||||
options.ContentLayout,
|
||||
options.RenameTorrent,
|
||||
options.UploadLimit,
|
||||
options.DownloadLimit,
|
||||
ratioLimit: null,
|
||||
seedingTimeLimit: null,
|
||||
options.TorrentManagementMode,
|
||||
options.DownloadInSequentialOrder,
|
||||
options.DownloadFirstAndLastPiecesFirst);
|
||||
var addTorrentParams = CreateAddTorrentParams(options);
|
||||
addTorrentParams.Torrents = files;
|
||||
|
||||
await apiClient.AddTorrent(addTorrentParams);
|
||||
|
||||
foreach (var stream in streams)
|
||||
{
|
||||
@@ -78,6 +64,46 @@ namespace Lantean.QBTMud.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
private static QBitTorrentClient.Models.AddTorrentParams CreateAddTorrentParams(TorrentOptions options)
|
||||
{
|
||||
var addTorrentParams = new QBitTorrentClient.Models.AddTorrentParams();
|
||||
addTorrentParams.AddToTopOfQueue = options.AddToTopOfQueue;
|
||||
addTorrentParams.AutoTorrentManagement = options.TorrentManagementMode;
|
||||
addTorrentParams.Category = options.Category;
|
||||
if (!string.IsNullOrEmpty(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.DownloadPath = options.DownloadPath;
|
||||
addTorrentParams.FirstLastPiecePriority = options.DownloadFirstAndLastPiecesFirst;
|
||||
addTorrentParams.InactiveSeedingTimeLimit = options.InactiveSeedingTimeLimit;
|
||||
addTorrentParams.Paused = !options.StartTorrent;
|
||||
addTorrentParams.RatioLimit = options.RatioLimit;
|
||||
addTorrentParams.RenameTorrent = options.RenameTorrent;
|
||||
addTorrentParams.SavePath = options.SavePath;
|
||||
addTorrentParams.SeedingTimeLimit = options.SeedingTimeLimit;
|
||||
addTorrentParams.SequentialDownload = options.DownloadInSequentialOrder;
|
||||
if (!string.IsNullOrEmpty(options.ShareLimitAction))
|
||||
{
|
||||
addTorrentParams.ShareLimitAction = Enum.Parse<QBitTorrentClient.Models.ShareLimitAction>(options.ShareLimitAction);
|
||||
}
|
||||
addTorrentParams.SkipChecking = options.SkipHashCheck;
|
||||
if (!string.IsNullOrEmpty(options.StopCondition))
|
||||
{
|
||||
addTorrentParams.StopCondition = Enum.Parse<QBitTorrentClient.Models.StopCondition>(options.StopCondition);
|
||||
}
|
||||
addTorrentParams.Stopped = !options.StartTorrent;
|
||||
addTorrentParams.Tags = options.Tags;
|
||||
addTorrentParams.UploadLimit = options.UploadLimit;
|
||||
addTorrentParams.UseDownloadPath = options.UseDownloadPath;
|
||||
return addTorrentParams;
|
||||
}
|
||||
|
||||
public static async Task InvokeAddTorrentLinkDialog(this IDialogService dialogService, IApiClient apiClient, string? url = null)
|
||||
{
|
||||
var parameters = new DialogParameters
|
||||
@@ -94,24 +120,10 @@ namespace Lantean.QBTMud.Helpers
|
||||
|
||||
var options = (AddTorrentLinkOptions)dialogResult.Data;
|
||||
|
||||
await apiClient.AddTorrent(
|
||||
urls: options.Urls,
|
||||
torrents: null,
|
||||
options.SavePath,
|
||||
options.Cookie,
|
||||
options.Category,
|
||||
tags: null,
|
||||
options.SkipHashCheck,
|
||||
!options.StartTorrent,
|
||||
options.ContentLayout,
|
||||
options.RenameTorrent,
|
||||
options.UploadLimit,
|
||||
options.DownloadLimit,
|
||||
ratioLimit: null,
|
||||
seedingTimeLimit: null,
|
||||
options.TorrentManagementMode,
|
||||
options.DownloadInSequentialOrder,
|
||||
options.DownloadFirstAndLastPiecesFirst);
|
||||
var addTorrentParams = CreateAddTorrentParams(options);
|
||||
addTorrentParams.Urls = options.Urls;
|
||||
|
||||
await apiClient.AddTorrent(addTorrentParams);
|
||||
}
|
||||
|
||||
public static async Task<bool> InvokeDeleteTorrentDialog(this IDialogService dialogService, IApiClient apiClient, params string[] hashes)
|
||||
@@ -192,7 +204,7 @@ namespace Lantean.QBTMud.Helpers
|
||||
{
|
||||
var parameters = new DialogParameters
|
||||
{
|
||||
//{ nameof(RenameFilesDialog.Hash), hash }
|
||||
{ nameof(RenameFilesDialog.Hash), hash }
|
||||
};
|
||||
|
||||
await dialogService.ShowAsync<RenameFilesDialog>("Rename Files", parameters, FullScreenDialogOptions);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.10" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.10" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
|
||||
<PackageReference Include="MudBlazor" Version="7.13.0" />
|
||||
<PackageReference Include="MudBlazor" Version="7.15.0" />
|
||||
<PackageReference Include="MudBlazor.ThemeManager" Version="2.1.0" />
|
||||
<!-- added to fix vuln in dependency -->
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.5" />
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Lantean.QBTMud.Models
|
||||
using Lantean.QBitTorrentClient.Models;
|
||||
|
||||
namespace Lantean.QBTMud.Models
|
||||
{
|
||||
public record TorrentOptions
|
||||
{
|
||||
@@ -61,5 +63,12 @@
|
||||
public long DownloadLimit { get; }
|
||||
|
||||
public long UploadLimit { get; }
|
||||
public string? DownloadPath { get; internal set; }
|
||||
public int? InactiveSeedingTimeLimit { get; internal set; }
|
||||
public float? RatioLimit { get; internal set; }
|
||||
public int? SeedingTimeLimit { get; internal set; }
|
||||
public string? ShareLimitAction { get; internal set; }
|
||||
public bool? UseDownloadPath { get; internal set; }
|
||||
public IEnumerable<string>? Tags { get; internal set; }
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ namespace Lantean.QBTMud.Pages
|
||||
|
||||
protected override Task OnInitializedAsync()
|
||||
{
|
||||
return DoLogin("admin", "AQnwFmBzV");
|
||||
return DoLogin("admin", "eBGJzbjkJ");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -305,7 +305,7 @@ namespace Lantean.QBitTorrentClient
|
||||
|
||||
#region Torrent management
|
||||
|
||||
public async Task<IReadOnlyList<Torrent>> GetTorrentList(string? filter = null, string? category = null, string? tag = null, string? sort = null, bool? reverse = null, int? limit = null, int? offset = null, params string[] hashes)
|
||||
public async Task<IReadOnlyList<Torrent>> GetTorrentList(string? filter = null, string? category = null, string? tag = null, string? sort = null, bool? reverse = null, int? limit = null, int? offset = null, bool? isPrivate = null, params string[] hashes)
|
||||
{
|
||||
var query = new QueryBuilder();
|
||||
if (filter is not null)
|
||||
@@ -340,6 +340,10 @@ namespace Lantean.QBitTorrentClient
|
||||
{
|
||||
query.Add("hashes", string.Join('|', hashes));
|
||||
}
|
||||
if (isPrivate is not null)
|
||||
{
|
||||
query.Add("private", isPrivate.Value ? "true" : "false");
|
||||
}
|
||||
|
||||
var response = await _httpClient.GetAsync("torrents/info", query);
|
||||
|
||||
@@ -486,79 +490,110 @@ namespace Lantean.QBitTorrentClient
|
||||
await ThrowIfNotSuccessfulStatusCode(response);
|
||||
}
|
||||
|
||||
public async Task AddTorrent(IEnumerable<string>? urls = null, Dictionary<string, Stream>? torrents = null, string? savePath = null, string? cookie = null, string? category = null, IEnumerable<string>? tags = null, bool? skipChecking = null, bool? paused = null, string? contentLayout = null, string? renameTorrent = null, long? uploadLimit = null, long? downloadLimit = null, float? ratioLimit = null, int? seedingTimeLimit = null, bool? autoTorrentManagement = null, bool? sequentialDownload = null, bool? firstLastPiecePriority = null)
|
||||
public async Task AddTorrent(AddTorrentParams addTorrentParams)
|
||||
{
|
||||
var content = new MultipartFormDataContent();
|
||||
if (urls is not null)
|
||||
if (addTorrentParams.Urls is not null)
|
||||
{
|
||||
content.AddString("urls", string.Join('\n', urls));
|
||||
content.AddString("urls", string.Join('\n', addTorrentParams.Urls));
|
||||
}
|
||||
if (torrents is not null)
|
||||
if (addTorrentParams.Torrents is not null)
|
||||
{
|
||||
foreach (var (name, stream) in torrents)
|
||||
foreach (var (name, stream) in addTorrentParams.Torrents)
|
||||
{
|
||||
content.Add(new StreamContent(stream), "torrents", name);
|
||||
}
|
||||
}
|
||||
if (savePath is not null)
|
||||
if (addTorrentParams.SkipChecking is not null)
|
||||
{
|
||||
content.AddString("savepath", savePath);
|
||||
content.AddString("skip_checking", addTorrentParams.SkipChecking.Value);
|
||||
}
|
||||
if (cookie is not null)
|
||||
if (addTorrentParams.SequentialDownload is not null)
|
||||
{
|
||||
content.AddString("cookie", cookie);
|
||||
content.AddString("sequentialDownload", addTorrentParams.SequentialDownload.Value);
|
||||
}
|
||||
if (category is not null)
|
||||
if (addTorrentParams.FirstLastPiecePriority is not null)
|
||||
{
|
||||
content.AddString("category", category);
|
||||
content.AddString("firstLastPiecePrio", addTorrentParams.FirstLastPiecePriority.Value);
|
||||
}
|
||||
if (tags is not null)
|
||||
if (addTorrentParams.AddToTopOfQueue is not null)
|
||||
{
|
||||
content.AddString("tags", string.Join(',', tags));
|
||||
content.AddString("addToTopOfQueue", addTorrentParams.AddToTopOfQueue.Value);
|
||||
}
|
||||
if (skipChecking is not null)
|
||||
// v4
|
||||
if (addTorrentParams.Paused is not null)
|
||||
{
|
||||
content.AddString("skip_checking", skipChecking.Value);
|
||||
content.AddString("paused", addTorrentParams.Paused.Value);
|
||||
}
|
||||
if (paused is not null)
|
||||
// v5
|
||||
if (addTorrentParams.Stopped is not null)
|
||||
{
|
||||
content.AddString("paused", paused.Value);
|
||||
content.AddString("stopped", addTorrentParams.Stopped.Value);
|
||||
}
|
||||
if (contentLayout is not null)
|
||||
if (addTorrentParams.SavePath is not null)
|
||||
{
|
||||
content.AddString("contentLayout", contentLayout);
|
||||
content.AddString("savepath", addTorrentParams.SavePath);
|
||||
}
|
||||
if (renameTorrent is not null)
|
||||
if (addTorrentParams.DownloadPath is not null)
|
||||
{
|
||||
content.AddString("rename", renameTorrent);
|
||||
content.AddString("downloadPath", addTorrentParams.DownloadPath);
|
||||
}
|
||||
if (uploadLimit is not null)
|
||||
if (addTorrentParams.UseDownloadPath is not null)
|
||||
{
|
||||
content.AddString("upLimit", uploadLimit.Value);
|
||||
content.AddString("useDownloadPath", addTorrentParams.UseDownloadPath.Value);
|
||||
}
|
||||
if (downloadLimit is not null)
|
||||
if (addTorrentParams.Category is not null)
|
||||
{
|
||||
content.AddString("dlLimit", downloadLimit.Value);
|
||||
content.AddString("category", addTorrentParams.Category);
|
||||
}
|
||||
if (ratioLimit is not null)
|
||||
if (addTorrentParams.Tags is not null)
|
||||
{
|
||||
content.AddString("ratioLimit", ratioLimit.Value);
|
||||
content.AddString("tags", string.Join(',', addTorrentParams.Tags));
|
||||
}
|
||||
if (seedingTimeLimit is not null)
|
||||
if (addTorrentParams.RenameTorrent is not null)
|
||||
{
|
||||
content.AddString("seedingTimeLimit", seedingTimeLimit.Value);
|
||||
content.AddString("rename", addTorrentParams.RenameTorrent);
|
||||
}
|
||||
if (autoTorrentManagement is not null)
|
||||
if (addTorrentParams.UploadLimit is not null)
|
||||
{
|
||||
content.AddString("autoTMM", autoTorrentManagement.Value);
|
||||
content.AddString("upLimit", addTorrentParams.UploadLimit.Value);
|
||||
}
|
||||
if (sequentialDownload is not null)
|
||||
if (addTorrentParams.DownloadLimit is not null)
|
||||
{
|
||||
content.AddString("sequentialDownload", sequentialDownload.Value);
|
||||
content.AddString("dlLimit", addTorrentParams.DownloadLimit.Value);
|
||||
}
|
||||
if (firstLastPiecePriority is not null)
|
||||
if (addTorrentParams.RatioLimit is not null)
|
||||
{
|
||||
content.AddString("firstLastPiecePrio", firstLastPiecePriority.Value);
|
||||
content.AddString("ratioLimit", addTorrentParams.RatioLimit.Value);
|
||||
}
|
||||
if (addTorrentParams.SeedingTimeLimit is not null)
|
||||
{
|
||||
content.AddString("seedingTimeLimit", addTorrentParams.SeedingTimeLimit.Value);
|
||||
}
|
||||
if (addTorrentParams.InactiveSeedingTimeLimit is not null)
|
||||
{
|
||||
content.AddString("inactiveSeedingTimeLimit", addTorrentParams.InactiveSeedingTimeLimit.Value);
|
||||
}
|
||||
if (addTorrentParams.ShareLimitAction is not null)
|
||||
{
|
||||
content.AddString("shareLimitAction", addTorrentParams.ShareLimitAction.Value);
|
||||
}
|
||||
if (addTorrentParams.AutoTorrentManagement is not null)
|
||||
{
|
||||
content.AddString("autoTMM", addTorrentParams.AutoTorrentManagement.Value);
|
||||
}
|
||||
if (addTorrentParams.StopCondition is not null)
|
||||
{
|
||||
content.AddString("stopCondition", addTorrentParams.StopCondition.Value);
|
||||
}
|
||||
if (addTorrentParams.ContentLayout is not null)
|
||||
{
|
||||
content.AddString("contentLayout", addTorrentParams.ContentLayout.Value);
|
||||
}
|
||||
|
||||
if (addTorrentParams.Cookie is not null)
|
||||
{
|
||||
content.AddString("cookie", addTorrentParams.Cookie);
|
||||
}
|
||||
|
||||
var response = await _httpClient.PostAsync("torrents/add", content);
|
||||
@@ -606,7 +641,7 @@ namespace Lantean.QBitTorrentClient
|
||||
public async Task AddPeers(IEnumerable<string> hashes, IEnumerable<PeerId> peers)
|
||||
{
|
||||
var content = new FormUrlEncodedBuilder()
|
||||
.AddPipeSeparated("hash", hashes)
|
||||
.AddPipeSeparated("hashes", hashes)
|
||||
.AddPipeSeparated("urls", peers)
|
||||
.ToFormUrlEncodedContent();
|
||||
|
||||
@@ -618,7 +653,7 @@ namespace Lantean.QBitTorrentClient
|
||||
public async Task IncreaseTorrentPriority(bool? all = null, params string[] hashes)
|
||||
{
|
||||
var content = new FormUrlEncodedBuilder()
|
||||
.AddAllOrPipeSeparated("hash", all, hashes)
|
||||
.AddAllOrPipeSeparated("hashes", all, hashes)
|
||||
.ToFormUrlEncodedContent();
|
||||
|
||||
var response = await _httpClient.PostAsync("torrents/increasePrio", content);
|
||||
@@ -629,7 +664,7 @@ namespace Lantean.QBitTorrentClient
|
||||
public async Task DecreaseTorrentPriority(bool? all = null, params string[] hashes)
|
||||
{
|
||||
var content = new FormUrlEncodedBuilder()
|
||||
.AddAllOrPipeSeparated("hash", all, hashes)
|
||||
.AddAllOrPipeSeparated("hashes", all, hashes)
|
||||
.ToFormUrlEncodedContent();
|
||||
|
||||
var response = await _httpClient.PostAsync("torrents/decreasePrio", content);
|
||||
@@ -637,10 +672,10 @@ namespace Lantean.QBitTorrentClient
|
||||
await ThrowIfNotSuccessfulStatusCode(response);
|
||||
}
|
||||
|
||||
public async Task MaximalTorrentPriority(bool? all = null, params string[] hashes)
|
||||
public async Task MaxTorrentPriority(bool? all = null, params string[] hashes)
|
||||
{
|
||||
var content = new FormUrlEncodedBuilder()
|
||||
.AddAllOrPipeSeparated("hash", all, hashes)
|
||||
.AddAllOrPipeSeparated("hashes", all, hashes)
|
||||
.ToFormUrlEncodedContent();
|
||||
|
||||
var response = await _httpClient.PostAsync("torrents/topPrio", content);
|
||||
@@ -648,10 +683,10 @@ namespace Lantean.QBitTorrentClient
|
||||
await ThrowIfNotSuccessfulStatusCode(response);
|
||||
}
|
||||
|
||||
public async Task MinimalTorrentPriority(bool? all = null, params string[] hashes)
|
||||
public async Task MinTorrentPriority(bool? all = null, params string[] hashes)
|
||||
{
|
||||
var content = new FormUrlEncodedBuilder()
|
||||
.AddAllOrPipeSeparated("hash", all, hashes)
|
||||
.AddAllOrPipeSeparated("hashes", all, hashes)
|
||||
.ToFormUrlEncodedContent();
|
||||
|
||||
var response = await _httpClient.PostAsync("torrents/bottomPrio", content);
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Lantean.QBitTorrentClient
|
||||
|
||||
#region Torrent management
|
||||
|
||||
Task<IReadOnlyList<Torrent>> GetTorrentList(string? filter = null, string? category = null, string? tag = null, string? sort = null, bool? reverse = null, int? limit = null, int? offset = null, params string[] hashes);
|
||||
Task<IReadOnlyList<Torrent>> GetTorrentList(string? filter = null, string? category = null, string? tag = null, string? sort = null, bool? reverse = null, int? limit = null, int? offset = null, bool? isPrivate = null, params string[] hashes);
|
||||
|
||||
Task<TorrentProperties> GetTorrentProperties(string hash);
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Lantean.QBitTorrentClient
|
||||
|
||||
Task ReannounceTorrents(bool? all = null, params string[] hashes);
|
||||
|
||||
Task AddTorrent(IEnumerable<string>? urls = null, Dictionary<string, Stream>? torrents = null, string? savePath = null, string? cookie = null, string? category = null, IEnumerable<string>? tags = null, bool? skipChecking = null, bool? paused = null, string? contentLayout = null, string? renameTorrent = null, long? uploadLimit = null, long? downloadLimit = null, float? ratioLimit = null, int? seedingTimeLimit = null, bool? autoTorrentManagement = null, bool? sequentialDownload = null, bool? firstLastPiecePriority = null);
|
||||
Task AddTorrent(AddTorrentParams addTorrentParams);
|
||||
|
||||
Task AddTrackersToTorrent(string hash, IEnumerable<string> urls);
|
||||
|
||||
@@ -116,9 +116,9 @@ namespace Lantean.QBitTorrentClient
|
||||
|
||||
Task DecreaseTorrentPriority(bool? all = null, params string[] hashes);
|
||||
|
||||
Task MaximalTorrentPriority(bool? all = null, params string[] hashes);
|
||||
Task MaxTorrentPriority(bool? all = null, params string[] hashes);
|
||||
|
||||
Task MinimalTorrentPriority(bool? all = null, params string[] hashes);
|
||||
Task MinTorrentPriority(bool? all = null, params string[] hashes);
|
||||
|
||||
Task SetFilePriority(string hash, IEnumerable<int> id, Priority priority);
|
||||
|
||||
|
||||
54
Lantean.QBitTorrentClient/Models/AddTorrentParams.cs
Normal file
54
Lantean.QBitTorrentClient/Models/AddTorrentParams.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
namespace Lantean.QBitTorrentClient.Models
|
||||
{
|
||||
public record AddTorrentParams
|
||||
{
|
||||
public IEnumerable<string>? Urls { get; set; }
|
||||
|
||||
public bool? SkipChecking { get; set; }
|
||||
|
||||
public bool? SequentialDownload { get; set; }
|
||||
|
||||
public bool? FirstLastPiecePriority { get; set; }
|
||||
|
||||
public bool? AddToTopOfQueue { get; set; }
|
||||
|
||||
// v4
|
||||
public bool? Paused { get; set; }
|
||||
// v5
|
||||
public bool? Stopped { get; set; }
|
||||
|
||||
public string? SavePath { get; set; }
|
||||
|
||||
public string? DownloadPath { get; set; }
|
||||
|
||||
public bool? UseDownloadPath { get; set; }
|
||||
|
||||
public string? Category { get; set; }
|
||||
|
||||
public IEnumerable<string>? Tags { get; set; }
|
||||
|
||||
public string? RenameTorrent { get; set; }
|
||||
|
||||
public long? UploadLimit { get; set; }
|
||||
|
||||
public long? DownloadLimit { get; set; }
|
||||
|
||||
public float? RatioLimit { get; set; }
|
||||
|
||||
public int? SeedingTimeLimit { get; set; }
|
||||
|
||||
public int? InactiveSeedingTimeLimit { get; set; }
|
||||
|
||||
public ShareLimitAction? ShareLimitAction { get; set; }
|
||||
|
||||
public bool? AutoTorrentManagement { get; set; }
|
||||
|
||||
public StopCondition? StopCondition { get; set; }
|
||||
|
||||
public TorrentContentLayout? ContentLayout { get; set; }
|
||||
|
||||
public string? Cookie { get; set; }
|
||||
|
||||
public Dictionary<string, Stream>? Torrents { get; set; }
|
||||
}
|
||||
}
|
||||
12
Lantean.QBitTorrentClient/Models/ShareLimitAction.cs
Normal file
12
Lantean.QBitTorrentClient/Models/ShareLimitAction.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Lantean.QBitTorrentClient.Models
|
||||
{
|
||||
public enum ShareLimitAction
|
||||
{
|
||||
Default = -1, // special value
|
||||
|
||||
Stop = 0,
|
||||
Remove = 1,
|
||||
RemoveWithContent = 3,
|
||||
EnableSuperSeeding = 2
|
||||
}
|
||||
}
|
||||
9
Lantean.QBitTorrentClient/Models/StopCondition.cs
Normal file
9
Lantean.QBitTorrentClient/Models/StopCondition.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Lantean.QBitTorrentClient.Models
|
||||
{
|
||||
public enum StopCondition
|
||||
{
|
||||
None = 0,
|
||||
MetadataReceived = 1,
|
||||
FilesChecked = 2
|
||||
}
|
||||
}
|
||||
9
Lantean.QBitTorrentClient/Models/TorrentContentLayout.cs
Normal file
9
Lantean.QBitTorrentClient/Models/TorrentContentLayout.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Lantean.QBitTorrentClient.Models
|
||||
{
|
||||
public enum TorrentContentLayout
|
||||
{
|
||||
Original,
|
||||
Subfolder,
|
||||
NoSubfolder
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,11 @@
|
||||
content.AddString(name, value.ToString());
|
||||
}
|
||||
|
||||
public static void AddString(this MultipartFormDataContent content, string name, Enum value)
|
||||
{
|
||||
content.AddString(name, value.ToString());
|
||||
}
|
||||
|
||||
public static void AddString(this MultipartFormDataContent content, string name, DateTimeOffset value, bool useSeconds = true)
|
||||
{
|
||||
content.AddString(name, useSeconds ? value.ToUnixTimeSeconds() : value.ToUnixTimeMilliseconds());
|
||||
|
||||
Reference in New Issue
Block a user