null checks
This commit is contained in:
parent
f93498bfe3
commit
9abb9e376d
@ -293,14 +293,14 @@ namespace AaxDecrypter
|
|||||||
|
|
||||||
public bool Step3_Chapterize()
|
public bool Step3_Chapterize()
|
||||||
{
|
{
|
||||||
string str1 = "";
|
var str1 = "";
|
||||||
if (chapters.FirstChapterStart != 0.0)
|
if (chapters.FirstChapterStart != 0.0)
|
||||||
{
|
{
|
||||||
str1 = " -ss " + chapters.FirstChapterStart.ToString("0.000", CultureInfo.InvariantCulture) + " -t " + (chapters.LastChapterStart - 1.0).ToString("0.000", CultureInfo.InvariantCulture) + " ";
|
str1 = " -ss " + chapters.FirstChapterStart.ToString("0.000", CultureInfo.InvariantCulture) + " -t " + (chapters.LastChapterStart - 1.0).ToString("0.000", CultureInfo.InvariantCulture) + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
string ffmpegTags = tags.GenerateFfmpegTags();
|
var ffmpegTags = tags.GenerateFfmpegTags();
|
||||||
string ffmpegChapters = chapters.GenerateFfmpegChapters();
|
var ffmpegChapters = chapters.GenerateFfmpegChapters();
|
||||||
File.WriteAllText(ff_txt_file, ffmpegTags + ffmpegChapters);
|
File.WriteAllText(ff_txt_file, ffmpegTags + ffmpegChapters);
|
||||||
|
|
||||||
var tagAndChapterInfo = new ProcessStartInfo
|
var tagAndChapterInfo = new ProcessStartInfo
|
||||||
|
|||||||
@ -17,10 +17,10 @@ namespace AaxDecrypter
|
|||||||
|
|
||||||
public Chapters(string file, double totalTime)
|
public Chapters(string file, double totalTime)
|
||||||
{
|
{
|
||||||
this.markers = getAAXChapters(file);
|
markers = getAAXChapters(file);
|
||||||
|
|
||||||
// add end time
|
// add end time
|
||||||
this.markers.Add(totalTime);
|
markers.Add(totalTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<double> getAAXChapters(string file)
|
private static List<double> 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
|
// 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)
|
public string GetCuefromChapters(string fileName)
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@ namespace AaxDecrypter
|
|||||||
{
|
{
|
||||||
var chapter = i + 1;
|
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 minutes = Math.Floor(timeSpan.TotalMinutes).ToString();
|
||||||
var seconds = timeSpan.Seconds.ToString("D2");
|
var seconds = timeSpan.Seconds.ToString("D2");
|
||||||
var milliseconds = (timeSpan.Milliseconds / 10).ToString("D2");
|
var milliseconds = (timeSpan.Milliseconds / 10).ToString("D2");
|
||||||
@ -78,8 +78,8 @@ namespace AaxDecrypter
|
|||||||
{
|
{
|
||||||
var chapter = i + 1;
|
var chapter = i + 1;
|
||||||
|
|
||||||
var start = this.markers[i] * 1000.0;
|
var start = markers[i] * 1000.0;
|
||||||
var end = this.markers[i + 1] * 1000.0;
|
var end = markers[i + 1] * 1000.0;
|
||||||
var chapterName = chapter.ToString("D3");
|
var chapterName = chapter.ToString("D3");
|
||||||
|
|
||||||
stringBuilder.Append("[CHAPTER]\n");
|
stringBuilder.Append("[CHAPTER]\n");
|
||||||
|
|||||||
@ -1,9 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
using TagLib;
|
using TagLib;
|
||||||
using TagLib.Mpeg4;
|
using TagLib.Mpeg4;
|
||||||
using Dinah.Core;
|
using Dinah.Core;
|
||||||
@ -23,52 +18,50 @@ namespace AaxDecrypter
|
|||||||
public string genre { get; }
|
public string genre { get; }
|
||||||
public TimeSpan duration { get; }
|
public TimeSpan duration { get; }
|
||||||
|
|
||||||
|
// input file
|
||||||
public Tags(string file)
|
public Tags(string file)
|
||||||
{
|
{
|
||||||
using TagLib.File tagLibFile = TagLib.File.Create(file, "audio/mp4", ReadStyle.Average);
|
using var tagLibFile = TagLib.File.Create(file, "audio/mp4", ReadStyle.Average);
|
||||||
this.title = tagLibFile.Tag.Title.Replace(" (Unabridged)", "");
|
title = tagLibFile.Tag.Title.Replace(" (Unabridged)", "");
|
||||||
this.album = tagLibFile.Tag.Album.Replace(" (Unabridged)", "");
|
album = tagLibFile.Tag.Album.Replace(" (Unabridged)", "");
|
||||||
this.author = tagLibFile.Tag.FirstPerformer ?? "[unknown]";
|
author = tagLibFile.Tag.FirstPerformer ?? "[unknown]";
|
||||||
this.year = tagLibFile.Tag.Year.ToString();
|
year = tagLibFile.Tag.Year.ToString();
|
||||||
this.comments = tagLibFile.Tag.Comment;
|
comments = tagLibFile.Tag.Comment ?? "";
|
||||||
this.duration = tagLibFile.Properties.Duration;
|
duration = tagLibFile.Properties.Duration;
|
||||||
this.genre = tagLibFile.Tag.FirstGenre;
|
genre = tagLibFile.Tag.FirstGenre ?? "";
|
||||||
|
|
||||||
var tag = tagLibFile.GetTag(TagTypes.Apple, true);
|
var tag = tagLibFile.GetTag(TagTypes.Apple, true);
|
||||||
this.publisher = tag.Publisher;
|
publisher = tag.Publisher ?? "";
|
||||||
this.narrator = string.IsNullOrWhiteSpace(tagLibFile.Tag.FirstComposer) ? tag.Narrator : tagLibFile.Tag.FirstComposer;
|
narrator = string.IsNullOrWhiteSpace(tagLibFile.Tag.FirstComposer) ? tag.Narrator : tagLibFile.Tag.FirstComposer;
|
||||||
this.comments = !string.IsNullOrWhiteSpace(tag.LongDescription) ? tag.LongDescription : tag.Description;
|
comments = !string.IsNullOrWhiteSpace(tag.LongDescription) ? tag.LongDescription : tag.Description;
|
||||||
this.id = tag.AudibleCDEK;
|
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)
|
public void AddAppleTags(string file)
|
||||||
{
|
{
|
||||||
using var file1 = TagLib.File.Create(file, "audio/mp4", ReadStyle.Average);
|
using var tagLibFile = TagLib.File.Create(file, "audio/mp4", ReadStyle.Average);
|
||||||
var tag = (AppleTag)file1.GetTag(TagTypes.Apple, true);
|
var tag = (AppleTag)tagLibFile.GetTag(TagTypes.Apple, true);
|
||||||
tag.Publisher = this.publisher;
|
tag.Publisher = publisher;
|
||||||
tag.LongDescription = this.comments;
|
tag.LongDescription = comments;
|
||||||
tag.Description = this.comments;
|
tag.Description = comments;
|
||||||
file1.Save();
|
tagLibFile.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GenerateFfmpegTags()
|
public string GenerateFfmpegTags()
|
||||||
{
|
=> $";FFMETADATA1"
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
+ $"\nmajor_brand=aax"
|
||||||
|
+ $"\nminor_version=1"
|
||||||
stringBuilder.Append(";FFMETADATA1\n");
|
+ $"\ncompatible_brands=aax M4B mp42isom"
|
||||||
stringBuilder.Append("major_brand=aax\n");
|
+ $"\ndate={year}"
|
||||||
stringBuilder.Append("minor_version=1\n");
|
+ $"\ngenre={genre}"
|
||||||
stringBuilder.Append("compatible_brands=aax M4B mp42isom\n");
|
+ $"\ntitle={title}"
|
||||||
stringBuilder.Append("date=" + this.year + "\n");
|
+ $"\nartist={author}"
|
||||||
stringBuilder.Append("genre=" + this.genre + "\n");
|
+ $"\nalbum={album}"
|
||||||
stringBuilder.Append("title=" + this.title + "\n");
|
+ $"\ncomposer={narrator}"
|
||||||
stringBuilder.Append("artist=" + this.author + "\n");
|
+ $"\ncomment={comments.Truncate(254)}"
|
||||||
stringBuilder.Append("album=" + this.album + "\n");
|
+ $"\ndescription={comments}"
|
||||||
stringBuilder.Append("composer=" + this.narrator + "\n");
|
+ $"\n";
|
||||||
stringBuilder.Append("comment=" + this.comments.Truncate(254) + "\n");
|
|
||||||
stringBuilder.Append("description=" + this.comments + "\n");
|
|
||||||
|
|
||||||
return stringBuilder.ToString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
|
||||||
<Version>3.1.1.0</Version>
|
<Version>3.1.2.0</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
-- begin VERSIONING ---------------------------------------------------------------------------------------------------------------------
|
-- begin VERSIONING ---------------------------------------------------------------------------------------------------------------------
|
||||||
https://github.com/rmcrackan/Libation/releases
|
https://github.com/rmcrackan/Libation/releases
|
||||||
|
|
||||||
|
v3.1.2 : null checks
|
||||||
v3.1.1 : Check if upgrade available on github
|
v3.1.1 : Check if upgrade available on github
|
||||||
v3.1.0 : FIRST PUBLIC RELEASE
|
v3.1.0 : FIRST PUBLIC RELEASE
|
||||||
v3.1-beta.11 : Improved configuration and settings file management. Configurable logging
|
v3.1-beta.11 : Improved configuration and settings file management. Configurable logging
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user