[CHANGE] Added jint. Reworking decipher functionality
This commit is contained in:
42
Manager.YouTube/Interpreter/PlayerEngine.cs
Normal file
42
Manager.YouTube/Interpreter/PlayerEngine.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using DotBased.Logging;
|
||||
using Jint;
|
||||
|
||||
namespace Manager.YouTube.Interpreter;
|
||||
|
||||
public class PlayerEngine
|
||||
{
|
||||
public string Version { get; set; }
|
||||
public Engine JsEngine { get; set; }
|
||||
private ILogger Logger { get; set; }
|
||||
|
||||
public PlayerEngine(string version, string script)
|
||||
{
|
||||
if (string.IsNullOrEmpty(version))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(version));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(script))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(script));
|
||||
}
|
||||
|
||||
Logger = LogService.RegisterLogger(typeof(PlayerEngine), version);
|
||||
Version = version;
|
||||
JsEngine = new Engine().Execute(script).SetValue("log", new Action<object>(obj =>
|
||||
{
|
||||
var logStr = obj.ToString();
|
||||
if (string.IsNullOrEmpty(logStr))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Logger.Information(logStr);
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
public void InitializePlayer()
|
||||
{
|
||||
JsEngine.Execute("createPlayer");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user