mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-05-09 07:39:49 -05:00
added some more variables to music nodes
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -17,10 +17,12 @@ namespace FileFlows.MusicNodes
|
||||
{
|
||||
{ "mi.Album", "Album" },
|
||||
{ "mi.Artist", "Artist" },
|
||||
{ "mi.ArtistThe", "Artist, The" },
|
||||
{ "mi.BitRate", 845 },
|
||||
{ "mi.Channels", 2 },
|
||||
{ "mi.Codec", "flac" },
|
||||
{ "mi.Date", new DateTime(2020, 05, 23) },
|
||||
{ "mi.Year", 2020 },
|
||||
{ "mi.Duration", 256 },
|
||||
{ "mi.Encoder", "FLAC 1.2.1" },
|
||||
{ "mi.Frequency", 44100 },
|
||||
@@ -28,9 +30,7 @@ namespace FileFlows.MusicNodes
|
||||
{ "mi.Language", "English" },
|
||||
{ "mi.Title", "Song Title" },
|
||||
{ "mi.Track", 2 },
|
||||
{ "mi.TrackPad", "02" },
|
||||
{ "mi.Disc", 2 },
|
||||
{ "mi.DiscPad", "02" },
|
||||
{ "mi.TotalDiscs", 2 }
|
||||
};
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -47,12 +47,22 @@ namespace FileFlows.MusicNodes
|
||||
else
|
||||
args.Parameters.Add(MUSIC_INFO, musicInfo);
|
||||
|
||||
variables.AddOrUpdate("mi.Artist", musicInfo.Artist);
|
||||
if(musicInfo.Artist.EndsWith(", The"))
|
||||
variables.AddOrUpdate("mi.Artist", "The " + musicInfo.Artist.Substring(0, musicInfo.Artist.Length - ", The".Length).Trim());
|
||||
else
|
||||
variables.AddOrUpdate("mi.Artist", musicInfo.Artist);
|
||||
|
||||
if(musicInfo.Artist?.StartsWith("The ") == true)
|
||||
variables.AddOrUpdate("mi.ArtistThe", musicInfo.Artist.Substring(4).Trim() + ", The");
|
||||
else
|
||||
variables.AddOrUpdate("mi.ArtistThe", musicInfo.Artist);
|
||||
|
||||
variables.AddOrUpdate("mi.Album", musicInfo.Album);
|
||||
variables.AddOrUpdate("mi.BitRate", musicInfo.BitRate);
|
||||
variables.AddOrUpdate("mi.Channels", musicInfo.Channels);
|
||||
variables.AddOrUpdate("mi.Codec", musicInfo.Codec);
|
||||
variables.AddOrUpdate("mi.Date", musicInfo.Date);
|
||||
variables.AddOrUpdate("mi.Year", musicInfo.Date.Year);
|
||||
variables.AddOrUpdate("mi.Duration", musicInfo.Duration);
|
||||
variables.AddOrUpdate("mi.Encoder", musicInfo.Encoder);
|
||||
variables.AddOrUpdate("mi.Frequency", musicInfo.Frequency);
|
||||
@@ -60,9 +70,7 @@ namespace FileFlows.MusicNodes
|
||||
variables.AddOrUpdate("mi.Language", musicInfo.Language);
|
||||
variables.AddOrUpdate("mi.Title", musicInfo.Title);
|
||||
variables.AddOrUpdate("mi.Track", musicInfo.Track);
|
||||
variables.AddOrUpdate("mi.TrackPad", musicInfo.Track.ToString("D2"));
|
||||
variables.AddOrUpdate("mi.Disc", musicInfo.Disc < 1 ? 1 : musicInfo.Disc);
|
||||
variables.AddOrUpdate("mi.DiscPad", musicInfo.Disc.ToString("D2"));
|
||||
variables.AddOrUpdate("mi.TotalDiscs", musicInfo.TotalDiscs < 1 ? 1 : musicInfo.TotalDiscs);
|
||||
|
||||
args.UpdateVariables(variables);
|
||||
|
||||
@@ -54,8 +54,18 @@ namespace FileFlows.MusicNodes.Tests
|
||||
foreach (string file in Directory.GetFiles(@"D:\videos\music"))
|
||||
{
|
||||
var args = new FileFlows.Plugin.NodeParameters(file, logger, false, string.Empty);
|
||||
var info = new MusicInfoHelper(ffmpegExe, logger).Read(file);
|
||||
Assert.IsNotNull(info);
|
||||
args.GetToolPathActual = (string tool) => ffmpegExe;
|
||||
|
||||
// laod the variables
|
||||
Assert.AreEqual(1, new MusicFile().Execute(args));
|
||||
|
||||
var mi = new MusicInfoHelper(ffmpegExe, args.Logger).Read(args.WorkingFile);
|
||||
|
||||
string folder = args.ReplaceVariables("{mi.ArtistThe} ({mi.Year})");
|
||||
Assert.AreEqual($"{mi.Artist} ({mi.Date.Year})", folder);
|
||||
|
||||
string fname = args.ReplaceVariables("{mi.Artist} - {mi.Track:##} - {mi.Title}");
|
||||
Assert.AreEqual($"{mi.Artist} - {mi.Track.ToString("00")} - {mi.Title}", fname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user