[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

@@ -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<ICipherOperation> Operations;
private CipherDecoder(IEnumerable<ICipherOperation> 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;

View File

@@ -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<Result<CipherDecoder>> GetDecoderAsync(ClientState clientState)
public static async Task<Result<CipherDecoder>> 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)

View File

@@ -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!");