Removed obsolete assembly reference and minor refactoring.

This commit is contained in:
Michael Bucari-Tovo 2021-06-30 01:12:34 -06:00
parent bc3aa29175
commit d6b62c0521
3 changed files with 18 additions and 30 deletions

View File

@ -8,12 +8,6 @@
<PackageReference Include="TagLibSharp" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="taglib-sharp">
<HintPath>lib\taglib-sharp.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Dinah.Core\Dinah.Core\Dinah.Core.csproj" />
</ItemGroup>

View File

@ -11,26 +11,23 @@ namespace AaxDecrypter
+ aaxcTagLib.Properties.Duration.Minutes + " minutes, "
+ aaxcTagLib.Properties.Duration.Seconds + " seconds";
var header
var nfoString
= "General Information\r\n"
+ "===================\r\n"
+ "======================\r\n"
+ $" Title: {aaxcTagLib.TitleSansUnabridged ?? "[unknown]"}\r\n"
+ $" Author: {aaxcTagLib.FirstAuthor ?? "[unknown]"}\r\n"
+ $" Read By: {aaxcTagLib.Narrator ?? "[unknown]"}\r\n"
+ $" Release Date: {aaxcTagLib.ReleaseDate ?? "[unknown]"}\r\n"
+ $" Book Copyright: {aaxcTagLib.BookCopyright ?? "[unknown]"}\r\n"
+ $" Recording Copyright: {aaxcTagLib.RecordingCopyright ?? "[unknown]"}\r\n"
+ $" Genre: {aaxcTagLib.AppleTags.FirstGenre ?? "[unknown]"}\r\n";
var s
= header
+ $" Genre: {aaxcTagLib.AppleTags.FirstGenre ?? "[unknown]"}\r\n"
+ $" Publisher: {aaxcTagLib.Publisher ?? "[unknown]"}\r\n"
+ $" Duration: {myDuration}\r\n"
+ $" Chapters: {chapters.Count}\r\n"
+ "\r\n"
+ "\r\n"
+ "Media Information\r\n"
+ "=================\r\n"
+ "======================\r\n"
+ " Source Format: Audible AAX\r\n"
+ $" Source Sample Rate: {aaxcTagLib.Properties.AudioSampleRate} Hz\r\n"
+ $" Source Channels: {aaxcTagLib.Properties.AudioChannels}\r\n"
@ -49,7 +46,7 @@ namespace AaxDecrypter
+ "================\r\n"
+ (!string.IsNullOrWhiteSpace(aaxcTagLib.LongDescription) ? aaxcTagLib.LongDescription : aaxcTagLib.Comment);
return s;
return nfoString;
}
}
}

View File

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using TagLib;
using TagLib.Mpeg4;
@ -41,38 +37,39 @@ namespace AaxDecrypter
Comment = AppleTags.Comment is not null ? unicodeToAscii(AppleTags.Comment) : default;
//TagLib uses @ART, which is the Artist tag
//TagLib uses @ART ID for Performers, 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);
Publisher = text.Length == 0 ? null : text[0];
Publisher = text.Length == 0 ? default : text[0];
text = AppleTags.GetText("rldt");
ReleaseDate = text.Length == 0 ? null : text[0];
ReleaseDate = text.Length == 0 ? default : text[0];
text = AppleTags.GetText(descriptionType);
LongDescription = text.Length == 0 ? null : unicodeToAscii(text[0]);
LongDescription = text.Length == 0 ? default : unicodeToAscii(text[0]);
text = AppleTags.GetText(naratorType);
Narrator = text.Length == 0 ? null : unicodeToAscii(text[0]);
Narrator = text.Length == 0 ? default : unicodeToAscii(text[0]);
}
public AaxcTagLibFile(string path)
: this(new LocalFileAbstraction(path))
{
}
/// <summary>
/// Copy all metadata fields in the source file, even those that TagLib doesn't
/// recognize, to the output file.
/// NOTE: Chapters aren't stored in MPEG-4 metadata. They are encoded as a Timed
/// Text Stream (MPEG-4 Part 17), so taglib doesn't read or write them.
/// </summary>
/// <param name="sourceFile">File from which tags will be coppied.</param>
public void CopyTagsFrom(AaxcTagLibFile sourceFile)
{
AppleTags.Clear();
//copy all metadata fields in the source file, even those that TagLib doesn't
//recognize, to the output file.
//NOTE: Chapters aren't stored in MPEG-4 metadata. They are encoded as a Timed
//Text Stream (MPEG-4 Part 17), so taglib doesn't read or write them.
foreach (var stag in sourceFile.AppleTags)
{
AppleTags.SetData(stag.BoxType, stag.Children.Cast<AppleDataBox>().ToArray());