[REFACTOR]

This commit is contained in:
max
2025-10-23 21:51:31 +02:00
parent 264be8d529
commit de28591d24
5 changed files with 9 additions and 11 deletions

View File

@@ -2,9 +2,10 @@
<MudNavMenu> <MudNavMenu>
<MudNavLink Href="/" Icon="@Icons.Material.Filled.Home" Match="NavLinkMatch.All">Home</MudNavLink> <MudNavLink Href="/" Icon="@Icons.Material.Filled.Home" Match="NavLinkMatch.All">Home</MudNavLink>
<MudNavGroup Title="Library" Expanded Icon="@Icons.Custom.Brands.YouTube" IconColor="Color.Error"> <MudNavGroup Title="Library" Expanded Icon="@Icons.Custom.Brands.YouTube" IconColor="Color.Error">
<MudNavLink Href="/Search" Icon="@Icons.Material.Filled.Search" Match="NavLinkMatch.All" Disabled>Search</MudNavLink>
<MudNavLink Href="/Accounts" Icon="@Icons.Material.Filled.AccountBox" Match="NavLinkMatch.All">Accounts</MudNavLink> <MudNavLink Href="/Accounts" Icon="@Icons.Material.Filled.AccountBox" Match="NavLinkMatch.All">Accounts</MudNavLink>
<MudNavLink Href="/Channels" Icon="@Icons.Material.Filled.AccountCircle" Match="NavLinkMatch.All">Channels</MudNavLink> <MudNavLink Href="/Channels" Icon="@Icons.Material.Filled.AccountCircle" Match="NavLinkMatch.All">Channels</MudNavLink>
<MudNavLink Href="/Playlists" Icon="@Icons.Material.Filled.ViewList" Match="NavLinkMatch.All">Playlists</MudNavLink> <MudNavLink Href="/Playlists" Icon="@Icons.Material.Filled.ViewList" Match="NavLinkMatch.All" Disabled>Playlists</MudNavLink>
<MudNavLink Href="/Library" Icon="@Icons.Material.Filled.Info" Match="NavLinkMatch.All" IconColor="Color.Info">Info</MudNavLink> <MudNavLink Href="/Library" Icon="@Icons.Material.Filled.Info" Match="NavLinkMatch.All" IconColor="Color.Info">Info</MudNavLink>
</MudNavGroup> </MudNavGroup>
<MudNavGroup Title="Application" Expanded Icon="@Icons.Material.Filled.SettingsSystemDaydream" IconColor="Color.Primary"> <MudNavGroup Title="Application" Expanded Icon="@Icons.Material.Filled.SettingsSystemDaydream" IconColor="Color.Primary">

View File

@@ -16,7 +16,6 @@ namespace Manager.App.Services;
public class LibraryService : ILibraryService public class LibraryService : ILibraryService
{ {
private readonly ILogger<LibraryService> _logger; private readonly ILogger<LibraryService> _logger;
private readonly LibrarySettings _librarySettings;
private readonly IDbContextFactory<LibraryDbContext> _dbContextFactory; private readonly IDbContextFactory<LibraryDbContext> _dbContextFactory;
private readonly DirectoryInfo _libraryDirectory; private readonly DirectoryInfo _libraryDirectory;
private readonly CacheService _cacheService; private readonly CacheService _cacheService;
@@ -24,13 +23,13 @@ public class LibraryService : ILibraryService
public LibraryService(ILogger<LibraryService> logger, IOptions<LibrarySettings> librarySettings, IDbContextFactory<LibraryDbContext> contextFactory, CacheService cacheService) public LibraryService(ILogger<LibraryService> logger, IOptions<LibrarySettings> librarySettings, IDbContextFactory<LibraryDbContext> contextFactory, CacheService cacheService)
{ {
_logger = logger; _logger = logger;
_librarySettings = librarySettings.Value; var librarySettings1 = librarySettings.Value;
_dbContextFactory = contextFactory; _dbContextFactory = contextFactory;
_cacheService = cacheService; _cacheService = cacheService;
_libraryDirectory = Directory.CreateDirectory(_librarySettings.Path); _libraryDirectory = Directory.CreateDirectory(librarySettings1.Path);
logger.LogDebug("Library directory: {LibraryWorkingDir}", _libraryDirectory.FullName); logger.LogDebug("Library directory: {LibraryWorkingDir}", _libraryDirectory.FullName);
Directory.CreateDirectory(Path.Combine(_librarySettings.Path, LibraryConstants.Directories.SubDirMedia)); Directory.CreateDirectory(Path.Combine(librarySettings1.Path, LibraryConstants.Directories.SubDirMedia));
Directory.CreateDirectory(Path.Combine(_librarySettings.Path, LibraryConstants.Directories.SubDirChannels)); Directory.CreateDirectory(Path.Combine(librarySettings1.Path, LibraryConstants.Directories.SubDirChannels));
} }
private async Task AddWebImagesAsync(LibraryDbContext context, List<WebImage> images, string foreignKey, string libSubDir, string fileType, string subDir) private async Task AddWebImagesAsync(LibraryDbContext context, List<WebImage> images, string foreignKey, string libSubDir, string fileType, string subDir)

View File

@@ -8,7 +8,6 @@ namespace Manager.YouTube.Util.Cipher;
public partial class CipherDecoder public partial class CipherDecoder
{ {
public required string Version { get; init; } public required string Version { get; init; }
public required string OriginalRelativeUrl { get; init; }
public readonly IReadOnlySet<ICipherOperation> Operations; public readonly IReadOnlySet<ICipherOperation> Operations;
private CipherDecoder(IEnumerable<ICipherOperation> operations) private CipherDecoder(IEnumerable<ICipherOperation> operations)
@@ -25,7 +24,6 @@ public partial class CipherDecoder
var operations = await GetCipherOperations(relativeUrl, client); var operations = await GetCipherOperations(relativeUrl, client);
var decoder = new CipherDecoder(operations) var decoder = new CipherDecoder(operations)
{ {
OriginalRelativeUrl = relativeUrl,
Version = version Version = version
}; };
return decoder; return decoder;

View File

@@ -9,7 +9,7 @@ public static class CipherManager
private static readonly CipherDecoderCollection LoadedCiphers = []; private static readonly CipherDecoderCollection LoadedCiphers = [];
private static readonly ILogger Logger = LogService.RegisterLogger(typeof(CipherManager)); private static readonly ILogger Logger = LogService.RegisterLogger(typeof(CipherManager));
public static async Task<Result<CipherDecoder>> GetDecoderAsync(ClientState clientState) public static async Task<Result<CipherDecoder>> GetDecoderAsync(ClientState clientState, YouTubeClient? client = null)
{ {
var relativePlayerJsUrl = clientState.PlayerJsUrl; var relativePlayerJsUrl = clientState.PlayerJsUrl;
if (string.IsNullOrEmpty(relativePlayerJsUrl)) if (string.IsNullOrEmpty(relativePlayerJsUrl))
@@ -26,7 +26,7 @@ public static class CipherManager
try try
{ {
var decoder = await CipherDecoder.CreateAsync(relativePlayerJsUrl, version); var decoder = await CipherDecoder.CreateAsync(relativePlayerJsUrl, version, client);
LoadedCiphers.Add(decoder); LoadedCiphers.Add(decoder);
} }
catch (Exception e) catch (Exception e)

View File

@@ -396,7 +396,7 @@ public sealed class YouTubeClient : IDisposable
return; return;
} }
var decipherDecoderResult = await CipherManager.GetDecoderAsync(state); var decipherDecoderResult = await CipherManager.GetDecoderAsync(state, this);
if (!decipherDecoderResult.IsSuccess) if (!decipherDecoderResult.IsSuccess)
{ {
_logger.Warning(decipherDecoderResult.Error?.Description ?? "Failed to get the cipher decoder!"); _logger.Warning(decipherDecoderResult.Error?.Description ?? "Failed to get the cipher decoder!");