Skip to content

Commit

Permalink
use splitpoint audio file name
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoCoderMatrix86 committed Apr 3, 2024
1 parent b508b96 commit e195cb7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
9 changes: 4 additions & 5 deletions AudioCuesheetEditor/Model/IO/Export/ExportfileGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ public IReadOnlyCollection<Exportfile> GenerateExportfiles()
var counter = 1;
String? content = null;
String filename = String.Empty;
//TODO
String audioFileName = String.Empty;
String? audioFileName = null;
foreach (var splitPoint in Cuesheet.SplitPoints.OrderBy(x => x.Moment))
{
audioFileName = String.Format("{0}({1}){2}", Path.GetFileNameWithoutExtension(Cuesheet.Audiofile?.Name), counter, Path.GetExtension(Cuesheet.Audiofile?.Name));
audioFileName = splitPoint.AudiofileName;
if (splitPoint.Validate().Status == ValidationStatus.Success)
{
switch (ExportType)
Expand Down Expand Up @@ -155,7 +154,7 @@ public IReadOnlyCollection<Exportfile> GenerateExportfiles()
return exportfiles;
}

private string WriteCuesheet(String audiofileName, TimeSpan? from = null, SplitPoint? splitPoint = null)
private string WriteCuesheet(String? audiofileName, TimeSpan? from = null, SplitPoint? splitPoint = null)
{
var builder = new StringBuilder();
if (Cuesheet.Cataloguenumber != null && string.IsNullOrEmpty(Cuesheet.Cataloguenumber.Value) == false && Cuesheet.Cataloguenumber.Validate().Status != ValidationStatus.Error)
Expand Down Expand Up @@ -231,7 +230,7 @@ private string WriteCuesheet(String audiofileName, TimeSpan? from = null, SplitP
return builder.ToString();
}

private String WriteExport(String audiofileName, TimeSpan? from = null, SplitPoint? splitPoint = null)
private String WriteExport(String? audiofileName, TimeSpan? from = null, SplitPoint? splitPoint = null)
{
var builder = new StringBuilder();
if (Exportprofile != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,17 @@ public void GenerateCuesheetFilesWithSplitPointsTest()
var splitPoint = cuesheet.AddSplitPoint();
splitPoint.Moment = new TimeSpan(2, 0, 0);
splitPoint.Title = "Last part";
splitPoint.AudiofileName = "Last part.mp3";
splitPoint = cuesheet.AddSplitPoint();
splitPoint.Moment = new TimeSpan(0, 30, 0);
splitPoint.AudiofileName = "First part.mp3";
splitPoint = cuesheet.AddSplitPoint();
splitPoint.Moment = new TimeSpan(1, 0, 0);
splitPoint.Artist = "Demo Artist Part2";
splitPoint = cuesheet.AddSplitPoint();
splitPoint.Artist = "Artist 3";
splitPoint.Title = "Title 3";
splitPoint.AudiofileName = "Part 3.mp3";
splitPoint.Moment = new TimeSpan(1, 30, 0);
testHelper.ApplicationOptions.CuesheetFilename = "Unit test.cue";
var generator = new ExportfileGenerator(ExportType.Cuesheet, cuesheet, applicationOptions: testHelper.ApplicationOptions);
Expand Down Expand Up @@ -349,11 +352,14 @@ public void GenerateCuesheetFilesWithSplitPointsTest()
{
Assert.AreEqual(String.Format("{0} \"{1}\"", CuesheetConstants.CuesheetTitle, splitPointForThisFile.Title), fileContent.First());
Assert.AreEqual(String.Format("{0} \"{1}\"", CuesheetConstants.CuesheetArtist, splitPointForThisFile.Artist), fileContent[1]);
Assert.AreEqual(String.Format("{0} \"{1}\" {2}", CuesheetConstants.CuesheetFileName, splitPointForThisFile.AudiofileName, cuesheet.Audiofile?.AudioFileType), fileContent[2]);
}
else
{
Assert.AreEqual(String.Format("{0} \"{1}\"", CuesheetConstants.CuesheetTitle, cuesheet.Title), fileContent.First());
Assert.AreEqual(String.Format("{0} \"{1}\"", CuesheetConstants.CuesheetArtist, cuesheet.Artist), fileContent[1]);
var cuesheetFileName = String.Format("{0}({1}){2}", Path.GetFileNameWithoutExtension(cuesheet.Audiofile?.Name), counter - 1, Path.GetExtension(cuesheet.Audiofile?.Name));
Assert.AreEqual(String.Format("{0} \"{1}\" {2}", CuesheetConstants.CuesheetFileName, cuesheetFileName, cuesheet.Audiofile?.AudioFileType), fileContent[2]);
}
//Check for start from position 1 and begin = 00:00:00
for (int i = 3; i < fileContent.Length; i += 4)
Expand Down Expand Up @@ -621,23 +627,25 @@ public void GenerateExportfilesWithSplitPointsTest()

cuesheet.Cataloguenumber.Value = "0123456789123";
cuesheet.CDTextfile = new CDTextfile("Testfile.cdt");

var splitPoint = cuesheet.AddSplitPoint();
splitPoint.Moment = new TimeSpan(2, 0, 0);
splitPoint.Title = "Last part";
splitPoint.AudiofileName = "Last part.mp3";
splitPoint = cuesheet.AddSplitPoint();
splitPoint.Moment = new TimeSpan(0, 30, 0);
splitPoint.AudiofileName = "First part.mp3";
splitPoint = cuesheet.AddSplitPoint();
splitPoint.Moment = new TimeSpan(1, 0, 0);
splitPoint.Artist = "Demo Artist Part2";
splitPoint = cuesheet.AddSplitPoint();
splitPoint.Artist = "Artist 3";
splitPoint.Title = "Title 3";
splitPoint.AudiofileName = "Part 3.mp3";
splitPoint.Moment = new TimeSpan(1, 30, 0);
//Test export
var exportProfile = new Exportprofile
{
SchemeHead = "%Cuesheet.Artist%;%Cuesheet.Title%;%Cuesheet.Cataloguenumber%;%Cuesheet.CDTextfile%",
SchemeHead = "%Cuesheet.Artist%;%Cuesheet.Title%;%Cuesheet.Audiofile%;%Cuesheet.Cataloguenumber%;%Cuesheet.CDTextfile%",
SchemeTracks = "%Track.Position%;%Track.Artist%;%Track.Title%;%Track.Begin%;%Track.End%;%Track.Length%",
SchemeFooter = "Exported %Cuesheet.Title% from %Cuesheet.Artist% using AudioCuesheetEditor"
};
Expand Down Expand Up @@ -674,11 +682,12 @@ public void GenerateExportfilesWithSplitPointsTest()
var splitPointForThisFile = cuesheet.SplitPoints.FirstOrDefault(x => x.Moment == generatedFile.End);
if (splitPointForThisFile != null)
{
Assert.AreEqual(String.Format("{0};{1};0123456789123;Testfile.cdt", splitPointForThisFile.Artist, splitPointForThisFile.Title), fileContent[0]);
Assert.AreEqual(String.Format("{0};{1};{2};0123456789123;Testfile.cdt", splitPointForThisFile.Artist, splitPointForThisFile.Title, splitPointForThisFile.AudiofileName), fileContent[0]);
}
else
{
Assert.AreEqual(String.Format("{0};{1};0123456789123;Testfile.cdt", cuesheet.Artist, cuesheet.Title), fileContent[0]);
var audiofileName = String.Format("{0}({1}){2}", Path.GetFileNameWithoutExtension(cuesheet.Audiofile?.Name), counter - 1, Path.GetExtension(cuesheet.Audiofile?.Name));
Assert.AreEqual(String.Format("{0};{1};{2};0123456789123;Testfile.cdt", cuesheet.Artist, cuesheet.Title, audiofileName), fileContent[0]);
}
//Check for start from position 1 and begin = 00:00:00
for (int i = 1; i < fileContent.Length - 1; i++)
Expand Down

0 comments on commit e195cb7

Please sign in to comment.