From a849b7524dc4739373f50af7e61160f6e00b9b01 Mon Sep 17 00:00:00 2001 From: max Date: Sun, 2 Nov 2025 21:22:56 +0100 Subject: [PATCH] [CHANGE] Added video info page --- .../Application/Dev/DevelopmentVideo.razor | 1 + .../Application/Dev/DevelopmentVideo.razor.cs | 18 +- Manager.App/Components/Pages/Video.razor | 244 ++++++++++++++++++ Manager.App/Components/Pages/Video.razor.cs | 48 ++++ Manager.App/Services/System/ClientService.cs | 3 +- 5 files changed, 295 insertions(+), 19 deletions(-) create mode 100644 Manager.App/Components/Pages/Video.razor create mode 100644 Manager.App/Components/Pages/Video.razor.cs diff --git a/Manager.App/Components/Application/Dev/DevelopmentVideo.razor b/Manager.App/Components/Application/Dev/DevelopmentVideo.razor index 1495d71..6dae352 100644 --- a/Manager.App/Components/Application/Dev/DevelopmentVideo.razor +++ b/Manager.App/Components/Application/Dev/DevelopmentVideo.razor @@ -3,6 +3,7 @@ @inject ISnackbar Snackbar @inject ClientService ClientService +@inject NavigationManager NavigationManager Video data diff --git a/Manager.App/Components/Application/Dev/DevelopmentVideo.razor.cs b/Manager.App/Components/Application/Dev/DevelopmentVideo.razor.cs index 0fa7ca1..64ef2fb 100644 --- a/Manager.App/Components/Application/Dev/DevelopmentVideo.razor.cs +++ b/Manager.App/Components/Application/Dev/DevelopmentVideo.razor.cs @@ -35,22 +35,6 @@ public partial class DevelopmentVideo : ComponentBase 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); + NavigationManager.NavigateTo($"/video/{_videoId}?clientId={_selectedClient.Id}"); } } \ No newline at end of file diff --git a/Manager.App/Components/Pages/Video.razor b/Manager.App/Components/Pages/Video.razor new file mode 100644 index 0000000..6463efd --- /dev/null +++ b/Manager.App/Components/Pages/Video.razor @@ -0,0 +1,244 @@ +@page "/Video/{VideoId}" +@using Manager.App.Services.System + +@inject ISnackbar Snackbar +@inject ClientService ClientService +@inject CacheService Cache + + +@if (!_loading && _video != null) +{ + + + @{ + var thumbnailUrl = _video.Thumbnails.OrderByDescending(t => t.Width).FirstOrDefault()?.Url; + } + @if (!string.IsNullOrWhiteSpace(thumbnailUrl)) + { + + } + + @_video.Title + @_video.Description + + + + + + @* Info *@ + + + + Video ID: + @_video.VideoId + + + Title: + @_video.Title + + + Description: + @_video.Description + + + HashTags: + @foreach (var hashtag in _video.HashTags) + { + @hashtag + } + + + + View count: + @_video.ViewCount + + + Like count: + @_video.LikeCount + + + Channel ID: + @_video.ChannelId + + + Author: + @_video.Author + + + Playability status: + @_video.PlayabilityStatus + + + Length seconds: + @_video.LengthSeconds + + + Keywords: + @foreach (var keyword in _video.Keywords) + { + @keyword + } + + + + Publish date: + @_video.PublishDate + + + Upload date: + @_video.UploadDate + + + Category: + @_video.Category + + + + @* Boolean values *@ + + + + Is owner viewing: + @_video.IsOwnerViewing + + + Allow rating: + @_video.AllowRating + + + Is crawlable: + @_video.IsCrawlable + + + Is private: + @_video.IsPrivate + + + Is unplugged corpus: + @_video.IsUnpluggedCorpus + + + Is live: + @_video.IsLive + + + Is family save: + @_video.IsFamilySave + + + Is unlisted: + @_video.IsUnlisted + + + Has Ypc metadata: + @_video.HasYpcMetadata + + + Is shorts eligible: + @_video.IsShortsEligible + + + + + + + @if (_video.StreamingData == null) + { + No streaming data available! + } + else + { + + + Adaptive Formats + + + Id + Mime type + Bitrate + Resolution + Last modified (UNIX epoch) + Quality + FPS + + + @context.Itag + @context.MimeType + @context.Bitrate + @($"{context.Width}x{context.Height}") + @context.LastModified + @context.Quality + @context.Fps + + + + + Formats + + + Id + Mime type + Bitrate + Resolution + Last modified (UNIX epoch) + Quality + FPS + + + @context.Itag + @context.MimeType + @context.Bitrate + @($"{context.Width}x{context.Height}") + @context.LastModified + @context.Quality + @context.Fps + + + + + } + + + @if (_video.PlayerConfig == null) + { + No player config available! + } + else + { + + + + Audio loudness DB: + @_video.PlayerConfig.AudioLoudnessDb + + + Audio perceptual loudness DB: + @_video.PlayerConfig.AudioPerceptualLoudnessDb + + + Audio enable per format loudness: + @_video.PlayerConfig.AudioLoudnessDb + + + Max bitrate: + @_video.PlayerConfig.MaxBitrate + + + Max read ahead time MS: + @_video.PlayerConfig.MaxReadAheadMediaTimeMs + + + Min read ahead time MS: + @_video.PlayerConfig.MinReadAheadMediaTimeMs + + + Read ahead growth rate MS: + @_video.PlayerConfig.ReadAheadGrowthRateMs + + + + } + + + +} \ No newline at end of file diff --git a/Manager.App/Components/Pages/Video.razor.cs b/Manager.App/Components/Pages/Video.razor.cs new file mode 100644 index 0000000..92efa72 --- /dev/null +++ b/Manager.App/Components/Pages/Video.razor.cs @@ -0,0 +1,48 @@ +using Manager.YouTube.Models; +using Microsoft.AspNetCore.Components; +using MudBlazor; + +namespace Manager.App.Components.Pages; + +public partial class Video : ComponentBase +{ + [Parameter] + public required string VideoId { get; set; } + + [SupplyParameterFromQuery(Name = "clientId")] + public string ClientId { get; set; } = ""; + + private bool _loading = true; + private YouTubeVideo? _video; + + protected override async Task OnInitializedAsync() + { + if (string.IsNullOrEmpty(VideoId)) + { + Snackbar.Add("Video id is null or empty!", Severity.Error); + _loading = false; + return; + } + + var clientResult = await ClientService.LoadClientByIdAsync(ClientId); + if (!clientResult.IsSuccess) + { + Snackbar.Add(clientResult.Error?.Description ?? "Failed to load client!", Severity.Error); + _loading = false; + return; + } + + var client = clientResult.Value; + + var videoResult = await client.GetVideoByIdAsync(VideoId); + if (!videoResult.IsSuccess) + { + Snackbar.Add(videoResult.Error?.Description ?? "Failed to get video.", Severity.Error); + _loading = false; + return; + } + + _video = videoResult.Value; + _loading = false; + } +} \ No newline at end of file diff --git a/Manager.App/Services/System/ClientService.cs b/Manager.App/Services/System/ClientService.cs index aa6330e..2690b85 100644 --- a/Manager.App/Services/System/ClientService.cs +++ b/Manager.App/Services/System/ClientService.cs @@ -31,11 +31,10 @@ public class ClientService(IServiceScopeFactory scopeFactory, ILogger