Bug fix: first line in cue file was incorrectly formatted
This commit is contained in:
parent
f55a3ca008
commit
215c539920
@ -102,8 +102,8 @@ namespace AaxDecrypter
|
|||||||
|
|
||||||
var defaultFilename = Path.Combine(
|
var defaultFilename = Path.Combine(
|
||||||
Path.GetDirectoryName(inputFileName),
|
Path.GetDirectoryName(inputFileName),
|
||||||
getASCIITag(tags.author),
|
PathLib.ToPathSafeString(tags.author),
|
||||||
getASCIITag(tags.title) + ".m4b"
|
PathLib.ToPathSafeString(tags.title) + ".m4b"
|
||||||
);
|
);
|
||||||
|
|
||||||
// set default name
|
// set default name
|
||||||
@ -111,12 +111,6 @@ namespace AaxDecrypter
|
|||||||
|
|
||||||
await Task.Run(() => saveCover(inputFileName));
|
await Task.Run(() => saveCover(inputFileName));
|
||||||
}
|
}
|
||||||
private string getASCIITag(string property)
|
|
||||||
{
|
|
||||||
foreach (char ch in new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()))
|
|
||||||
property = property.Replace(ch.ToString(), "");
|
|
||||||
return property;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveCover(string aaxFile)
|
private void saveCover(string aaxFile)
|
||||||
{
|
{
|
||||||
@ -126,19 +120,14 @@ namespace AaxDecrypter
|
|||||||
|
|
||||||
private void printPrelim()
|
private void printPrelim()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Audible Book ID = " + tags.id);
|
Console.WriteLine($"Audible Book ID = {tags.id}");
|
||||||
|
|
||||||
Console.WriteLine("Book: " + tags.title);
|
Console.WriteLine($"Book: {tags.title}");
|
||||||
Console.WriteLine("Author: " + tags.author);
|
Console.WriteLine($"Author: {tags.author}");
|
||||||
Console.WriteLine("Narrator: " + tags.narrator);
|
Console.WriteLine($"Narrator: {tags.narrator}");
|
||||||
Console.WriteLine("Year: " + tags.year);
|
Console.WriteLine($"Year: {tags.year}");
|
||||||
Console.WriteLine("Total Time: "
|
Console.WriteLine($"Total Time: {tags.duration.GetTotalTimeFormatted()} in {chapters.Count} chapters");
|
||||||
+ tags.duration.GetTotalTimeFormatted()
|
Console.WriteLine($"WARNING-Source is {encodingInfo.originalBitrate} kbits @ {encodingInfo.sampleRate}Hz, {encodingInfo.channels} channels");
|
||||||
+ " in " + chapters.Count() + " chapters");
|
|
||||||
Console.WriteLine("WARNING-Source is "
|
|
||||||
+ encodingInfo.originalBitrate + " kbits @ "
|
|
||||||
+ encodingInfo.sampleRate + "Hz, "
|
|
||||||
+ encodingInfo.channels + " channels");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Run()
|
public bool Run()
|
||||||
@ -159,19 +148,14 @@ namespace AaxDecrypter
|
|||||||
|
|
||||||
public void SetOutputFilename(string outFileName)
|
public void SetOutputFilename(string outFileName)
|
||||||
{
|
{
|
||||||
outputFileName = outFileName;
|
outputFileName = PathLib.ReplaceExtension(outFileName, ".m4b");
|
||||||
|
outDir = Path.GetDirectoryName(outputFileName);
|
||||||
if (Path.GetExtension(outputFileName) != ".m4b")
|
|
||||||
outputFileName = outputFileWithNewExt(".m4b");
|
|
||||||
|
|
||||||
if (File.Exists(outputFileName))
|
if (File.Exists(outputFileName))
|
||||||
File.Delete(outputFileName);
|
File.Delete(outputFileName);
|
||||||
|
|
||||||
outDir = Path.GetDirectoryName(outputFileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string outputFileWithNewExt(string extension)
|
private string outputFileWithNewExt(string extension) => PathLib.ReplaceExtension(outputFileName, extension);
|
||||||
=> Path.Combine(outDir, Path.GetFileNameWithoutExtension(outputFileName) + '.' + extension.Trim('.'));
|
|
||||||
|
|
||||||
public bool Step1_CreateDir()
|
public bool Step1_CreateDir()
|
||||||
{
|
{
|
||||||
@ -349,13 +333,13 @@ namespace AaxDecrypter
|
|||||||
|
|
||||||
public bool End_CreateCue()
|
public bool End_CreateCue()
|
||||||
{
|
{
|
||||||
File.WriteAllText(outputFileWithNewExt(".cue"), chapters.GetCuefromChapters(Path.GetFileName(outputFileName)));
|
File.WriteAllText(outputFileWithNewExt(".cue"), Cue.CreateContents(Path.GetFileName(outputFileName), chapters));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool End_CreateNfo()
|
public bool End_CreateNfo()
|
||||||
{
|
{
|
||||||
File.WriteAllText(outputFileWithNewExt(".nfo"), NFO.CreateNfoContents(AppName, tags, encodingInfo, chapters));
|
File.WriteAllText(outputFileWithNewExt(".nfo"), NFO.CreateContents(AppName, tags, encodingInfo, chapters));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,40 +41,20 @@ namespace AaxDecrypter
|
|||||||
return chapters;
|
return chapters;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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. ie: fencepost
|
||||||
public int Count() => markers.Count - 1;
|
public int Count => markers.Count - 1;
|
||||||
|
|
||||||
public string GetCuefromChapters(string fileName)
|
public IEnumerable<TimeSpan> GetBeginningTimes()
|
||||||
{
|
{
|
||||||
var stringBuilder = new StringBuilder();
|
for (var i = 0; i < Count; i++)
|
||||||
if (fileName != "")
|
yield return TimeSpan.FromSeconds(markers[i]);
|
||||||
{
|
|
||||||
stringBuilder.Append("FILE \"" + fileName + "\" MP4\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < Count(); i++)
|
|
||||||
{
|
|
||||||
var chapter = i + 1;
|
|
||||||
|
|
||||||
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");
|
|
||||||
string str = minutes + ":" + seconds + ":" + milliseconds;
|
|
||||||
|
|
||||||
stringBuilder.Append("TRACK " + chapter + " AUDIO\n");
|
|
||||||
stringBuilder.Append(" TITLE \"Chapter " + chapter.ToString("D2") + "\"\n");
|
|
||||||
stringBuilder.Append(" INDEX 01 " + str + "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return stringBuilder.ToString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GenerateFfmpegChapters()
|
public string GenerateFfmpegChapters()
|
||||||
{
|
{
|
||||||
var stringBuilder = new StringBuilder();
|
var stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
for (var i = 0; i < Count(); i++)
|
for (var i = 0; i < Count; i++)
|
||||||
{
|
{
|
||||||
var chapter = i + 1;
|
var chapter = i + 1;
|
||||||
|
|
||||||
|
|||||||
65
AaxDecrypter/UNTESTED/Cue.cs
Normal file
65
AaxDecrypter/UNTESTED/Cue.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Dinah.Core;
|
||||||
|
|
||||||
|
namespace AaxDecrypter
|
||||||
|
{
|
||||||
|
public static class Cue
|
||||||
|
{
|
||||||
|
public static string CreateContents(string filePath, Chapters chapters)
|
||||||
|
{
|
||||||
|
var stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
stringBuilder.AppendLine(GetFileLine(filePath, "MP3"));
|
||||||
|
|
||||||
|
var beginningTimes = chapters.GetBeginningTimes().ToList();
|
||||||
|
for (var i = 0; i < beginningTimes.Count; i++)
|
||||||
|
{
|
||||||
|
var chapter = i + 1;
|
||||||
|
|
||||||
|
var timeSpan = beginningTimes[i];
|
||||||
|
var minutes = Math.Floor(timeSpan.TotalMinutes).ToString();
|
||||||
|
var seconds = timeSpan.Seconds.ToString("D2");
|
||||||
|
var milliseconds = (timeSpan.Milliseconds / 10).ToString("D2");
|
||||||
|
var time = minutes + ":" + seconds + ":" + milliseconds;
|
||||||
|
|
||||||
|
stringBuilder.AppendLine($"TRACK {chapter} AUDIO");
|
||||||
|
stringBuilder.AppendLine($" TITLE \"Chapter {chapter:D2}\"");
|
||||||
|
stringBuilder.AppendLine($" INDEX 01 {time}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return stringBuilder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UpdateFileName(FileInfo cueFileInfo, string audioFilePath)
|
||||||
|
=> UpdateFileName(cueFileInfo.FullName, audioFilePath);
|
||||||
|
|
||||||
|
public static void UpdateFileName(string cueFilePath, FileInfo audioFileInfo)
|
||||||
|
=> UpdateFileName(cueFilePath, audioFileInfo.FullName);
|
||||||
|
|
||||||
|
public static void UpdateFileName(FileInfo cueFileInfo, FileInfo audioFileInfo)
|
||||||
|
=> UpdateFileName(cueFileInfo.FullName, audioFileInfo.FullName);
|
||||||
|
|
||||||
|
public static void UpdateFileName(string cueFilePath, string audioFilePath)
|
||||||
|
{
|
||||||
|
var cueContents = File.ReadAllLines(cueFilePath);
|
||||||
|
|
||||||
|
for (var i = 0; i < cueContents.Length; i++)
|
||||||
|
{
|
||||||
|
var line = cueContents[i];
|
||||||
|
if (!line.Trim().StartsWith("FILE") || !line.Contains(" "))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var fileTypeBegins = line.LastIndexOf(" ") + 1;
|
||||||
|
cueContents[i] = GetFileLine(audioFilePath, line[fileTypeBegins..]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
File.WriteAllLines(cueFilePath, cueContents);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetFileLine(string filePath, string audioType) => $"FILE {Path.GetFileName(filePath).SurroundWithQuotes()} {audioType}";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,48 +2,46 @@
|
|||||||
{
|
{
|
||||||
public static class NFO
|
public static class NFO
|
||||||
{
|
{
|
||||||
public static string CreateNfoContents(string ripper, Tags tags, EncodingInfo encodingInfo, Chapters chapters)
|
public static string CreateContents(string ripper, Tags tags, EncodingInfo encodingInfo, Chapters chapters)
|
||||||
{
|
{
|
||||||
int _hours = (int)tags.duration.TotalHours;
|
var _hours = (int)tags.duration.TotalHours;
|
||||||
string myDuration
|
var myDuration
|
||||||
= (_hours > 0 ? _hours + " hours, " : "")
|
= (_hours > 0 ? _hours + " hours, " : "")
|
||||||
+ tags.duration.Minutes + " minutes, "
|
+ tags.duration.Minutes + " minutes, "
|
||||||
+ tags.duration.Seconds + " seconds";
|
+ tags.duration.Seconds + " seconds";
|
||||||
|
|
||||||
string str4
|
var header
|
||||||
= "General Information\r\n"
|
= "General Information\r\n"
|
||||||
+ "===================\r\n"
|
+ "===================\r\n"
|
||||||
+ " Title: " + tags.title + "\r\n"
|
+ $" Title: {tags.title}\r\n"
|
||||||
+ " Author: " + tags.author + "\r\n"
|
+ $" Author: {tags.author}\r\n"
|
||||||
+ " Read By: " + tags.narrator + "\r\n"
|
+ $" Read By: {tags.narrator}\r\n"
|
||||||
+ " Copyright: " + tags.year + "\r\n"
|
+ $" Copyright: {tags.year}\r\n"
|
||||||
+ " Audiobook Copyright: " + tags.year + "\r\n";
|
+ $" Audiobook Copyright: {tags.year}\r\n";
|
||||||
if (tags.genre != "")
|
if (tags.genre != "")
|
||||||
{
|
header += $" Genre: {tags.genre}\r\n";
|
||||||
str4 = str4 + " Genre: " + tags.genre + "\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
string s
|
var s
|
||||||
= str4
|
= header
|
||||||
+ " Publisher: " + tags.publisher + "\r\n"
|
+ $" Publisher: {tags.publisher}\r\n"
|
||||||
+ " Duration: " + myDuration + "\r\n"
|
+ $" Duration: {myDuration}\r\n"
|
||||||
+ " Chapters: " + chapters.Count() + "\r\n"
|
+ $" Chapters: {chapters.Count}\r\n"
|
||||||
+ "\r\n"
|
+ "\r\n"
|
||||||
+ "\r\n"
|
+ "\r\n"
|
||||||
+ "Media Information\r\n"
|
+ "Media Information\r\n"
|
||||||
+ "=================\r\n"
|
+ "=================\r\n"
|
||||||
+ " Source Format: Audible AAX\r\n"
|
+ " Source Format: Audible AAX\r\n"
|
||||||
+ " Source Sample Rate: " + encodingInfo.sampleRate + " Hz\r\n"
|
+ $" Source Sample Rate: {encodingInfo.sampleRate} Hz\r\n"
|
||||||
+ " Source Channels: " + encodingInfo.channels + "\r\n"
|
+ $" Source Channels: {encodingInfo.channels}\r\n"
|
||||||
+ " Source Bitrate: " + encodingInfo.originalBitrate + " kbits\r\n"
|
+ $" Source Bitrate: {encodingInfo.originalBitrate} kbits\r\n"
|
||||||
+ "\r\n"
|
+ "\r\n"
|
||||||
+ " Lossless Encode: Yes\r\n"
|
+ " Lossless Encode: Yes\r\n"
|
||||||
+ " Encoded Codec: AAC / M4B\r\n"
|
+ " Encoded Codec: AAC / M4B\r\n"
|
||||||
+ " Encoded Sample Rate: " + encodingInfo.sampleRate + " Hz\r\n"
|
+ $" Encoded Sample Rate: {encodingInfo.sampleRate} Hz\r\n"
|
||||||
+ " Encoded Channels: " + encodingInfo.channels + "\r\n"
|
+ $" Encoded Channels: {encodingInfo.channels}\r\n"
|
||||||
+ " Encoded Bitrate: " + encodingInfo.originalBitrate + " kbits\r\n"
|
+ $" Encoded Bitrate: {encodingInfo.originalBitrate} kbits\r\n"
|
||||||
+ "\r\n"
|
+ "\r\n"
|
||||||
+ " Ripper: " + ripper + "\r\n"
|
+ $" Ripper: {ripper}\r\n"
|
||||||
+ "\r\n"
|
+ "\r\n"
|
||||||
+ "\r\n"
|
+ "\r\n"
|
||||||
+ "Book Description\r\n"
|
+ "Book Description\r\n"
|
||||||
|
|||||||
@ -144,14 +144,20 @@ namespace FileLiberator
|
|||||||
|
|
||||||
var musicFileExt = Path.GetExtension(outputAudioFilename).Trim('.');
|
var musicFileExt = Path.GetExtension(outputAudioFilename).Trim('.');
|
||||||
|
|
||||||
|
// audio filename: safetitle_limit50char + " [" + productId + "]." + audio_ext
|
||||||
|
var audioFileName = FileUtility.GetValidFilename(destinationDir, product.Title, musicFileExt, product.AudibleProductId);
|
||||||
|
|
||||||
foreach (var f in sortedFiles)
|
foreach (var f in sortedFiles)
|
||||||
{
|
{
|
||||||
var dest = AudibleFileStorage.Audio.IsFileTypeMatch(f)
|
var dest
|
||||||
// audio filename: safetitle_limit50char + " [" + productId + "]." + audio_ext
|
= AudibleFileStorage.Audio.IsFileTypeMatch(f)
|
||||||
? FileUtility.GetValidFilename(destinationDir, product.Title, musicFileExt, product.AudibleProductId)
|
? audioFileName
|
||||||
// non-audio filename: safetitle_limit50char + " [" + productId + "][" + audio_ext +"]." + non_audio_ext
|
// non-audio filename: safetitle_limit50char + " [" + productId + "][" + audio_ext +"]." + non_audio_ext
|
||||||
: FileUtility.GetValidFilename(destinationDir, product.Title, f.Extension, product.AudibleProductId, musicFileExt);
|
: FileUtility.GetValidFilename(destinationDir, product.Title, f.Extension, product.AudibleProductId, musicFileExt);
|
||||||
|
|
||||||
|
if (Path.GetExtension(dest).Trim('.').ToLower() == "cue")
|
||||||
|
Cue.UpdateFileName(f, audioFileName);
|
||||||
|
|
||||||
File.Move(f.FullName, dest);
|
File.Move(f.FullName, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
|
||||||
<Version>4.2.3.1</Version>
|
<Version>4.2.4.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -380,19 +380,25 @@ namespace LibationLauncher
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
LibationWinForms.BookLiberation.ProcessorAutomationController.DownloadFileAsync(zipUrl, selectedPath).GetAwaiter().GetResult();
|
LibationWinForms.BookLiberation.ProcessorAutomationController.DownloadFileAsync(zipUrl, selectedPath).GetAwaiter().GetResult();
|
||||||
MessageBox.Show($"File downloaded");
|
MessageBox.Show("File downloaded");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"ERROR: {ex.Message}\r\n{ex.StackTrace}");
|
Error(ex, "Error downloading update");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"Error checking for update. ERROR: {ex.Message}\r\n{ex.StackTrace}");
|
Error(ex, "Error checking for update");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void Error(Exception ex, string message)
|
||||||
|
{
|
||||||
|
Log.Logger.Error(ex, message);
|
||||||
|
MessageBox.Show($"{message}\r\nSee log for details");
|
||||||
|
}
|
||||||
|
|
||||||
private static void logStartupState()
|
private static void logStartupState()
|
||||||
{
|
{
|
||||||
var config = Configuration.Instance;
|
var config = Configuration.Instance;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user