bat/c#/shell/ps1

This commit is contained in:
John Andrews
2024-08-05 09:19:16 +12:00
parent 9ad51503b8
commit e65c4d6113
8 changed files with 70 additions and 16 deletions
@@ -1,7 +1,5 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using BasicNodes.Scripting;
using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
@@ -10,12 +8,12 @@ namespace FileFlows.BasicNodes.Scripting;
/// <summary>
/// Flow element that executes a bat script
/// </summary>
public class BatScript : ScriptBase
public class BatchScript : ScriptBase
{
/// <inheritdoc />
public override string Icon => "svg:dos";
/// <inheritdoc />
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/bat-script";
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/scripting/batch-script";
/// <inheritdoc />
protected override ScriptLanguage Language => ScriptLanguage.Batch;
+4 -1
View File
@@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations;
using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
namespace BasicNodes.Scripting;
namespace FileFlows.BasicNodes.Scripting;
/// <summary>
/// Flow element that executes a CSharp script
@@ -19,6 +19,9 @@ public class CSharpScript : ScriptBase
/// <inheritdoc />
protected override ScriptLanguage Language => ScriptLanguage.CSharp;
/// <inheritdoc />
public override string Group => "Scripting:1";
/// <summary>
/// Gets or sets the code to execute
/// </summary>
+3 -3
View File
@@ -19,10 +19,10 @@ public class Function : Node
/// <inheritdoc />
public override bool FailureNode => true;
/// <inheritdoc />
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/function";
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/scripting/function";
/// <inheritdoc />
public override string Group => "Scripting";
public override string Group => "Scripting:0";
/// <summary>
/// Gets or sets the number of outputs
/// </summary>
-2
View File
@@ -1,7 +1,5 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using BasicNodes.Scripting;
using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
+2 -1
View File
@@ -2,7 +2,7 @@ using System.ComponentModel;
using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
namespace BasicNodes.Scripting;
namespace FileFlows.BasicNodes.Scripting;
/// <summary>
/// Base for a script
@@ -46,6 +46,7 @@ public abstract class ScriptBase : Node
var result = args.ScriptExecutor.Execute(new()
{
Args = args,
Logger = args.Logger,
Code = Language is ScriptLanguage.CSharp or ScriptLanguage.JavaScript ? Code : args.ReplaceVariables(Code),
ScriptType = ScriptType.Flow,
Language = Language
-1
View File
@@ -1,6 +1,5 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using BasicNodes.Scripting;
using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
+5 -4
View File
@@ -21,8 +21,8 @@
"1": "Library Folder"
}
},
"BatScript": {
"Label": "Batch (.bat)",
"BatchScript": {
"Label": "Batch Script (.bat)",
"Description": "Allows you to execute a batch (.bat) script in a Windows environment.",
"Outputs": {
"1": "returned 1",
@@ -60,7 +60,7 @@
}
},
"ShellScript": {
"Label": "Shell (.sh))",
"Label": "Shell Script (.sh)",
"Description": "Allows you to execute a shell (.sh) script in a Unix-like environment.",
"Outputs": {
"1": "returned 1",
@@ -79,7 +79,7 @@
}
},
"PowerShellScript": {
"Label": "PowerShell (.ps1)",
"Label": "PowerShell Script (.ps1)",
"Description": "Allows you to execute a PowerShell (.ps1) script in a Windows environment.",
"Outputs": {
"1": "returned 1",
@@ -286,6 +286,7 @@
}
},
"Function": {
"Label": "Function",
"Outputs": {
"1": "returned 1",
"2": "returned 2",
+54
View File
@@ -186,6 +186,60 @@ namespace FileFlows.VideoNodes
args.SetMetadata(metadata);
}
private int Test(ILogger Logger)
{
var MAX_BITRATE = 3_000_000; // bitrate is 3,000 KBps
if(Variables.TryGetValue("vi.VideoInfo", out var oVideoInfo) == false || oVideoInfo is FileFlows.VideoNodes.VideoInfo videoInfo == false)
{
Logger.ILog("Failed to locate VideoInformation in variables");
return -1;
}
Logger.ILog("Got video information.");
var video = videoInfo.VideoStreams.FirstOrDefault();
if(video == null)
{
Logger.ILog("No video streams detected.");
return -1;
}
// get the video stream
var bitrate = video.Bitrate;
if(bitrate < 1)
{
// video stream doesn't have bitrate information
// need to use the overall bitrate
var overall = videoInfo.Bitrate;
if(overall < 1)
return 0; // couldn't get overall bitrate either
// overall bitrate includes all audio streams, so we try and subtract those
var calculated = overall;
if(videoInfo.AudioStreams.Count > 0) // check there are audio streams
{
foreach(var audio in videoInfo.AudioStreams)
{
if(audio.Bitrate > 0)
calculated -= audio.Bitrate;
else{
// audio doesn't have bitrate either, so we just subtract 5% of the original bitrate
// this is a guess, but it should get us close
calculated -= (overall * 0.05f);
}
}
}
bitrate = calculated;
}
// check if the bitrate is over the maximum bitrate
if(bitrate > MAX_BITRATE)
return 1; // it is, so call output 1
return 2; // it isn't so call output 2
}
protected VideoInfo GetVideoInfo(NodeParameters args, bool refreshIfFileChanged = true)
{
var vi = GetVideoInfoActual(args);