From fb9b4eb77e9f34275569851ed86522c4368a0343 Mon Sep 17 00:00:00 2001 From: MBucari Date: Sat, 12 Aug 2023 17:19:56 -0600 Subject: [PATCH] Update audio duration on library scan (#707) --- Source/DataLayer/EfClasses/Book.cs | 8 ++++++-- Source/DtoImporterService/BookImporter.cs | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/DataLayer/EfClasses/Book.cs b/Source/DataLayer/EfClasses/Book.cs index b8bcce6b..01211dc8 100644 --- a/Source/DataLayer/EfClasses/Book.cs +++ b/Source/DataLayer/EfClasses/Book.cs @@ -106,6 +106,7 @@ namespace DataLayer ReplaceAuthors(authors); ReplaceNarrators(narrators); } + public void UpdateTitle(string title, string subtitle) { Title = title?.Trim() ?? ""; @@ -113,8 +114,11 @@ namespace DataLayer _titleWithSubtitle = null; } - #region contributors, authors, narrators - internal HashSet ContributorsLink { get; private set; } + public void UpdateLengthInMinutes(int lengthInMinutes) + => LengthInMinutes = lengthInMinutes; + + #region contributors, authors, narrators + internal HashSet ContributorsLink { get; private set; } public IEnumerable Authors => ContributorsLink.ByRole(Role.Author).Select(bc => bc.Contributor).ToList(); public IEnumerable Narrators => ContributorsLink.ByRole(Role.Narrator).Select(bc => bc.Contributor).ToList(); diff --git a/Source/DtoImporterService/BookImporter.cs b/Source/DtoImporterService/BookImporter.cs index f3813e1c..58eb65f1 100644 --- a/Source/DtoImporterService/BookImporter.cs +++ b/Source/DtoImporterService/BookImporter.cs @@ -149,6 +149,8 @@ namespace DtoImporterService { var item = importItem.DtoItem; + book.UpdateLengthInMinutes(item.LengthInMinutes); + // Update the book titles, since formatting can change book.UpdateTitle(item.Title, item.Subtitle);