Minor tag reading improvements.

This commit is contained in:
Michael Bucari-Tovo 2021-06-30 01:06:22 -06:00
parent e958944466
commit bc3aa29175
2 changed files with 15 additions and 11 deletions

View File

@ -5,8 +5,6 @@ namespace AaxDecrypter
{ {
public static string CreateContents(string ripper, AaxcTagLibFile aaxcTagLib, ChapterInfo chapters) public static string CreateContents(string ripper, AaxcTagLibFile aaxcTagLib, ChapterInfo chapters)
{ {
var tag = aaxcTagLib.AppleTags;
var _hours = (int)aaxcTagLib.Properties.Duration.TotalHours; var _hours = (int)aaxcTagLib.Properties.Duration.TotalHours;
var myDuration var myDuration
= (_hours > 0 ? _hours + " hours, " : string.Empty) = (_hours > 0 ? _hours + " hours, " : string.Empty)
@ -21,13 +19,12 @@ namespace AaxDecrypter
+ $" Read By: {aaxcTagLib.Narrator ?? "[unknown]"}\r\n" + $" Read By: {aaxcTagLib.Narrator ?? "[unknown]"}\r\n"
+ $" Release Date: {aaxcTagLib.ReleaseDate ?? "[unknown]"}\r\n" + $" Release Date: {aaxcTagLib.ReleaseDate ?? "[unknown]"}\r\n"
+ $" Book Copyright: {aaxcTagLib.BookCopyright ?? "[unknown]"}\r\n" + $" Book Copyright: {aaxcTagLib.BookCopyright ?? "[unknown]"}\r\n"
+ $" Recording Copyright: {aaxcTagLib.RecordingCopyright ?? "[unknown]"}\r\n"; + $" Recording Copyright: {aaxcTagLib.RecordingCopyright ?? "[unknown]"}\r\n"
if (!string.IsNullOrEmpty(tag.FirstGenre)) + $" Genre: {aaxcTagLib.AppleTags.FirstGenre ?? "[unknown]"}\r\n";
header += $" Genre: {aaxcTagLib.AppleTags.FirstGenre}\r\n";
var s var s
= header = header
+ $" Publisher: {aaxcTagLib.Publisher ?? string.Empty}\r\n" + $" Publisher: {aaxcTagLib.Publisher ?? "[unknown]"}\r\n"
+ $" Duration: {myDuration}\r\n" + $" Duration: {myDuration}\r\n"
+ $" Chapters: {chapters.Count}\r\n" + $" Chapters: {chapters.Count}\r\n"
+ "\r\n" + "\r\n"
@ -50,7 +47,7 @@ namespace AaxDecrypter
+ "\r\n" + "\r\n"
+ "Book Description\r\n" + "Book Description\r\n"
+ "================\r\n" + "================\r\n"
+ (!string.IsNullOrWhiteSpace(aaxcTagLib.LongDescription) ? aaxcTagLib.LongDescription : aaxcTagLib.Tag.Comment); + (!string.IsNullOrWhiteSpace(aaxcTagLib.LongDescription) ? aaxcTagLib.LongDescription : aaxcTagLib.Comment);
return s; return s;
} }

View File

@ -17,11 +17,11 @@ namespace AaxDecrypter
private static ReadOnlyByteVector descriptionType = new ReadOnlyByteVector(0xa9, (byte)'d', (byte)'e', (byte)'s'); private static ReadOnlyByteVector descriptionType = new ReadOnlyByteVector(0xa9, (byte)'d', (byte)'e', (byte)'s');
private static ReadOnlyByteVector publisherType = new ReadOnlyByteVector(0xa9, (byte)'p', (byte)'u', (byte)'b'); private static ReadOnlyByteVector publisherType = new ReadOnlyByteVector(0xa9, (byte)'p', (byte)'u', (byte)'b');
public string Narrator { get; } public string Narrator { get; }
public string Comment { get; }
public string LongDescription { get; } public string LongDescription { get; }
public string ReleaseDate { get; } public string ReleaseDate { get; }
public string Publisher { get; } public string Publisher { get; }
//TagLib uses @ART, which is the Artist tag public string[] Authors { get; }
public string[] Authors => AppleTags.Performers;
public string FirstAuthor { get; } public string FirstAuthor { get; }
public string TitleSansUnabridged { get; } public string TitleSansUnabridged { get; }
public string BookCopyright { get; } public string BookCopyright { get; }
@ -39,7 +39,12 @@ namespace AaxDecrypter
TitleSansUnabridged = AppleTags.Title?.Replace(" (Unabridged)", ""); TitleSansUnabridged = AppleTags.Title?.Replace(" (Unabridged)", "");
FirstAuthor = Authors?.Length > 0 ? unicodeToAscii(Authors[0]) : default; Comment = AppleTags.Comment is not null ? unicodeToAscii(AppleTags.Comment) : default;
//TagLib uses @ART, which is the Artist tag
Authors = AppleTags.Performers.Select(author => unicodeToAscii(author)).ToArray();
FirstAuthor = Authors?.Length > 0 ? Authors[0] : default;
string[] text = AppleTags.GetText(publisherType); string[] text = AppleTags.GetText(publisherType);
Publisher = text.Length == 0 ? null : text[0]; Publisher = text.Length == 0 ? null : text[0];
@ -55,9 +60,11 @@ namespace AaxDecrypter
} }
public AaxcTagLibFile(string path) : this(new LocalFileAbstraction(path)) public AaxcTagLibFile(string path)
: this(new LocalFileAbstraction(path))
{ {
} }
public void CopyTagsFrom(AaxcTagLibFile sourceFile) public void CopyTagsFrom(AaxcTagLibFile sourceFile)
{ {
AppleTags.Clear(); AppleTags.Clear();