FF-1680: New flow elements for file/folder dates

This commit is contained in:
John Andrews
2024-07-21 15:57:16 +12:00
parent 7e13545972
commit 28513001da
11 changed files with 89 additions and 15 deletions

View File

@@ -137,6 +137,16 @@ public class LocalFileService : IFileService
}
}
public Result<DateTime> DirectoryCreationTimeUtc(string path)
{
throw new NotImplementedException();
}
public Result<DateTime> DirectoryLastWriteTimeUtc(string path)
{
throw new NotImplementedException();
}
public Result<bool> FileExists(string path)
{
if (IsProtectedPath(ref path))

View File

@@ -138,12 +138,15 @@ public class DirectoryDateCompare : Node
}
// then it must be a between or not between
var minutes = now.Subtract(date).TotalMinutes;
int low = Math.Min(DateComparision.Value1, DateComparision.Value2);
int high = Math.Max(DateComparision.Value1, DateComparision.Value2);
bool isBetween = minutes >= low && minutes <= high;
int high = Math.Max(DateComparision.Value1, DateComparision.Value2);
DateTime lowDate = now.AddMinutes(-low);
DateTime highDate = now.AddMinutes(-high);
bool isBetween = now >= lowDate && now <= highDate;
args.Logger?.ILog(
$"Date is {(isBetween ? "" : "not ")}between {low} minutes and {high} minutes");
$"Date is {(isBetween ? "" : "not ")}between {lowDate:yyyy-MM-ddTHH:mm:ss}Z and {highDate:yyyy-MM-ddTHH:mm:ss}Z");
if (DateComparision.Comparison is DateCompareMode.Between)
{

View File

@@ -134,12 +134,15 @@ public class FileDateCompare : Node
}
// then it must be a between or not between
var minutes = now.Subtract(date).TotalMinutes;
int low = Math.Min(DateComparision.Value1, DateComparision.Value2);
int high = Math.Max(DateComparision.Value1, DateComparision.Value2);
bool isBetween = minutes >= low && minutes <= high;
int high = Math.Max(DateComparision.Value1, DateComparision.Value2);
DateTime lowDate = now.AddMinutes(-low);
DateTime highDate = now.AddMinutes(-high);
bool isBetween = now >= lowDate && now <= highDate;
args.Logger?.ILog(
$"Date is {(isBetween ? "" : "not ")}between {low} minutes and {high} minutes");
$"Date is {(isBetween ? "" : "not ")}between {lowDate:yyyy-MM-ddTHH:mm:ss}Z and {highDate:yyyy-MM-ddTHH:mm:ss}Z");
if (DateComparision.Comparison is DateCompareMode.Between)
{

View File

@@ -90,7 +90,7 @@
},
"Fields": {
"Path": "Path",
"Path-Help": "The path to the file to check. Leave empty to check the current working file.\nIf a file is specified the directory containing the file will be checked.",
"Path-Help": "The path to the folder to check. Leave empty to check the current working file.\nIf a file is specified the directory containing the file will be checked.",
"Date": "Date",
"DateComparision": "Comparision"
}

View File

@@ -136,6 +136,16 @@ public class LocalFileService : IFileService
}
}
public Result<DateTime> DirectoryCreationTimeUtc(string path)
{
throw new NotImplementedException();
}
public Result<DateTime> DirectoryLastWriteTimeUtc(string path)
{
throw new NotImplementedException();
}
public Result<bool> FileExists(string path)
{
if (IsProtectedPath(ref path))

Binary file not shown.

Binary file not shown.

View File

@@ -137,6 +137,16 @@ public class LocalFileService : IFileService
}
}
public Result<DateTime> DirectoryCreationTimeUtc(string path)
{
throw new NotImplementedException();
}
public Result<DateTime> DirectoryLastWriteTimeUtc(string path)
{
throw new NotImplementedException();
}
public Result<bool> FileExists(string path)
{
if (IsProtectedPath(ref path))

View File

@@ -140,6 +140,16 @@ public class LocalFileService : IFileService
}
}
public Result<DateTime> DirectoryCreationTimeUtc(string path)
{
throw new NotImplementedException();
}
public Result<DateTime> DirectoryLastWriteTimeUtc(string path)
{
throw new NotImplementedException();
}
public Result<bool> FileExists(string path)
{
if (IsProtectedPath(ref path))

View File

@@ -64,7 +64,15 @@ public class FfmpegBuilderAudioNormalization : FfmpegBuilderNode
item.stream.Filter.Add(track);
else
{
string twoPass = DoTwoPass(this, args, FFMPEG, audio.TypeIndex, localFile);
var twoPassResult = DoTwoPass(this, args, FFMPEG, audio.TypeIndex, localFile);
if (twoPassResult.Failed(out var error))
{
args.Logger?.ELog(error);
args.FailureReason = error;
return -1;
}
var twoPass = twoPassResult.Value;
item.stream.Filter.Add(twoPass);
normalizedTracks.Add(audio.TypeIndex, twoPass);
}
@@ -79,7 +87,7 @@ public class FfmpegBuilderAudioNormalization : FfmpegBuilderNode
return normalizing ? 1 : 2;
}
public static string DoTwoPass(EncodingNode node, NodeParameters args, string ffmpegExe, int audioIndex, string localFile)
public static Result<string> DoTwoPass(EncodingNode node, NodeParameters args, string ffmpegExe, int audioIndex, string localFile)
{
//-af loudnorm=I=-24:LRA=7:TP=-2.0"
string output;
@@ -95,17 +103,27 @@ public class FfmpegBuilderAudioNormalization : FfmpegBuilderNode
}, out output, updateWorkingFile: false, dontAddInputFile: true);
if (result == false)
throw new Exception("Failed to process audio track");
return Result<string>.Fail("Failed to process audio track");
int index = output.LastIndexOf("{", StringComparison.Ordinal);
if (index == -1)
throw new Exception("Failed to detected json in output");
return Result<string>.Fail("Failed to detected json in output");
string json = output[index..];
json = json.Substring(0, json.IndexOf("}", StringComparison.Ordinal) + 1);
if (string.IsNullOrEmpty(json))
throw new Exception("Failed to parse TwoPass json");
LoudNormStats? stats = JsonSerializer.Deserialize<LoudNormStats>(json);
return Result<string>.Fail("Failed to parse TwoPass json");
LoudNormStats? stats;
try
{
stats = JsonSerializer.Deserialize<LoudNormStats>(json);
}
catch (Exception ex)
{
args.Logger.ELog("Failed to parse JSON: " +ex.Message);
args.Logger.ELog("JSON:" + json);
return Result<string>.Fail("Failed to parse JSON output from FFmpeg");
}
if (stats.input_i == "-inf" || stats.input_lra == "-inf" || stats.input_tp == "-inf" || stats.input_thresh == "-inf" || stats.target_offset == "-inf")
{

View File

@@ -137,6 +137,16 @@ public class LocalFileService : IFileService
}
}
public Result<DateTime> DirectoryCreationTimeUtc(string path)
{
throw new NotImplementedException();
}
public Result<DateTime> DirectoryLastWriteTimeUtc(string path)
{
throw new NotImplementedException();
}
public Result<bool> FileExists(string path)
{
if (IsProtectedPath(ref path))