diff --git a/BasicNodes/BasicNodes.csproj b/BasicNodes/BasicNodes.csproj index 3ff9b45c..904fa216 100644 Binary files a/BasicNodes/BasicNodes.csproj and b/BasicNodes/BasicNodes.csproj differ diff --git a/BasicNodes/File/InputDirectory.cs b/BasicNodes/File/InputDirectory.cs new file mode 100644 index 00000000..7a07b7eb --- /dev/null +++ b/BasicNodes/File/InputDirectory.cs @@ -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; + } + } + } +} \ No newline at end of file diff --git a/BasicNodes/File/InputFile.cs b/BasicNodes/File/InputFile.cs index 0561cca9..c1b6597f 100644 --- a/BasicNodes/File/InputFile.cs +++ b/BasicNodes/File/InputFile.cs @@ -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; + } + } } } \ No newline at end of file diff --git a/BasicNodes/Functions/Function.cs b/BasicNodes/Functions/Function.cs index d9f343c4..714e1c8d 100644 --- a/BasicNodes/Functions/Function.cs +++ b/BasicNodes/Functions/Function.cs @@ -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 ExplodeVariables(Dictionary input) + //{ + // Dictionary 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()); + // Dictionary bkdict = (Dictionary)result[bk]; + // // nk = Year + // string nk = key.Substring(key.IndexOf(".") + 1); + // bkdict[] + // } + // } + // return result; + //} } } \ No newline at end of file diff --git a/BasicNodes/Tests/FileExtensionTests.cs b/BasicNodes/Tests/FileExtensionTests.cs index c7e1e7a2..b686808b 100644 --- a/BasicNodes/Tests/FileExtensionTests.cs +++ b/BasicNodes/Tests/FileExtensionTests.cs @@ -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); } diff --git a/BasicNodes/Tests/FileSizeTests.cs b/BasicNodes/Tests/FileSizeTests.cs index 58cd22fd..0abb7ca8 100644 --- a/BasicNodes/Tests/FileSizeTests.cs +++ b/BasicNodes/Tests/FileSizeTests.cs @@ -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); } diff --git a/BasicNodes/Tests/FunctionTests.cs b/BasicNodes/Tests/FunctionTests.cs index d938fb16..98d46781 100644 --- a/BasicNodes/Tests/FunctionTests.cs +++ b/BasicNodes/Tests/FunctionTests.cs @@ -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 { { "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 { { "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 { { "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 { { "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 + { + { "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 + { + { "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); + } } } diff --git a/BasicNodes/Tests/PatternMatchTests.cs b/BasicNodes/Tests/PatternMatchTests.cs index 3a207fab..55e6162a 100644 --- a/BasicNodes/Tests/PatternMatchTests.cs +++ b/BasicNodes/Tests/PatternMatchTests.cs @@ -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); diff --git a/BasicNodes/Tests/PatternReplacerTests.cs b/BasicNodes/Tests/PatternReplacerTests.cs index 8de63484..ec6741b8 100644 --- a/BasicNodes/Tests/PatternReplacerTests.cs +++ b/BasicNodes/Tests/PatternReplacerTests.cs @@ -17,7 +17,7 @@ namespace BasicNodes.Tests new KeyValuePair("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(@"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); diff --git a/BasicNodes/Tests/RenamerTests.cs b/BasicNodes/Tests/RenamerTests.cs index ccf8779d..847b888b 100644 --- a/BasicNodes/Tests/RenamerTests.cs +++ b/BasicNodes/Tests/RenamerTests.cs @@ -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 { { "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 { { "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 { { "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 { { "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 { { "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 { { "miTitle", "Batman Unlimited: Mech vs Mutants" }, diff --git a/BasicNodes/Tools/Zip.cs b/BasicNodes/Tools/Zip.cs new file mode 100644 index 00000000..f9e70d28 --- /dev/null +++ b/BasicNodes/Tools/Zip.cs @@ -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; + } + } + } +} diff --git a/FileFlows.Plugin.dll b/FileFlows.Plugin.dll index 0917a19d..ece315dd 100644 Binary files a/FileFlows.Plugin.dll and b/FileFlows.Plugin.dll differ diff --git a/FileFlows.Plugin.pdb b/FileFlows.Plugin.pdb index 28e2ff63..44a54b71 100644 Binary files a/FileFlows.Plugin.pdb and b/FileFlows.Plugin.pdb differ diff --git a/MetaNodes/MetaNodes.csproj b/MetaNodes/MetaNodes.csproj index c1fe9c75..0a85bcae 100644 Binary files a/MetaNodes/MetaNodes.csproj and b/MetaNodes/MetaNodes.csproj differ diff --git a/MetaNodes/Tests/TheMovieDb/MovieLookupTests.cs b/MetaNodes/Tests/TheMovieDb/MovieLookupTests.cs index 409b3a46..cceb49d6 100644 --- a/MetaNodes/Tests/TheMovieDb/MovieLookupTests.cs +++ b/MetaNodes/Tests/TheMovieDb/MovieLookupTests.cs @@ -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; diff --git a/VideoNodes/InputNodes/VideoFile.cs b/VideoNodes/InputNodes/VideoFile.cs index 3cafd2f7..e6d3e1b9 100644 --- a/VideoNodes/InputNodes/VideoFile.cs +++ b/VideoNodes/InputNodes/VideoFile.cs @@ -15,13 +15,13 @@ namespace FileFlows.VideoNodes { _Variables = new Dictionary() { - { "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 }, }; } diff --git a/VideoNodes/Tests/VideoInfoHelperTests.cs b/VideoNodes/Tests/VideoInfoHelperTests.cs index 54ad2101..7907167e 100644 --- a/VideoNodes/Tests/VideoInfoHelperTests.cs +++ b/VideoNodes/Tests/VideoInfoHelperTests.cs @@ -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(); diff --git a/VideoNodes/VideoNodes.csproj b/VideoNodes/VideoNodes.csproj index c3102d87..0f8a1e27 100644 Binary files a/VideoNodes/VideoNodes.csproj and b/VideoNodes/VideoNodes.csproj differ diff --git a/VideoNodes/VideoNodes/VideoNode.cs b/VideoNodes/VideoNodes/VideoNode.cs index 3d6d0381..7b7dfc4a 100644 --- a/VideoNodes/VideoNodes/VideoNode.cs +++ b/VideoNodes/VideoNodes/VideoNode.cs @@ -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); } diff --git a/plugins.json b/plugins.json index 6fb22ad8..10f86b2a 100644 --- a/plugins.json +++ b/plugins.json @@ -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" } ] diff --git a/ref/FileFlows.Plugin.dll b/ref/FileFlows.Plugin.dll index 3ad80cec..8dd6ea93 100644 Binary files a/ref/FileFlows.Plugin.dll and b/ref/FileFlows.Plugin.dll differ