diff --git a/AaxDecrypter/UNTESTED/AaxToM4bConverter.cs b/AaxDecrypter/UNTESTED/AaxToM4bConverter.cs index 0e900b1c..c763d7db 100644 --- a/AaxDecrypter/UNTESTED/AaxToM4bConverter.cs +++ b/AaxDecrypter/UNTESTED/AaxToM4bConverter.cs @@ -293,14 +293,14 @@ namespace AaxDecrypter public bool Step3_Chapterize() { - string str1 = ""; + var str1 = ""; if (chapters.FirstChapterStart != 0.0) { str1 = " -ss " + chapters.FirstChapterStart.ToString("0.000", CultureInfo.InvariantCulture) + " -t " + (chapters.LastChapterStart - 1.0).ToString("0.000", CultureInfo.InvariantCulture) + " "; } - string ffmpegTags = tags.GenerateFfmpegTags(); - string ffmpegChapters = chapters.GenerateFfmpegChapters(); + var ffmpegTags = tags.GenerateFfmpegTags(); + var ffmpegChapters = chapters.GenerateFfmpegChapters(); File.WriteAllText(ff_txt_file, ffmpegTags + ffmpegChapters); var tagAndChapterInfo = new ProcessStartInfo diff --git a/AaxDecrypter/UNTESTED/Chapters.cs b/AaxDecrypter/UNTESTED/Chapters.cs index e92f563e..146e5b05 100644 --- a/AaxDecrypter/UNTESTED/Chapters.cs +++ b/AaxDecrypter/UNTESTED/Chapters.cs @@ -17,10 +17,10 @@ namespace AaxDecrypter public Chapters(string file, double totalTime) { - this.markers = getAAXChapters(file); + markers = getAAXChapters(file); // add end time - this.markers.Add(totalTime); + markers.Add(totalTime); } private static List getAAXChapters(string file) @@ -42,7 +42,7 @@ namespace AaxDecrypter } // subtract 1 b/c end time marker is a real entry but isn't a real chapter - public int Count() => this.markers.Count - 1; + public int Count() => markers.Count - 1; public string GetCuefromChapters(string fileName) { @@ -56,7 +56,7 @@ namespace AaxDecrypter { var chapter = i + 1; - var timeSpan = TimeSpan.FromSeconds(this.markers[i]); + var timeSpan = TimeSpan.FromSeconds(markers[i]); var minutes = Math.Floor(timeSpan.TotalMinutes).ToString(); var seconds = timeSpan.Seconds.ToString("D2"); var milliseconds = (timeSpan.Milliseconds / 10).ToString("D2"); @@ -78,8 +78,8 @@ namespace AaxDecrypter { var chapter = i + 1; - var start = this.markers[i] * 1000.0; - var end = this.markers[i + 1] * 1000.0; + var start = markers[i] * 1000.0; + var end = markers[i + 1] * 1000.0; var chapterName = chapter.ToString("D3"); stringBuilder.Append("[CHAPTER]\n"); diff --git a/AaxDecrypter/UNTESTED/Tags.cs b/AaxDecrypter/UNTESTED/Tags.cs index bd37dadc..25182600 100644 --- a/AaxDecrypter/UNTESTED/Tags.cs +++ b/AaxDecrypter/UNTESTED/Tags.cs @@ -1,9 +1,4 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Text; using TagLib; using TagLib.Mpeg4; using Dinah.Core; @@ -23,52 +18,50 @@ namespace AaxDecrypter public string genre { get; } public TimeSpan duration { get; } + // input file public Tags(string file) { - using TagLib.File tagLibFile = TagLib.File.Create(file, "audio/mp4", ReadStyle.Average); - this.title = tagLibFile.Tag.Title.Replace(" (Unabridged)", ""); - this.album = tagLibFile.Tag.Album.Replace(" (Unabridged)", ""); - this.author = tagLibFile.Tag.FirstPerformer ?? "[unknown]"; - this.year = tagLibFile.Tag.Year.ToString(); - this.comments = tagLibFile.Tag.Comment; - this.duration = tagLibFile.Properties.Duration; - this.genre = tagLibFile.Tag.FirstGenre; + using var tagLibFile = TagLib.File.Create(file, "audio/mp4", ReadStyle.Average); + title = tagLibFile.Tag.Title.Replace(" (Unabridged)", ""); + album = tagLibFile.Tag.Album.Replace(" (Unabridged)", ""); + author = tagLibFile.Tag.FirstPerformer ?? "[unknown]"; + year = tagLibFile.Tag.Year.ToString(); + comments = tagLibFile.Tag.Comment ?? ""; + duration = tagLibFile.Properties.Duration; + genre = tagLibFile.Tag.FirstGenre ?? ""; - var tag = tagLibFile.GetTag(TagTypes.Apple, true); - this.publisher = tag.Publisher; - this.narrator = string.IsNullOrWhiteSpace(tagLibFile.Tag.FirstComposer) ? tag.Narrator : tagLibFile.Tag.FirstComposer; - this.comments = !string.IsNullOrWhiteSpace(tag.LongDescription) ? tag.LongDescription : tag.Description; - this.id = tag.AudibleCDEK; + var tag = tagLibFile.GetTag(TagTypes.Apple, true); + publisher = tag.Publisher ?? ""; + narrator = string.IsNullOrWhiteSpace(tagLibFile.Tag.FirstComposer) ? tag.Narrator : tagLibFile.Tag.FirstComposer; + comments = !string.IsNullOrWhiteSpace(tag.LongDescription) ? tag.LongDescription : tag.Description; + id = tag.AudibleCDEK; } + // my best guess of what this step is doing: + // re-publish the data we read from the input file => output file public void AddAppleTags(string file) { - using var file1 = TagLib.File.Create(file, "audio/mp4", ReadStyle.Average); - var tag = (AppleTag)file1.GetTag(TagTypes.Apple, true); - tag.Publisher = this.publisher; - tag.LongDescription = this.comments; - tag.Description = this.comments; - file1.Save(); + using var tagLibFile = TagLib.File.Create(file, "audio/mp4", ReadStyle.Average); + var tag = (AppleTag)tagLibFile.GetTag(TagTypes.Apple, true); + tag.Publisher = publisher; + tag.LongDescription = comments; + tag.Description = comments; + tagLibFile.Save(); } public string GenerateFfmpegTags() - { - StringBuilder stringBuilder = new StringBuilder(); - - stringBuilder.Append(";FFMETADATA1\n"); - stringBuilder.Append("major_brand=aax\n"); - stringBuilder.Append("minor_version=1\n"); - stringBuilder.Append("compatible_brands=aax M4B mp42isom\n"); - stringBuilder.Append("date=" + this.year + "\n"); - stringBuilder.Append("genre=" + this.genre + "\n"); - stringBuilder.Append("title=" + this.title + "\n"); - stringBuilder.Append("artist=" + this.author + "\n"); - stringBuilder.Append("album=" + this.album + "\n"); - stringBuilder.Append("composer=" + this.narrator + "\n"); - stringBuilder.Append("comment=" + this.comments.Truncate(254) + "\n"); - stringBuilder.Append("description=" + this.comments + "\n"); - - return stringBuilder.ToString(); - } + => $";FFMETADATA1" + + $"\nmajor_brand=aax" + + $"\nminor_version=1" + + $"\ncompatible_brands=aax M4B mp42isom" + + $"\ndate={year}" + + $"\ngenre={genre}" + + $"\ntitle={title}" + + $"\nartist={author}" + + $"\nalbum={album}" + + $"\ncomposer={narrator}" + + $"\ncomment={comments.Truncate(254)}" + + $"\ndescription={comments}" + + $"\n"; } } diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index 4dfb99ba..cd36dfd1 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 3.1.1.0 + 3.1.2.0 diff --git a/REFERENCE.txt b/REFERENCE.txt index a2ba6681..b82d0bee 100644 --- a/REFERENCE.txt +++ b/REFERENCE.txt @@ -1,6 +1,7 @@ -- begin VERSIONING --------------------------------------------------------------------------------------------------------------------- https://github.com/rmcrackan/Libation/releases +v3.1.2 : null checks v3.1.1 : Check if upgrade available on github v3.1.0 : FIRST PUBLIC RELEASE v3.1-beta.11 : Improved configuration and settings file management. Configurable logging