Minor refactoring.

This commit is contained in:
Michael Bucari-Tovo 2021-07-01 08:22:04 -06:00
parent 8c6ada8d20
commit 36ab494b31
2 changed files with 8 additions and 8 deletions

View File

@ -1,5 +1,6 @@
using Dinah.Core; using Dinah.Core;
using Dinah.Core.Diagnostics; using Dinah.Core.Diagnostics;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
@ -66,8 +67,8 @@ namespace AaxDecrypter
public class Chapter public class Chapter
{ {
public string Title { get; } public string Title { get; }
public long StartOffsetMs { get; } public TimeSpan StartOffset { get; }
public long EndOffsetMs { get; } public TimeSpan EndOffset { get; }
public Chapter(string title, long startOffsetMs, long lengthMs) public Chapter(string title, long startOffsetMs, long lengthMs)
{ {
ArgumentValidator.EnsureNotNullOrEmpty(title, nameof(title)); ArgumentValidator.EnsureNotNullOrEmpty(title, nameof(title));
@ -75,16 +76,16 @@ namespace AaxDecrypter
ArgumentValidator.EnsureGreaterThan(lengthMs, nameof(lengthMs), 0); ArgumentValidator.EnsureGreaterThan(lengthMs, nameof(lengthMs), 0);
Title = title; Title = title;
StartOffsetMs = startOffsetMs; StartOffset = TimeSpan.FromMilliseconds(startOffsetMs);
EndOffsetMs = StartOffsetMs + lengthMs; EndOffset = StartOffset + TimeSpan.FromMilliseconds(lengthMs);
} }
public string ToFFMeta() public string ToFFMeta()
{ {
return "[CHAPTER]\n" + return "[CHAPTER]\n" +
"TIMEBASE=1/1000\n" + "TIMEBASE=1/1000\n" +
"START=" + StartOffsetMs + "\n" + "START=" + StartOffset.TotalMilliseconds + "\n" +
"END=" + EndOffsetMs + "\n" + "END=" + EndOffset.TotalMilliseconds + "\n" +
"title=" + Title; "title=" + Title;
} }
} }

View File

@ -17,11 +17,10 @@ namespace AaxDecrypter
foreach (var c in chapters.Chapters) foreach (var c in chapters.Chapters)
{ {
trackCount++; trackCount++;
var startTime = TimeSpan.FromMilliseconds(c.StartOffsetMs);
stringBuilder.AppendLine($"TRACK {trackCount} AUDIO"); stringBuilder.AppendLine($"TRACK {trackCount} AUDIO");
stringBuilder.AppendLine($" TITLE \"{c.Title}\""); stringBuilder.AppendLine($" TITLE \"{c.Title}\"");
stringBuilder.AppendLine($" INDEX 01 {(int)startTime.TotalMinutes}:{startTime:ss\\:ff}"); stringBuilder.AppendLine($" INDEX 01 {(int)c.StartOffset.TotalMinutes}:{c.StartOffset:ss\\:ff}");
} }
return stringBuilder.ToString(); return stringBuilder.ToString();