[CHANGE] Reworked parsers/converters. Decipher operation from script do not work!
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
@using Manager.App.Models.System
|
||||
@using Manager.App.Services.System
|
||||
|
||||
@inject ISnackbar Snackbar
|
||||
@inject ClientService ClientService
|
||||
|
||||
<MudText>Video data</MudText>
|
||||
<MudStack 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>
|
||||
<MudTextField Label="Video id" @bind-Value="@_videoId"/>
|
||||
</MudStack>
|
||||
<MudStack>
|
||||
<MudButton OnClick="GetDataAsync">Get data</MudButton>
|
||||
</MudStack>
|
||||
@@ -0,0 +1,56 @@
|
||||
using Manager.App.Models.System;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Manager.App.Components.Application.Dev;
|
||||
|
||||
public partial class DevelopmentVideo : ComponentBase
|
||||
{
|
||||
private YouTubeClientItem? _selectedClient;
|
||||
private string _videoId = "";
|
||||
|
||||
private async Task<IEnumerable<YouTubeClientItem>> SearchClientsAsync(string? search, CancellationToken cancellationToken)
|
||||
{
|
||||
var searchResults = await ClientService.GetClientsAsync(search, cancellationToken: cancellationToken);
|
||||
return !searchResults.IsSuccess ? [] : searchResults.Value;
|
||||
}
|
||||
|
||||
private async Task GetDataAsync(MouseEventArgs obj)
|
||||
{
|
||||
if (_selectedClient == null)
|
||||
{
|
||||
Snackbar.Add("No client selected!", Severity.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(_videoId))
|
||||
{
|
||||
Snackbar.Add("No video ID set!", Severity.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_videoId.Length != 11)
|
||||
{
|
||||
Snackbar.Add("Video ID needs to have an length of 11 chars!", Severity.Warning);
|
||||
}
|
||||
|
||||
var clientResult = await ClientService.LoadClientByIdAsync(_selectedClient.Id);
|
||||
if (!clientResult.IsSuccess)
|
||||
{
|
||||
Snackbar.Add(clientResult.Error?.Description ?? $"Failed to get client with id: {_selectedClient.Id}", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
var ytClient = clientResult.Value;
|
||||
var videoResult = await ytClient.GetVideoByIdAsync(_videoId);
|
||||
if (!videoResult.IsSuccess)
|
||||
{
|
||||
Snackbar.Add(videoResult.Error?.Description ?? $"Failed to load video: {_videoId}", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
var ytVideo = videoResult.Value;
|
||||
Snackbar.Add($"Loaded video {ytVideo.Title}", Severity.Success);
|
||||
}
|
||||
}
|
||||
@@ -6,4 +6,7 @@
|
||||
<MudTabPanel Text="Authentication">
|
||||
<AuthenticationHasher />
|
||||
</MudTabPanel>
|
||||
<MudTabPanel Text="Video">
|
||||
<DevelopmentVideo />
|
||||
</MudTabPanel>
|
||||
</MudTabs>
|
||||
@@ -101,6 +101,7 @@ public class LibraryService : ILibraryService
|
||||
}
|
||||
else
|
||||
{
|
||||
context.HttpCookies.RemoveRange(context.HttpCookies.Where(x => x.ClientId == client.Id));
|
||||
context.ClientAccounts.Add(dbClient);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ClientService(IServiceScopeFactory scopeFactory, ILogger<ClientServ
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ListResult<YouTubeClientItem>> GetClientsAsync(string search, int offset = 0, int limit = 10, CancellationToken cancellationToken = default)
|
||||
public async Task<ListResult<YouTubeClientItem>> GetClientsAsync(string? search, int offset = 0, int limit = 10, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (_libraryService == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user