Minor refactoring.
This commit is contained in:
parent
05d52e64e5
commit
54ceba816a
@ -4,19 +4,14 @@ using Dinah.Core.ErrorHandling;
|
||||
using Dinah.Core.IO;
|
||||
using FileManager;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FileLiberator
|
||||
{
|
||||
public class ConvertToMp3 : IDecryptable
|
||||
{
|
||||
|
||||
private Mp4File m4bBook;
|
||||
|
||||
public event EventHandler<string> DecryptBegin;
|
||||
public event EventHandler<string> TitleDiscovered;
|
||||
public event EventHandler<string> AuthorsDiscovered;
|
||||
@ -28,14 +23,18 @@ namespace FileLiberator
|
||||
public event EventHandler<LibraryBook> Begin;
|
||||
public event EventHandler<LibraryBook> Completed;
|
||||
|
||||
|
||||
public event EventHandler<string> StatusUpdate;
|
||||
public event EventHandler<Action<byte[]>> RequestCoverArt;
|
||||
|
||||
private Mp4File m4bBook;
|
||||
|
||||
private string Mp3FileName(LibraryBook libraryBook)
|
||||
{
|
||||
string m4bPath = AudibleFileStorage.Audio.GetPath(libraryBook.Book.AudibleProductId);
|
||||
|
||||
if (m4bPath is null)
|
||||
return string.Empty;
|
||||
|
||||
return Path.Combine(Path.GetDirectoryName(m4bPath), Path.GetFileNameWithoutExtension(m4bPath) + ".mp3");
|
||||
}
|
||||
public void Cancel()
|
||||
@ -65,7 +64,6 @@ namespace FileLiberator
|
||||
NarratorsDiscovered?.Invoke(this, m4bBook.AppleTags.Narrator);
|
||||
CoverImageFilepathDiscovered?.Invoke(this, m4bBook.AppleTags.Cover);
|
||||
|
||||
|
||||
var mp3File = File.OpenWrite(Path.GetTempFileName());
|
||||
|
||||
var result = await Task.Run(() => m4bBook.ConvertToMp3(mp3File));
|
||||
|
||||
@ -104,6 +104,7 @@ namespace LibationWinForms.BookLiberation
|
||||
convertBook.Begin -= decryptBookBegin;
|
||||
convertBook.StatusUpdate -= statusUpdate;
|
||||
convertBook.Completed -= decryptBookCompleted;
|
||||
convertBook.Completed -= updateLiberatedStatus;
|
||||
}
|
||||
|
||||
private static BackupBook getWiredUpBackupBook(EventHandler<LibraryBook> completedAction)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user