From de28591d2425f2bb4373129ebe97820711de0f37 Mon Sep 17 00:00:00 2001 From: max Date: Thu, 23 Oct 2025 21:51:31 +0200 Subject: [PATCH] [REFACTOR] --- Manager.App/Components/Layout/NavMenu.razor | 3 ++- Manager.App/Services/LibraryService.cs | 9 ++++----- Manager.YouTube/Util/Cipher/CipherDecoder.cs | 2 -- Manager.YouTube/Util/Cipher/CipherManager.cs | 4 ++-- Manager.YouTube/YouTubeClient.cs | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Manager.App/Components/Layout/NavMenu.razor b/Manager.App/Components/Layout/NavMenu.razor index dd3ae86..b8a7d3d 100644 --- a/Manager.App/Components/Layout/NavMenu.razor +++ b/Manager.App/Components/Layout/NavMenu.razor @@ -2,9 +2,10 @@ Home + Search Accounts Channels - Playlists + Playlists Info diff --git a/Manager.App/Services/LibraryService.cs b/Manager.App/Services/LibraryService.cs index 30212b0..4e57e67 100644 --- a/Manager.App/Services/LibraryService.cs +++ b/Manager.App/Services/LibraryService.cs @@ -16,7 +16,6 @@ namespace Manager.App.Services; public class LibraryService : ILibraryService { private readonly ILogger _logger; - private readonly LibrarySettings _librarySettings; private readonly IDbContextFactory _dbContextFactory; private readonly DirectoryInfo _libraryDirectory; private readonly CacheService _cacheService; @@ -24,13 +23,13 @@ public class LibraryService : ILibraryService public LibraryService(ILogger logger, IOptions librarySettings, IDbContextFactory contextFactory, CacheService cacheService) { _logger = logger; - _librarySettings = librarySettings.Value; + var librarySettings1 = librarySettings.Value; _dbContextFactory = contextFactory; _cacheService = cacheService; - _libraryDirectory = Directory.CreateDirectory(_librarySettings.Path); + _libraryDirectory = Directory.CreateDirectory(librarySettings1.Path); logger.LogDebug("Library directory: {LibraryWorkingDir}", _libraryDirectory.FullName); - Directory.CreateDirectory(Path.Combine(_librarySettings.Path, LibraryConstants.Directories.SubDirMedia)); - Directory.CreateDirectory(Path.Combine(_librarySettings.Path, LibraryConstants.Directories.SubDirChannels)); + Directory.CreateDirectory(Path.Combine(librarySettings1.Path, LibraryConstants.Directories.SubDirMedia)); + Directory.CreateDirectory(Path.Combine(librarySettings1.Path, LibraryConstants.Directories.SubDirChannels)); } private async Task AddWebImagesAsync(LibraryDbContext context, List images, string foreignKey, string libSubDir, string fileType, string subDir) diff --git a/Manager.YouTube/Util/Cipher/CipherDecoder.cs b/Manager.YouTube/Util/Cipher/CipherDecoder.cs index 1dd39f3..b9c0663 100644 --- a/Manager.YouTube/Util/Cipher/CipherDecoder.cs +++ b/Manager.YouTube/Util/Cipher/CipherDecoder.cs @@ -8,7 +8,6 @@ namespace Manager.YouTube.Util.Cipher; public partial class CipherDecoder { public required string Version { get; init; } - public required string OriginalRelativeUrl { get; init; } public readonly IReadOnlySet Operations; private CipherDecoder(IEnumerable operations) @@ -25,7 +24,6 @@ public partial class CipherDecoder var operations = await GetCipherOperations(relativeUrl, client); var decoder = new CipherDecoder(operations) { - OriginalRelativeUrl = relativeUrl, Version = version }; return decoder; diff --git a/Manager.YouTube/Util/Cipher/CipherManager.cs b/Manager.YouTube/Util/Cipher/CipherManager.cs index e4d2a99..5db1300 100644 --- a/Manager.YouTube/Util/Cipher/CipherManager.cs +++ b/Manager.YouTube/Util/Cipher/CipherManager.cs @@ -9,7 +9,7 @@ public static class CipherManager private static readonly CipherDecoderCollection LoadedCiphers = []; private static readonly ILogger Logger = LogService.RegisterLogger(typeof(CipherManager)); - public static async Task> GetDecoderAsync(ClientState clientState) + public static async Task> GetDecoderAsync(ClientState clientState, YouTubeClient? client = null) { var relativePlayerJsUrl = clientState.PlayerJsUrl; if (string.IsNullOrEmpty(relativePlayerJsUrl)) @@ -26,7 +26,7 @@ public static class CipherManager try { - var decoder = await CipherDecoder.CreateAsync(relativePlayerJsUrl, version); + var decoder = await CipherDecoder.CreateAsync(relativePlayerJsUrl, version, client); LoadedCiphers.Add(decoder); } catch (Exception e) diff --git a/Manager.YouTube/YouTubeClient.cs b/Manager.YouTube/YouTubeClient.cs index 0ec1704..f4c27d2 100644 --- a/Manager.YouTube/YouTubeClient.cs +++ b/Manager.YouTube/YouTubeClient.cs @@ -396,7 +396,7 @@ public sealed class YouTubeClient : IDisposable return; } - var decipherDecoderResult = await CipherManager.GetDecoderAsync(state); + var decipherDecoderResult = await CipherManager.GetDecoderAsync(state, this); if (!decipherDecoderResult.IsSuccess) { _logger.Warning(decipherDecoderResult.Error?.Description ?? "Failed to get the cipher decoder!");