mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-02-05 05:08:55 -06:00
added InputDirectory, Zip node. Updated variables to use dotnotation
This commit is contained in:
Binary file not shown.
31
BasicNodes/File/InputDirectory.cs
Normal file
31
BasicNodes/File/InputDirectory.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
namespace FileFlows.BasicNodes.File
|
||||
{
|
||||
using System.ComponentModel;
|
||||
using FileFlows.Plugin;
|
||||
using FileFlows.Plugin.Attributes;
|
||||
|
||||
public class InputDirectory: Node
|
||||
{
|
||||
public override int Outputs => 1;
|
||||
public override FlowElementType Type => FlowElementType.Input;
|
||||
public override string Icon => "far fa-folder";
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
try
|
||||
{
|
||||
var info = new DirectoryInfo(args.WorkingFile);
|
||||
if (info.Exists == false)
|
||||
{
|
||||
args.Logger?.ELog("Directory not found: " + args.WorkingFile);
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
args.Logger?.ELog("Failed in InputDirectory: " + ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,5 +9,24 @@ namespace FileFlows.BasicNodes.File
|
||||
public override int Outputs => 1;
|
||||
public override FlowElementType Type => FlowElementType.Input;
|
||||
public override string Icon => "far fa-file";
|
||||
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileInfo fileInfo = new FileInfo(args.WorkingFile);
|
||||
if (fileInfo.Exists == false)
|
||||
{
|
||||
args.Logger?.ELog("File not found: " + args.WorkingFile);
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
args.Logger?.ELog("Failed in InputFile: " + ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ namespace FileFlows.BasicNodes.Functions
|
||||
using Jint;
|
||||
using System.Text;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public class Function : Node
|
||||
{
|
||||
@@ -38,6 +39,14 @@ namespace FileFlows.BasicNodes.Functions
|
||||
if(fileInfo.Exists)
|
||||
fileSize = fileInfo.Length;
|
||||
|
||||
// replace Variables. with dictionary notation
|
||||
string tcode = Code;
|
||||
foreach (string k in args.Variables.Keys.OrderByDescending(x => x.Length))
|
||||
{
|
||||
tcode = tcode.Replace("Variables." + k, "Variables['" + k + "']");
|
||||
}
|
||||
|
||||
|
||||
var sb = new StringBuilder();
|
||||
var log = new
|
||||
{
|
||||
@@ -56,7 +65,7 @@ namespace FileFlows.BasicNodes.Functions
|
||||
|
||||
try
|
||||
{
|
||||
var result = int.Parse(engine.Evaluate(Code).ToObject().ToString());
|
||||
var result = int.Parse(engine.Evaluate(tcode).ToObject().ToString());
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -65,5 +74,28 @@ namespace FileFlows.BasicNodes.Functions
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//private Dictionary<string, object> ExplodeVariables(Dictionary<string, object> input)
|
||||
//{
|
||||
// Dictionary<string, object> result = new();
|
||||
// foreach(var key in input.Keys)
|
||||
// {
|
||||
// if(key.IndexOf(".") > 0)
|
||||
// {
|
||||
// // folder.Date.Year
|
||||
// // folder.Date.Month
|
||||
// // folder.Date.Date
|
||||
// //bk = Date
|
||||
// string bk = key.Substring(0, key.IndexOf("."));
|
||||
// if(result.ContainsKey(bk) == false)
|
||||
// result.Add(bk, new Dictionary<string, object>());
|
||||
// Dictionary<string, object> bkdict = (Dictionary<string, object>)result[bk];
|
||||
// // nk = Year
|
||||
// string nk = key.Substring(key.IndexOf(".") + 1);
|
||||
// bkdict[]
|
||||
// }
|
||||
// }
|
||||
// return result;
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ namespace BasicNodes.Tests
|
||||
[TestInitialize]
|
||||
public void TestStarting()
|
||||
{
|
||||
Args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", new TestLogger());;
|
||||
Args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", new TestLogger(), false, string.Empty);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace BasicNodes.Tests
|
||||
[TestInitialize]
|
||||
public void TestStarting()
|
||||
{
|
||||
Args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", new TestLogger());
|
||||
Args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", new TestLogger(), false, string.Empty);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace BasicNodes.Tests
|
||||
[TestInitialize]
|
||||
public void TestStarting()
|
||||
{
|
||||
Args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", new TestLogger());
|
||||
Args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", new TestLogger(), false, string.Empty);
|
||||
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace BasicNodes.Tests
|
||||
{
|
||||
Function pm = new Function();
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", logger);
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", logger, false, string.Empty);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -75,7 +75,7 @@ return 0";
|
||||
{
|
||||
Function pm = new Function();
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", logger);
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", logger, false, string.Empty);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -93,7 +93,7 @@ return 0";
|
||||
{
|
||||
Function pm = new Function();
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", logger);
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", logger, false, string.Empty);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -111,7 +111,7 @@ return 0";
|
||||
{
|
||||
Function pm = new Function();
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", logger);
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", logger, false, string.Empty);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -126,6 +126,40 @@ return 0";
|
||||
Assert.AreEqual(1234d, args.Variables["NewItem"]);
|
||||
Assert.AreEqual(2001d, args.Variables["miYear"]);
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void Function_UseVariables_Date()
|
||||
{
|
||||
Function pm = new Function();
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", logger, false, string.Empty);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "folder.Date", new DateTime(2020, 03, 01) }
|
||||
};
|
||||
pm.Code = @"
|
||||
if(Variables.folder.Date.getFullYear() === 2020) return 1;
|
||||
return 2";
|
||||
var result = pm.Execute(args);
|
||||
Assert.AreEqual(1, result);
|
||||
}
|
||||
[TestMethod]
|
||||
public void Function_UseVariables_MultipelDot()
|
||||
{
|
||||
Function pm = new Function();
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", logger, false, string.Empty);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "folder.Date.Year", 2020 }
|
||||
};
|
||||
pm.Code = @"
|
||||
if(Variables.folder.Date.Year === 2020) return 1;
|
||||
return 2";
|
||||
var result = pm.Execute(args);
|
||||
Assert.AreEqual(1, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace BasicNodes.Tests
|
||||
{
|
||||
PatternMatch pm = new PatternMatch();
|
||||
pm.Pattern = @"\.mkv$";
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", new TestLogger(), false, string.Empty);
|
||||
args.SetWorkingFile($@"c:\temp\{Guid.NewGuid().ToString()}.mkv", dontDelete: true);
|
||||
|
||||
var result = pm.Execute(args);
|
||||
@@ -25,7 +25,7 @@ namespace BasicNodes.Tests
|
||||
{
|
||||
PatternMatch pm = new PatternMatch();
|
||||
pm.Pattern = @"\.mkv$";
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.avi", new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.avi", new TestLogger(), false, string.Empty);
|
||||
args.SetWorkingFile($@"c:\temp\{Guid.NewGuid().ToString()}.avi", dontDelete: true);
|
||||
|
||||
var result = pm.Execute(args);
|
||||
@@ -37,7 +37,7 @@ namespace BasicNodes.Tests
|
||||
{
|
||||
PatternMatch pm = new PatternMatch();
|
||||
pm.Pattern = @"[-$";
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.avi", new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.avi", new TestLogger(), false, string.Empty);
|
||||
args.SetWorkingFile($@"c:\temp\{Guid.NewGuid().ToString()}.avi", dontDelete: true);
|
||||
|
||||
var result = pm.Execute(args);
|
||||
@@ -48,7 +48,7 @@ namespace BasicNodes.Tests
|
||||
{
|
||||
PatternMatch pm = new PatternMatch();
|
||||
pm.Pattern = @"\-trailer";
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile-TRAILER.avi", new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile-TRAILER.avi", new TestLogger(), false, string.Empty);
|
||||
args.SetWorkingFile($@"c:\temp\{Guid.NewGuid().ToString()}.avi", dontDelete: true);
|
||||
|
||||
var result = pm.Execute(args);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace BasicNodes.Tests
|
||||
new KeyValuePair<string, string>("Seinfeld", "Batman")
|
||||
};
|
||||
node.UnitTest = true;
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Seinfeld.mkv", new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Seinfeld.mkv", new TestLogger(), false, string.Empty);
|
||||
|
||||
var result = node.Execute(args);
|
||||
Assert.AreEqual(1, result);
|
||||
@@ -34,7 +34,7 @@ namespace BasicNodes.Tests
|
||||
new KeyValuePair<string, string>(@"0([1-9]+x[\d]+)", "$1"),
|
||||
};
|
||||
node.UnitTest = true;
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Seinfeld S03E06.mkv", new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Seinfeld S03E06.mkv", new TestLogger(), false, string.Empty);
|
||||
|
||||
var result = node.Execute(args);
|
||||
Assert.AreEqual(1, result);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace BasicNodes.Tests
|
||||
public void Renamer_Extension()
|
||||
{
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger);
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger, false, string.Empty);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -36,7 +36,7 @@ namespace BasicNodes.Tests
|
||||
public void Renamer_Extension_DoubleDot()
|
||||
{
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger);
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger, false, string.Empty);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -61,7 +61,7 @@ namespace BasicNodes.Tests
|
||||
public void Renamer_Empty_SquareBrackets()
|
||||
{
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger);
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger, false, string.Empty);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -85,7 +85,7 @@ namespace BasicNodes.Tests
|
||||
public void Renamer_Empty_RoundBrackets()
|
||||
{
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger);
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger, false, string.Empty);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -108,7 +108,7 @@ namespace BasicNodes.Tests
|
||||
public void Renamer_Empty_SquareBrackets_Extension()
|
||||
{
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger);
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger, false, string.Empty);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Ghostbusters" },
|
||||
@@ -133,7 +133,7 @@ namespace BasicNodes.Tests
|
||||
public void Renamer_Colon()
|
||||
{
|
||||
var logger = new TestLogger();
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger);
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger, false, string.Empty);
|
||||
args.Variables = new Dictionary<string, object>
|
||||
{
|
||||
{ "miTitle", "Batman Unlimited: Mech vs Mutants" },
|
||||
|
||||
147
BasicNodes/Tools/Zip.cs
Normal file
147
BasicNodes/Tools/Zip.cs
Normal file
@@ -0,0 +1,147 @@
|
||||
namespace FileFlows.BasicNodes.File
|
||||
{
|
||||
using FileFlows.Plugin;
|
||||
using FileFlows.Plugin.Attributes;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.IO.Compression;
|
||||
|
||||
|
||||
public class Zip : Node
|
||||
{
|
||||
public override int Inputs => 1;
|
||||
public override int Outputs => 1;
|
||||
public override FlowElementType Type => FlowElementType.Process;
|
||||
public override string Icon => "fas fa-file-archive";
|
||||
private string _DestinationPath = string.Empty;
|
||||
private string _DestinationFile = string.Empty;
|
||||
|
||||
[Folder(1)]
|
||||
public string DestinationPath
|
||||
{
|
||||
get => _DestinationPath;
|
||||
set { _DestinationPath = value ?? ""; }
|
||||
}
|
||||
|
||||
[TextVariable(2)]
|
||||
public string DestinationFile
|
||||
{
|
||||
get => _DestinationFile;
|
||||
set { _DestinationFile = value ?? ""; }
|
||||
}
|
||||
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
bool isDir = false;
|
||||
|
||||
try
|
||||
{
|
||||
if (System.IO.Directory.Exists(args.WorkingFile))
|
||||
{
|
||||
isDir = true;
|
||||
}
|
||||
else if (System.IO.File.Exists(args.WorkingFile) == false)
|
||||
{
|
||||
args.Logger?.ELog("File or folder does not exist: " + args.WorkingFile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
string destDir = DestinationPath;
|
||||
if (string.IsNullOrEmpty(destDir))
|
||||
{
|
||||
if (isDir)
|
||||
destDir = new DirectoryInfo(args.LibraryPath).FullName;
|
||||
else
|
||||
destDir = new FileInfo(args.FileName)?.DirectoryName ?? String.Empty;
|
||||
if (string.IsNullOrEmpty(destDir))
|
||||
{
|
||||
args.Logger?.ELog("Failed to get destination directory");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// incase they set a linux path on windows or vice versa
|
||||
destDir = destDir.Replace('\\', Path.DirectorySeparatorChar);
|
||||
destDir = destDir.Replace('/', Path.DirectorySeparatorChar);
|
||||
|
||||
destDir = args.ReplaceVariables(destDir, stripMissing: true);
|
||||
|
||||
// this converts it to the actual OS path
|
||||
destDir = new FileInfo(destDir).DirectoryName!;
|
||||
args.CreateDirectoryIfNotExists(destDir);
|
||||
}
|
||||
|
||||
string destFile = args.ReplaceVariables(DestinationFile ?? string.Empty, true);
|
||||
if (string.IsNullOrEmpty(destFile))
|
||||
{
|
||||
if (isDir)
|
||||
destFile = new DirectoryInfo(args.FileName).Name + ".zip";
|
||||
else
|
||||
destFile = new FileInfo(args.FileName).Name + ".zip";
|
||||
}
|
||||
if (destFile.ToLower().EndsWith(".zip") == false)
|
||||
destFile += ".zip";
|
||||
destFile = Path.Combine(destDir, destFile);
|
||||
|
||||
args.Logger?.ILog($"Compressing '{args.WorkingFile}' to '{destFile}'");
|
||||
if (isDir)
|
||||
{
|
||||
var dir = new DirectoryInfo(args.WorkingFile);
|
||||
var files = dir.GetFiles("*.*", SearchOption.AllDirectories);
|
||||
using (FileStream fs = new FileStream(destFile, FileMode.Create))
|
||||
{
|
||||
using (ZipArchive arch = new ZipArchive(fs, ZipArchiveMode.Create))
|
||||
{
|
||||
args?.PartPercentageUpdate(0);
|
||||
float current= 0;
|
||||
float count = files.Length;
|
||||
foreach(var file in files)
|
||||
{
|
||||
++count;
|
||||
if (file.FullName.ToLower() == destFile.ToLower())
|
||||
continue; // cant zip the zip we are creating
|
||||
string relative = file.FullName.Substring(dir.FullName.Length + 1);
|
||||
try
|
||||
{
|
||||
arch.CreateEntryFromFile(file.FullName, relative, CompressionLevel.SmallestSize);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
args.Logger?.WLog("Failed to add file to zip: " + file.FullName + " => " + ex.Message);
|
||||
}
|
||||
args?.PartPercentageUpdate((current / count) * 100);
|
||||
}
|
||||
args?.PartPercentageUpdate(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (FileStream fs = new FileStream(destFile, FileMode.Create))
|
||||
{
|
||||
using (ZipArchive arch = new ZipArchive(fs, ZipArchiveMode.Create))
|
||||
{
|
||||
arch.CreateEntryFromFile(args.WorkingFile, new FileInfo(args.FileName).Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (System.IO.File.Exists(destFile))
|
||||
{
|
||||
args.SetWorkingFile(destFile);
|
||||
args.Logger?.ILog("Zip created at: " + destFile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
args.Logger?.ELog("Failed to create zip: " + destFile);
|
||||
return -1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
args.Logger?.ELog("Failed creating zip: " + ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -12,7 +12,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_File_Ghostbusters()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Ghostbusters 1984.mkv", new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Ghostbusters 1984.mkv", new TestLogger(), false, string.Empty);
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = false;
|
||||
@@ -31,7 +31,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_File_Ghostbusters2()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Ghostbusters 2.mkv", new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Ghostbusters 2.mkv", new TestLogger(), false, string.Empty);
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = false;
|
||||
@@ -50,7 +50,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_File_WithDots()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back.To.The.Future.2.mkv", new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back.To.The.Future.2.mkv", new TestLogger(), false, string.Empty);
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = false;
|
||||
@@ -69,7 +69,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_File_WithYear()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back.To.The.Future.1989.mkv", new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back.To.The.Future.1989.mkv", new TestLogger(), false, string.Empty);
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = false;
|
||||
@@ -88,7 +88,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_Folder_WithYear()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back To The Future (1989)\Jaws.mkv", new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back To The Future (1989)\Jaws.mkv", new TestLogger(), false, string.Empty);
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = true;
|
||||
@@ -107,7 +107,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_VariablesSet()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back To The Future (1989)\Jaws.mkv", new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Back To The Future (1989)\Jaws.mkv", new TestLogger(), false, string.Empty);
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = true;
|
||||
@@ -123,7 +123,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_NoMatchNoVariables()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\sdfsdfdsvfdcxdsf.mkv", new TestLogger(), false, string.Empty);
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = false;
|
||||
@@ -138,7 +138,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_ComplexFile()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Constantine.2005.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}\Constantine.2005.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}.mkv", new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Constantine.2005.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}\Constantine.2005.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}.mkv", new TestLogger(), false, string.Empty);
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = false;
|
||||
@@ -157,7 +157,7 @@ namespace MetaNodes.Tests.TheMovieDb
|
||||
[TestMethod]
|
||||
public void MovieLookupTests_WonderWoman()
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Wonder.Woman.1984.2020.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}\Wonder.Woman.1984.2020.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}.mkv", new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(@"c:\test\Wonder.Woman.1984.2020.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}\Wonder.Woman.1984.2020.German.DL.AC3.1080p.BluRay.x265-Fun{{fdg$ERGESDG32fesdfgds}}.mkv", new TestLogger(), false, string.Empty);
|
||||
|
||||
MovieLookup ml = new MovieLookup();
|
||||
ml.UseFolderName = false;
|
||||
|
||||
@@ -15,13 +15,13 @@ namespace FileFlows.VideoNodes
|
||||
{
|
||||
_Variables = new Dictionary<string, object>()
|
||||
{
|
||||
{ "viVideoCodec", "hevc" },
|
||||
{ "viAudioCodec", "ac3" },
|
||||
{ "viAudioCodecs", "ac3,aac"},
|
||||
{ "viAudioLanguage", "eng" },
|
||||
{ "viAudioLanguages", "eng, mao" },
|
||||
{ "viResolution", "1080p" },
|
||||
{ "viDuration", 1800 },
|
||||
{ "vi.Video.Codec", "hevc" },
|
||||
{ "vi.Audio.Codec", "ac3" },
|
||||
{ "vi.Audio.Codecs", "ac3,aac"},
|
||||
{ "vi.Audio.Language", "eng" },
|
||||
{ "vi.Audio.Languages", "eng, mao" },
|
||||
{ "vi.Resolution", "1080p" },
|
||||
{ "vi.Duration", 1800 },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace VideoNodes.Tests
|
||||
{
|
||||
"subrip", "srt"
|
||||
};
|
||||
var args = new FileFlows.Plugin.NodeParameters(file, new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(file, new TestLogger(), false, string.Empty);
|
||||
args.GetToolPath = (string tool) => @"C:\utils\ffmpeg\ffmpeg.exe";
|
||||
args.TempPath = @"D:\videos\temp";
|
||||
|
||||
@@ -48,25 +48,28 @@ namespace VideoNodes.Tests
|
||||
[TestMethod]
|
||||
public void VideoInfoTest_DetectBlackBars()
|
||||
{
|
||||
const string file = @"D:\videos\unprocessed\The Witcher - S02E05 - Turn Your Back.mkv";
|
||||
var vi = new VideoInfoHelper(@"C:\utils\ffmpeg\ffmpeg.exe", new TestLogger());
|
||||
vi.Read(@"D:\videos\unprocessed\Bourne.mkv");
|
||||
//const string file = @"D:\videos\unprocessed\The Witcher - S02E05 - Turn Your Back.mkv";
|
||||
//const string file = @"D:\videos\unprocessed\Hawkeye (2021) - S01E05 - Ronin.mkv";
|
||||
const string file = @"\\ORACLE\tv\Dexter - New Blood\Season 1\Dexter - New Blood - S01E07 - Skin of Her Teeth.mkv";
|
||||
//var vi = new VideoInfoHelper(@"C:\utils\ffmpeg\ffmpeg.exe", new TestLogger(), false, string.Empty);
|
||||
//vi.Read(@"D:\videos\unprocessed\Bourne.mkv");
|
||||
|
||||
var args = new FileFlows.Plugin.NodeParameters(file, new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(file, new TestLogger(), false, string.Empty);
|
||||
args.GetToolPath = (string tool) => @"C:\utils\ffmpeg\ffmpeg.exe";
|
||||
args.TempPath = @"D:\videos\temp";
|
||||
|
||||
int result = new DetectBlackBars().Execute(args);
|
||||
|
||||
Assert.IsTrue(result > 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void VideoInfoTest_NvidiaCard()
|
||||
{
|
||||
const string file = @"D:\videos\unprocessed\Bourne.mkv";
|
||||
const string ffmpeg = @"C:\utils\ffmpeg\ffmpeg.exe";
|
||||
var args = new FileFlows.Plugin.NodeParameters(file, new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(file, new TestLogger(), false, string.Empty);
|
||||
//args.Process = new FileFlows.Plugin.ProcessHelper(args.Logger);
|
||||
|
||||
var node = new VideoEncode();
|
||||
@@ -80,7 +83,7 @@ namespace VideoNodes.Tests
|
||||
{
|
||||
const string file = @"D:\videos\unprocessed\Bourne.mkv";
|
||||
const string ffmpeg = @"C:\utils\ffmpeg\ffmpeg.exe";
|
||||
var args = new FileFlows.Plugin.NodeParameters(file, new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(file, new TestLogger(), false, string.Empty);
|
||||
//args.Process = new FileFlows.Plugin.ProcessHelper(args.Logger);
|
||||
|
||||
var node = new VideoEncode();
|
||||
@@ -94,7 +97,7 @@ namespace VideoNodes.Tests
|
||||
{
|
||||
const string file = @"D:\videos\unprocessed\Bourne.mkv";
|
||||
const string ffmpeg = @"C:\utils\ffmpeg\ffmpeg.exe";
|
||||
var args = new FileFlows.Plugin.NodeParameters(file, new TestLogger());
|
||||
var args = new FileFlows.Plugin.NodeParameters(file, new TestLogger(), false, string.Empty);
|
||||
//args.Process = new FileFlows.Plugin.ProcessHelper(args.Logger);
|
||||
|
||||
var node = new VideoEncode();
|
||||
|
||||
Binary file not shown.
@@ -74,31 +74,31 @@ namespace FileFlows.VideoNodes
|
||||
else
|
||||
args.Parameters.Add(VIDEO_INFO, videoInfo);
|
||||
|
||||
variables.AddOrUpdate("viDuration", videoInfo.VideoStreams[0].Duration.TotalSeconds);
|
||||
variables.AddOrUpdate("viVideoCodec", videoInfo.VideoStreams[0].Codec);
|
||||
variables.AddOrUpdate("vi.Duration", videoInfo.VideoStreams[0].Duration.TotalSeconds);
|
||||
variables.AddOrUpdate("vi.Video.Codec", videoInfo.VideoStreams[0].Codec);
|
||||
if (videoInfo.AudioStreams?.Any() == true)
|
||||
{
|
||||
;
|
||||
if (string.IsNullOrEmpty(videoInfo.AudioStreams[0].Codec))
|
||||
Variables.AddOrUpdate("viAudioCodec", videoInfo.AudioStreams[0].Codec);
|
||||
Variables.AddOrUpdate("vi.Audio.Codec", videoInfo.AudioStreams[0].Codec);
|
||||
if (string.IsNullOrEmpty(videoInfo.AudioStreams[0].Codec))
|
||||
Variables.AddOrUpdate("viAudioChannels", videoInfo.AudioStreams[0].Channels);
|
||||
Variables.AddOrUpdate("vi.Audio.Channels", videoInfo.AudioStreams[0].Channels);
|
||||
if (string.IsNullOrEmpty(videoInfo.AudioStreams[0].Language))
|
||||
Variables.AddOrUpdate("viAudioLanguage", videoInfo.AudioStreams[0].Language);
|
||||
Variables.AddOrUpdate("viAudioCodecs", string.Join(", ", videoInfo.AudioStreams.Select(x => x.Codec).Where(x => string.IsNullOrEmpty(x) == false)));
|
||||
Variables.AddOrUpdate("viAudioLanguages", string.Join(", ", videoInfo.AudioStreams.Select(x => x.Language).Where(x => string.IsNullOrEmpty(x) == false)));
|
||||
Variables.AddOrUpdate("vi.Audio.Language", videoInfo.AudioStreams[0].Language);
|
||||
Variables.AddOrUpdate("vi.Audio.Codecs", string.Join(", ", videoInfo.AudioStreams.Select(x => x.Codec).Where(x => string.IsNullOrEmpty(x) == false)));
|
||||
Variables.AddOrUpdate("vi.Audio.Languages", string.Join(", ", videoInfo.AudioStreams.Select(x => x.Language).Where(x => string.IsNullOrEmpty(x) == false)));
|
||||
}
|
||||
|
||||
if (videoInfo.VideoStreams[0].Width == 1920)
|
||||
Variables.AddOrUpdate("viResolution", "1080");
|
||||
Variables.AddOrUpdate("vi.Resolution", "1080");
|
||||
else if (videoInfo.VideoStreams[0].Width == 3840)
|
||||
Variables.AddOrUpdate("viResolution", "4l");
|
||||
Variables.AddOrUpdate("vi.Resolution", "4l");
|
||||
else if (videoInfo.VideoStreams[0].Width == 1280)
|
||||
Variables.AddOrUpdate("viResolution", "720p");
|
||||
Variables.AddOrUpdate("vi.Resolution", "720p");
|
||||
else if (videoInfo.VideoStreams[0].Width < 1280)
|
||||
Variables.AddOrUpdate("viResolution", "SD");
|
||||
Variables.AddOrUpdate("vi.Resolution", "SD");
|
||||
else
|
||||
Variables.AddOrUpdate("viResolution", videoInfo.VideoStreams[0].Width + "x" + videoInfo.VideoStreams[0].Height);
|
||||
Variables.AddOrUpdate("vi.Resolution", videoInfo.VideoStreams[0].Width + "x" + videoInfo.VideoStreams[0].Height);
|
||||
|
||||
args.UpdateVariables(variables);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
[
|
||||
{
|
||||
"Name": "BasicNodes",
|
||||
"Version": "0.0.1.34",
|
||||
"Version": "0.0.1.40",
|
||||
"Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/BasicNodes.zip?raw=true"
|
||||
},
|
||||
{
|
||||
"Name": "MetaNodes",
|
||||
"Version": "0.0.1.34",
|
||||
"Version": "0.0.1.40",
|
||||
"Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/MetaNodes.zip?raw=true"
|
||||
},
|
||||
{
|
||||
"Name": "VideoNodes",
|
||||
"Version": "0.0.1.34",
|
||||
"Version": "0.0.1.40",
|
||||
"Package": "https://github.com/revenz/FileFlowsPlugins/blob/master/Builds/VideoNodes.zip?raw=true"
|
||||
}
|
||||
]
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user