mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2025-12-30 23:09:31 -06:00
improved track parser
This commit is contained in:
@@ -87,7 +87,8 @@ namespace FileFlows.MusicNodes
|
||||
mi.Language = line.Substring(colonIndex + 1).Trim();
|
||||
else if (line.Trim().ToLower().StartsWith("track"))
|
||||
{
|
||||
if (int.TryParse(line.Substring(colonIndex + 1).Trim(), out int value))
|
||||
var trackMatch = Regex.Match(line.Substring(colonIndex + 1).Trim(), @"^[\d]+");
|
||||
if (trackMatch.Success && int.TryParse(trackMatch.Value, out int value))
|
||||
mi.Track = value;
|
||||
}
|
||||
else if (line.Trim().ToLower().StartsWith("artist") || line.Trim().ToLower().StartsWith("album_artist"))
|
||||
|
||||
51
MusicNodes/Tests/MusicInfoTests.cs
Normal file
51
MusicNodes/Tests/MusicInfoTests.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
#if(DEBUG)
|
||||
|
||||
|
||||
namespace FileFlows.MusicNodes.Tests
|
||||
{
|
||||
using FileFlows.MusicNodes;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
[TestClass]
|
||||
public class MusicInfoTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void MusicInfo_SplitTrack()
|
||||
{
|
||||
|
||||
const string file = @"\\oracle\music\The Cranberries\No Need To Argue\The Cranberries - No Need To Argue - 00 - I Don't Need (Demo).mp3";
|
||||
const string ffmpegExe = @"C:\utils\ffmpeg\ffmpeg.exe";
|
||||
|
||||
var args = new FileFlows.Plugin.NodeParameters(file, new TestLogger(), false, string.Empty);
|
||||
args.GetToolPathActual = (string tool) => ffmpegExe;
|
||||
args.TempPath = @"D:\music\temp";
|
||||
|
||||
var musicInfo = new MusicInfoHelper(ffmpegExe, args.Logger).Read(args.WorkingFile);
|
||||
|
||||
Assert.AreEqual(9, musicInfo.Track);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MusicInfo_NormalTrack()
|
||||
{
|
||||
|
||||
const string file = @"\\oracle\music\Taylor Swift\Speak Now\Taylor Swift - Speak Now - 08 - Never Grow Up.mp3";
|
||||
const string ffmpegExe = @"C:\utils\ffmpeg\ffmpeg.exe";
|
||||
|
||||
var args = new FileFlows.Plugin.NodeParameters(file, new TestLogger(), false, string.Empty);
|
||||
args.GetToolPathActual = (string tool) => ffmpegExe;
|
||||
args.TempPath = @"D:\music\temp";
|
||||
|
||||
var musicInfo = new MusicInfoHelper(ffmpegExe, args.Logger).Read(args.WorkingFile);
|
||||
|
||||
Assert.AreEqual(8, musicInfo.Track);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user