[CHANGE] Testing js runtime script

This commit is contained in:
max
2025-11-02 00:02:09 +01:00
parent 4c04378080
commit 16343c9a56
2 changed files with 18 additions and 7 deletions

View File

@@ -3,11 +3,11 @@ using DotBased.Monads;
namespace Manager.YouTube.Interpreter;
public class JavaScriptEngineManager
public static class JavaScriptEngineManager
{
private readonly PlayerEngineCollection _engines = [];
private static readonly PlayerEngineCollection Engines = [];
public async Task<Result<PlayerEngine>> GetPlayerEngine(string playerUrl)
public static async Task<Result<PlayerEngine>> GetPlayerEngine(string playerUrl)
{
if (string.IsNullOrEmpty(playerUrl))
{
@@ -16,7 +16,7 @@ public class JavaScriptEngineManager
var version = GetScriptVersion(playerUrl);
if (_engines.TryGetValue(version, out var engine))
if (Engines.TryGetValue(version, out var engine))
{
return engine;
}

View File

@@ -5,6 +5,7 @@ using System.Text.Json;
using System.Text.Json.Nodes;
using DotBased.Logging;
using DotBased.Monads;
using Manager.YouTube.Interpreter;
using Manager.YouTube.Models;
using Manager.YouTube.Models.Innertube;
using Manager.YouTube.Parsers;
@@ -402,7 +403,17 @@ public sealed class YouTubeClient : IDisposable
return;
}
var decipherDecoderResult = await CipherManager.GetDecoderAsync(state, this);
var jsEngineResult = await JavaScriptEngineManager.GetPlayerEngine(state.PlayerJsUrl ?? "");
if (!jsEngineResult.IsSuccess)
{
_logger.Warning(jsEngineResult.Error?.Description ?? "Failed to get player script engine.");
return;
}
var engine = jsEngineResult.Value;
engine.InitializePlayer();
/*var decipherDecoderResult = await CipherManager.GetDecoderAsync(state, this);
if (!decipherDecoderResult.IsSuccess)
{
_logger.Warning(decipherDecoderResult.Error?.Description ?? "Failed to get the cipher decoder!");
@@ -413,6 +424,6 @@ public sealed class YouTubeClient : IDisposable
foreach (var format in formatsWithCipher)
{
format.Url = decoder.Decipher(format.SignatureCipher);
}
}*/
}
}