[CHANGE] Reworked cipher stuff
This commit is contained in:
13
Manager.App/Components/Application/Dev/CipherDev.razor
Normal file
13
Manager.App/Components/Application/Dev/CipherDev.razor
Normal file
@@ -0,0 +1,13 @@
|
||||
@using Manager.App.Models.System
|
||||
@using Manager.App.Services.System
|
||||
|
||||
@inject ISnackbar Snackbar
|
||||
@inject ClientService ClientService
|
||||
|
||||
<MudText>Cipher manager</MudText>
|
||||
<MudStack Row Spacing="2">
|
||||
<MudAutocomplete T="YouTubeClientItem" Label="Client" @bind-Value="@_selectedClient" SearchFunc="SearchClientsAsync" ToStringFunc="@(i => i == null ? "null?" : $"{i.Name} ({i.Handle})")"
|
||||
Variant="Variant.Outlined" ShowProgressIndicator ProgressIndicatorColor="Color.Primary">
|
||||
</MudAutocomplete>
|
||||
<MudButton OnClick="ExecCipher">Exec</MudButton>
|
||||
</MudStack>
|
||||
43
Manager.App/Components/Application/Dev/CipherDev.razor.cs
Normal file
43
Manager.App/Components/Application/Dev/CipherDev.razor.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Manager.App.Models.System;
|
||||
using Manager.YouTube.Util.Cipher;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Manager.App.Components.Application.Dev;
|
||||
|
||||
public partial class CipherDev : ComponentBase
|
||||
{
|
||||
private YouTubeClientItem? _selectedClient;
|
||||
|
||||
private async Task ExecCipher(MouseEventArgs obj)
|
||||
{
|
||||
if (_selectedClient == null)
|
||||
{
|
||||
Snackbar.Add("No client selected", Severity.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var ytClientResult = await ClientService.LoadClientByIdAsync(_selectedClient.Id);
|
||||
if (!ytClientResult.IsSuccess)
|
||||
{
|
||||
Snackbar.Add(ytClientResult.Error?.Description ?? "Failed to get the client!", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
var ytClient = ytClientResult.Value;
|
||||
if (ytClient.State == null)
|
||||
{
|
||||
Snackbar.Add("Client state is null!", Severity.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var decoder = await CipherManager.GetDecoderAsync(ytClient.State, ytClient);
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<YouTubeClientItem>> SearchClientsAsync(string? search, CancellationToken cancellationToken)
|
||||
{
|
||||
var searchResults = await ClientService.GetClientsAsync(search, cancellationToken: cancellationToken);
|
||||
return !searchResults.IsSuccess ? [] : searchResults.Value;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
@inject ClientService ClientService
|
||||
|
||||
<MudText>Video data</MudText>
|
||||
<MudStack Spacing="2">
|
||||
<MudStack Row Spacing="2">
|
||||
<MudAutocomplete T="YouTubeClientItem" Label="Client" @bind-Value="@_selectedClient" SearchFunc="SearchClientsAsync" ToStringFunc="@(i => i == null ? "null?" : $"{i.Name} ({i.Handle})")"
|
||||
Variant="Variant.Outlined" ShowProgressIndicator ProgressIndicatorColor="Color.Primary">
|
||||
</MudAutocomplete>
|
||||
|
||||
Reference in New Issue
Block a user