[CHANGE] Testing js runtime script
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user