diff --git a/Apprise/Apprise.csproj b/Apprise/Apprise.csproj index 57941e3a..8754c5a5 100644 --- a/Apprise/Apprise.csproj +++ b/Apprise/Apprise.csproj @@ -5,8 +5,8 @@ enable enable FileFlows.$(MSBuildProjectName.Replace(" ", "_")) - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true true FileFlows diff --git a/AudioNodes/AudioInfo.cs b/AudioNodes/AudioInfo.cs index ff68b3d9..68c6695a 100644 --- a/AudioNodes/AudioInfo.cs +++ b/AudioNodes/AudioInfo.cs @@ -13,7 +13,7 @@ namespace FileFlows.AudioNodes public string[] Genres { get; set; } public string Encoder { get; set; } public long Duration { get; set; } - public long BitRate { get; set; } + public long Bitrate { get; set; } public string Codec { get; set; } public long Channels { get; set; } public long Frequency { get; set; } diff --git a/AudioNodes/AudioInfoHelper.cs b/AudioNodes/AudioInfoHelper.cs index 34cf15fc..d148ce3e 100644 --- a/AudioNodes/AudioInfoHelper.cs +++ b/AudioNodes/AudioInfoHelper.cs @@ -163,7 +163,7 @@ namespace FileFlows.AudioNodes { br = br.Substring(0, br.IndexOf(" ")); if (long.TryParse(br, out long value)) - mi.BitRate = value; + mi.Bitrate = value; } } diff --git a/AudioNodes/AudioNodes.csproj b/AudioNodes/AudioNodes.csproj index 6de2105e..f0f8cb94 100644 --- a/AudioNodes/AudioNodes.csproj +++ b/AudioNodes/AudioNodes.csproj @@ -6,8 +6,8 @@ enable true true - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true true FileFlows diff --git a/AudioNodes/InputNodes/AudioFile.cs b/AudioNodes/InputNodes/AudioFile.cs index 4d4dfdfd..d03a2bcf 100644 --- a/AudioNodes/InputNodes/AudioFile.cs +++ b/AudioNodes/InputNodes/AudioFile.cs @@ -18,7 +18,7 @@ namespace FileFlows.AudioNodes { "mi.Album", "Album" }, { "mi.Artist", "Artist" }, { "mi.ArtistThe", "Artist, The" }, - { "mi.BitRate", 845 }, + { "mi.Bitrate", 845 }, { "mi.Channels", 2 }, { "mi.Codec", "flac" }, { "mi.Date", new DateTime(2020, 05, 23) }, diff --git a/AudioNodes/Nodes/AudioNode.cs b/AudioNodes/Nodes/AudioNode.cs index a318bfc6..9740e82c 100644 --- a/AudioNodes/Nodes/AudioNode.cs +++ b/AudioNodes/Nodes/AudioNode.cs @@ -59,7 +59,7 @@ namespace FileFlows.AudioNodes variables.AddOrUpdate("audio.ArtistThe", AudioInfo.Artist); variables.AddOrUpdate("audio.Album", AudioInfo.Album); - variables.AddOrUpdate("audio.BitRate", AudioInfo.BitRate); + variables.AddOrUpdate("audio.Bitrate", AudioInfo.Bitrate); variables.AddOrUpdate("audio.Channels", AudioInfo.Channels); variables.AddOrUpdate("audio.Codec", AudioInfo.Codec); variables.AddOrUpdate("audio.Date", AudioInfo.Date); @@ -74,9 +74,45 @@ namespace FileFlows.AudioNodes variables.AddOrUpdate("audio.Disc", AudioInfo.Disc < 1 ? 1 : AudioInfo.Disc); variables.AddOrUpdate("audio.TotalDiscs", AudioInfo.TotalDiscs < 1 ? 1 : AudioInfo.TotalDiscs); + + if (args.OriginalMetadata == null) + { + args.OriginalMetadata = new Dictionary(); + args.OriginalMetadata.Add("Duration", AudioInfo.Duration); + args.OriginalMetadata.Add("Codec", AudioInfo.Codec); + args.OriginalMetadata.Add("Bitrate", AudioInfo.Bitrate); + args.OriginalMetadata.Add("Channels", AudioInfo.Channels); + AddIfSet(args.OriginalMetadata, "Date", AudioInfo.Date); + AddIfSet(args.OriginalMetadata, "Frequency", AudioInfo.Frequency); + AddIfSet(args.OriginalMetadata, "Encoder", AudioInfo.Encoder); + AddIfSet(args.OriginalMetadata, "Genres", AudioInfo.Genres); + AddIfSet(args.OriginalMetadata, "Language", AudioInfo.Language); + AddIfSet(args.OriginalMetadata, "Title", AudioInfo.Title); + AddIfSet(args.OriginalMetadata, "Track", AudioInfo.Track); + AddIfSet(args.OriginalMetadata, "Disc", AudioInfo.Disc); + AddIfSet(args.OriginalMetadata, "TotalDiscs", AudioInfo.TotalDiscs); + } + args.UpdateVariables(variables); } + private void AddIfSet(Dictionary dict, string name, object value) + { + if (value == null) + return; + if (value is string sValue && string.IsNullOrWhiteSpace(sValue)) + return; + if (value is int iValue && iValue < 1) + return; + if (value is TimeSpan tsValue && tsValue.TotalSeconds < 1) + return; + if (value is DateTime dtValue && dtValue.Year <= 1900) + return; + if (value is IEnumerable strList && strList.Any() == false) + return; + dict.Add(name, value); + } + protected AudioInfo GetAudioInfo(NodeParameters args) { if (args.Parameters.ContainsKey(Audio_INFO) == false) diff --git a/AudioNodes/Nodes/ConvertNode.cs b/AudioNodes/Nodes/ConvertNode.cs index 1569475c..2c7fdb94 100644 --- a/AudioNodes/Nodes/ConvertNode.cs +++ b/AudioNodes/Nodes/ConvertNode.cs @@ -156,13 +156,13 @@ namespace FileFlows.AudioNodes { if (SkipIfCodecMatches) { - args.Logger?.ILog($"Audio file already '{Codec}' at bitrate '{AudioInfo.BitRate}', and set to skip if codec matches"); + args.Logger?.ILog($"Audio file already '{Codec}' at bitrate '{AudioInfo.Bitrate}', and set to skip if codec matches"); return 2; } - if(AudioInfo.BitRate <= Bitrate) + if(AudioInfo.Bitrate <= Bitrate) { - args.Logger?.ILog($"Audio file already '{Codec}' at bitrate '{AudioInfo.BitRate}'"); + args.Logger?.ILog($"Audio file already '{Codec}' at bitrate '{AudioInfo.Bitrate}'"); return 2; } } diff --git a/BasicNodes/BasicNodes.csproj b/BasicNodes/BasicNodes.csproj index 18270f6c..33879506 100644 --- a/BasicNodes/BasicNodes.csproj +++ b/BasicNodes/BasicNodes.csproj @@ -4,8 +4,8 @@ net6.0 enable enable - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true FileFlows John Andrews diff --git a/ChecksumNodes/ChecksumNodes.csproj b/ChecksumNodes/ChecksumNodes.csproj index 70473d69..f135472e 100644 --- a/ChecksumNodes/ChecksumNodes.csproj +++ b/ChecksumNodes/ChecksumNodes.csproj @@ -5,8 +5,8 @@ enable true true - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true FileFlows John Andrews diff --git a/CollectionNodes/CollectionNodes.csproj b/CollectionNodes/CollectionNodes.csproj index f9cc2c07..43040d53 100644 --- a/CollectionNodes/CollectionNodes.csproj +++ b/CollectionNodes/CollectionNodes.csproj @@ -4,8 +4,8 @@ net6.0 enable enable - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true true FileFlows diff --git a/ComicNodes/ComicNodes.csproj b/ComicNodes/ComicNodes.csproj index 15d9083a..1aa159c3 100644 --- a/ComicNodes/ComicNodes.csproj +++ b/ComicNodes/ComicNodes.csproj @@ -5,8 +5,8 @@ enable enable FileFlows.$(MSBuildProjectName.Replace(" ", "_")) - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true true FileFlows diff --git a/ComicNodes/Comics/ComicConverter.cs b/ComicNodes/Comics/ComicConverter.cs index e1530052..60004746 100644 --- a/ComicNodes/Comics/ComicConverter.cs +++ b/ComicNodes/Comics/ComicConverter.cs @@ -45,7 +45,15 @@ public class ComicConverter: Node currentFormat = currentFormat[1..]; // remove the dot currentFormat = currentFormat.ToLower(); - if(currentFormat == Format) + + if (args.OriginalMetadata == null) + { + args.OriginalMetadata = new Dictionary(); + args.OriginalMetadata.Add("Format", currentFormat); + args.OriginalMetadata.Add("Pages", GetPageCount(currentFormat, args.WorkingFile)); + } + + if (currentFormat == Format) { args.Logger?.ILog($"Already in the target format of '{Format}'"); return 2; @@ -63,6 +71,20 @@ public class ComicConverter: Node return 1; } + private int GetPageCount(string format, string workingFile) + { + if (format == null) + return 0; + format = format.ToLower().Trim(); + switch (format) + { + case "pdf": + return Helpers.PdfHelper.GetPageCount(workingFile); + default: + return Helpers.GenericExtractor.GetImageCount(workingFile); + } + } + private string CreateComic(NodeParameters args, string directory, string format) { string file = Path.Combine(args.TempPath, Guid.NewGuid().ToString() + "." + format); diff --git a/ComicNodes/Helpers/GenericExtractor.cs b/ComicNodes/Helpers/GenericExtractor.cs index 5b0e2c4f..7dbfafdd 100644 --- a/ComicNodes/Helpers/GenericExtractor.cs +++ b/ComicNodes/Helpers/GenericExtractor.cs @@ -25,4 +25,10 @@ internal class GenericExtractor if (args?.PartPercentageUpdate != null) args?.PartPercentageUpdate(halfProgress ? 50 : 100); } + + internal static int GetImageCount(string workingFile) + { + var rgxImages = new Regex(@"\.(jpeg|jpg|jpe|png|bmp|tiff|webp|gif)$"); + return ArchiveFactory.GetFileParts(workingFile).Where(x => rgxImages.IsMatch(x)).Count(); + } } diff --git a/ComicNodes/Helpers/PdfHelper.cs b/ComicNodes/Helpers/PdfHelper.cs index 5d026ff2..20a3ae56 100644 --- a/ComicNodes/Helpers/PdfHelper.cs +++ b/ComicNodes/Helpers/PdfHelper.cs @@ -115,4 +115,16 @@ internal class PdfHelper if (args?.PartPercentageUpdate != null) args?.PartPercentageUpdate(100); } + + /// + /// Gets the number of pages in a PDF + /// + /// the PDF file + /// the number of pages in the PDF + internal static int GetPageCount(string pdfFile) + { + using var library = DocLib.Instance; + using var docReader = library.GetDocReader(pdfFile, new PageDimensions(1080, 1920)); + return docReader.GetPageCount(); + } } diff --git a/DiscordNodes/DiscordNodes.csproj b/DiscordNodes/DiscordNodes.csproj index 5d1c8d70..0b2b51de 100644 --- a/DiscordNodes/DiscordNodes.csproj +++ b/DiscordNodes/DiscordNodes.csproj @@ -5,8 +5,8 @@ enable enable FileFlows.$(MSBuildProjectName.Replace(" ", "_")) - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true true FileFlows diff --git a/EmailNodes/EmailNodes.csproj b/EmailNodes/EmailNodes.csproj index 77c4fa87..601527d1 100644 --- a/EmailNodes/EmailNodes.csproj +++ b/EmailNodes/EmailNodes.csproj @@ -9,8 +9,8 @@ true true true - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true FileFlows John Andrews diff --git a/Emby/Emby.csproj b/Emby/Emby.csproj index 6d2b3c54..70b60ff0 100644 --- a/Emby/Emby.csproj +++ b/Emby/Emby.csproj @@ -5,8 +5,8 @@ enable enable FileFlows.$(MSBuildProjectName.Replace(" ", "_")) - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true true FileFlows diff --git a/FileFlows.Plugin.dll b/FileFlows.Plugin.dll index df60dd90..662f3a02 100644 Binary files a/FileFlows.Plugin.dll and b/FileFlows.Plugin.dll differ diff --git a/FileFlows.Plugin.pdb b/FileFlows.Plugin.pdb index 95ddc566..18ce86b4 100644 Binary files a/FileFlows.Plugin.pdb and b/FileFlows.Plugin.pdb differ diff --git a/Gotify/Gotify.csproj b/Gotify/Gotify.csproj index 6edef2c2..32681cf2 100644 --- a/Gotify/Gotify.csproj +++ b/Gotify/Gotify.csproj @@ -5,8 +5,8 @@ enable enable FileFlows.$(MSBuildProjectName.Replace(" ", "_")) - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true true FileFlows diff --git a/ImageNodes/ImageNodes.csproj b/ImageNodes/ImageNodes.csproj index cc983011..163972da 100644 --- a/ImageNodes/ImageNodes.csproj +++ b/ImageNodes/ImageNodes.csproj @@ -5,8 +5,8 @@ enable enable FileFlows.$(MSBuildProjectName.Replace(" ", "_")) - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true true FileFlows diff --git a/MetaNodes/MetaNodes.csproj b/MetaNodes/MetaNodes.csproj index b015aa2b..ef96b28e 100644 --- a/MetaNodes/MetaNodes.csproj +++ b/MetaNodes/MetaNodes.csproj @@ -6,8 +6,8 @@ enable true true - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true true FileFlows diff --git a/MusicNodes/InputNodes/MusicFile.cs b/MusicNodes/InputNodes/MusicFile.cs index dfdbe8a5..a1633db2 100644 --- a/MusicNodes/InputNodes/MusicFile.cs +++ b/MusicNodes/InputNodes/MusicFile.cs @@ -19,7 +19,7 @@ namespace FileFlows.MusicNodes { "mi.Album", "Album" }, { "mi.Artist", "Artist" }, { "mi.ArtistThe", "Artist, The" }, - { "mi.BitRate", 845 }, + { "mi.Bitrate", 845 }, { "mi.Channels", 2 }, { "mi.Codec", "flac" }, { "mi.Date", new DateTime(2020, 05, 23) }, diff --git a/MusicNodes/MusicInfo.cs b/MusicNodes/MusicInfo.cs index 46970deb..f5128501 100644 --- a/MusicNodes/MusicInfo.cs +++ b/MusicNodes/MusicInfo.cs @@ -13,7 +13,7 @@ namespace FileFlows.MusicNodes public string[] Genres { get; set; } public string Encoder { get; set; } public long Duration { get; set; } - public long BitRate { get; set; } + public long Bitrate { get; set; } public string Codec { get; set; } public long Channels { get; set; } public long Frequency { get; set; } diff --git a/MusicNodes/MusicInfoHelper.cs b/MusicNodes/MusicInfoHelper.cs index 0aa4418f..1f05e591 100644 --- a/MusicNodes/MusicInfoHelper.cs +++ b/MusicNodes/MusicInfoHelper.cs @@ -163,7 +163,7 @@ namespace FileFlows.MusicNodes { br = br.Substring(0, br.IndexOf(" ")); if (long.TryParse(br, out long value)) - mi.BitRate = value; + mi.Bitrate = value; } } diff --git a/MusicNodes/MusicNodes.csproj b/MusicNodes/MusicNodes.csproj index ef72caca..ef96b42f 100644 --- a/MusicNodes/MusicNodes.csproj +++ b/MusicNodes/MusicNodes.csproj @@ -6,8 +6,8 @@ enable true true - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true true FileFlows diff --git a/MusicNodes/Nodes/ConvertNode.cs b/MusicNodes/Nodes/ConvertNode.cs index 532d2f60..7c943604 100644 --- a/MusicNodes/Nodes/ConvertNode.cs +++ b/MusicNodes/Nodes/ConvertNode.cs @@ -152,13 +152,13 @@ namespace FileFlows.MusicNodes { if (SkipIfCodecMatches) { - args.Logger?.ILog($"Music file already '{Codec}' at bitrate '{musicInfo.BitRate}', and set to skip if codec matches"); + args.Logger?.ILog($"Music file already '{Codec}' at bitrate '{musicInfo.Bitrate}', and set to skip if codec matches"); return 2; } - if(musicInfo.BitRate <= Bitrate) + if(musicInfo.Bitrate <= Bitrate) { - args.Logger?.ILog($"Music file already '{Codec}' at bitrate '{musicInfo.BitRate}'"); + args.Logger?.ILog($"Music file already '{Codec}' at bitrate '{musicInfo.Bitrate}'"); return 2; } } diff --git a/MusicNodes/Nodes/MusicNode.cs b/MusicNodes/Nodes/MusicNode.cs index 9153d15e..62d5e261 100644 --- a/MusicNodes/Nodes/MusicNode.cs +++ b/MusicNodes/Nodes/MusicNode.cs @@ -59,7 +59,7 @@ namespace FileFlows.MusicNodes variables.AddOrUpdate("mi.ArtistThe", musicInfo.Artist); variables.AddOrUpdate("mi.Album", musicInfo.Album); - variables.AddOrUpdate("mi.BitRate", musicInfo.BitRate); + variables.AddOrUpdate("mi.Bitrate", musicInfo.Bitrate); variables.AddOrUpdate("mi.Channels", musicInfo.Channels); variables.AddOrUpdate("mi.Codec", musicInfo.Codec); variables.AddOrUpdate("mi.Date", musicInfo.Date); diff --git a/Plex/Plex.csproj b/Plex/Plex.csproj index b1f1a18b..c01f1a24 100644 --- a/Plex/Plex.csproj +++ b/Plex/Plex.csproj @@ -5,8 +5,8 @@ enable enable FileFlows.$(MSBuildProjectName.Replace(" ", "_")) - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true true FileFlows diff --git a/VideoLegacyNodes/VideoLegacyNodes.csproj b/VideoLegacyNodes/VideoLegacyNodes.csproj index 6ae4ea1b..f9484c63 100644 --- a/VideoLegacyNodes/VideoLegacyNodes.csproj +++ b/VideoLegacyNodes/VideoLegacyNodes.csproj @@ -6,8 +6,8 @@ enable true true - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true FileFlows John Andrews diff --git a/VideoNodes/VideoNodes.csproj b/VideoNodes/VideoNodes.csproj index a20f6297..d4f0662e 100644 --- a/VideoNodes/VideoNodes.csproj +++ b/VideoNodes/VideoNodes.csproj @@ -6,8 +6,8 @@ enable true true - 1.0.0.169 - 1.0.0.169 + 1.0.0.170 + 1.0.0.170 true FileFlows John Andrews diff --git a/VideoNodes/VideoNodes/VideoNode.cs b/VideoNodes/VideoNodes/VideoNode.cs index 4d7b9b6d..1748b040 100644 --- a/VideoNodes/VideoNodes/VideoNode.cs +++ b/VideoNodes/VideoNodes/VideoNode.cs @@ -113,6 +113,41 @@ namespace FileFlows.VideoNodes variables.AddOrUpdate("vi.Resolution", videoInfo.VideoStreams[0].Width + "x" + videoInfo.VideoStreams[0].Height); args.UpdateVariables(variables); + + if(args.OriginalMetadata == null) + { + args.OriginalMetadata = new Dictionary(); + args.OriginalMetadata.Add("Duration", videoInfo.VideoStreams[0].Duration); + foreach (var (stream, i) in videoInfo.VideoStreams.Select((value, i) => (value, i))) + { + string prefix = "Video" + (i == 0 ? "" : " " + (i + 1)) + " "; + args.OriginalMetadata.Add(prefix + "Codec", stream.Codec); + args.OriginalMetadata.Add(prefix + "Resolution", stream.Width + "x" + stream.Height + (stream.HDR ? " (HDR)" : string.Empty)); + if(stream.Bitrate > 0) + args.OriginalMetadata.Add(prefix + "Bitrate", stream.Bitrate); + } + foreach (var (stream, i) in videoInfo.AudioStreams.Select((value, i) => (value, i))) + { + string prefix = "Audio" + (i == 0 ? "" : " " + (i + 1)) + " "; + args.OriginalMetadata.Add(prefix + "Codec", stream.Codec); + args.OriginalMetadata.Add(prefix + "Channels", stream.Channels); + if (string.IsNullOrEmpty(stream.Title) == false) + args.OriginalMetadata.Add(prefix + "Title", stream.Title); + if(string.IsNullOrEmpty(stream.Language) == false) + args.OriginalMetadata.Add(prefix + "Language", stream.Language); + if (stream.Bitrate > 0) + args.OriginalMetadata.Add(prefix + "Bitrate", stream.Bitrate); + } + foreach (var (strream, i) in videoInfo.SubtitleStreams.Select((value, i) => (value, i))) + { + string prefix = "Audio" + (i == 0 ? "" : " " + (i + 1)) + " "; + args.OriginalMetadata.Add(prefix + "Codec", strream.Codec); + if (string.IsNullOrEmpty(strream.Title) == false) + args.OriginalMetadata.Add(prefix + "Title", strream.Title); + if (string.IsNullOrEmpty(strream.Language) == false) + args.OriginalMetadata.Add(prefix + "Language", strream.Language); + } + } } protected VideoInfo GetVideoInfo(NodeParameters args, bool refreshIfFileChanged = true)