diff --git a/Source/FileLiberator/AudioFileStorageExt.cs b/Source/FileLiberator/AudioFileStorageExt.cs index dc96fa27..e5c2e344 100644 --- a/Source/FileLiberator/AudioFileStorageExt.cs +++ b/Source/FileLiberator/AudioFileStorageExt.cs @@ -25,8 +25,7 @@ namespace FileLiberator if (seriesParent is not null) { - var baseDir = Templates.Folder.GetFilename(seriesParent.ToDto(), AudibleFileStorage.BooksDirectory, ""); - return Templates.Folder.GetFilename(libraryBook.ToDto(), baseDir, ""); + return Templates.Folder.GetFilename(seriesParent.ToDto(), AudibleFileStorage.BooksDirectory, ""); } } } diff --git a/Source/FileLiberator/UtilityExtensions.cs b/Source/FileLiberator/UtilityExtensions.cs index b85eee0c..54f72a44 100644 --- a/Source/FileLiberator/UtilityExtensions.cs +++ b/Source/FileLiberator/UtilityExtensions.cs @@ -41,7 +41,8 @@ namespace FileLiberator SeriesName = libraryBook.Book.SeriesLink.FirstOrDefault()?.Series.Name, SeriesNumber = (int?)libraryBook.Book.SeriesLink.FirstOrDefault()?.Index, - IsPodcast = libraryBook.Book.IsEpisodeChild(), + IsPodcastParent = libraryBook.Book.IsEpisodeParent(), + IsPodcast = libraryBook.Book.IsEpisodeChild() || libraryBook.Book.IsEpisodeParent(), BitRate = libraryBook.Book.AudioFormat.Bitrate, SampleRate = libraryBook.Book.AudioFormat.SampleRate, diff --git a/Source/LibationFileManager/LibraryBookDto.cs b/Source/LibationFileManager/LibraryBookDto.cs index 859f18c9..861125e9 100644 --- a/Source/LibationFileManager/LibraryBookDto.cs +++ b/Source/LibationFileManager/LibraryBookDto.cs @@ -22,6 +22,7 @@ namespace LibationFileManager public string SeriesName { get; set; } public int? SeriesNumber { get; set; } public bool IsSeries => !string.IsNullOrEmpty(SeriesName); + public bool IsPodcastParent { get; set; } public bool IsPodcast { get; set; } public int BitRate { get; set; } diff --git a/Source/LibationFileManager/TemplateTags.cs b/Source/LibationFileManager/TemplateTags.cs index 8adcd4d6..d0beb15e 100644 --- a/Source/LibationFileManager/TemplateTags.cs +++ b/Source/LibationFileManager/TemplateTags.cs @@ -47,6 +47,7 @@ namespace LibationFileManager public static TemplateTags DateAdded { get; } = new TemplateTags("date added", "Date added to your Audible account. e.g. yyyy-MM-dd", $"", ""); public static TemplateTags IfSeries { get; } = new TemplateTags("if series", "Only include if part of a book series or podcast", "<-if series>", "...<-if series>"); public static TemplateTags IfPodcast { get; } = new TemplateTags("if podcast", "Only include if part of a podcast", "<-if podcast>", "...<-if podcast>"); + public static TemplateTags IfPodcastParent { get; } = new TemplateTags("if podcastparent", "Only include if item is a podcast series parent", "<-if podcastparent>", "...<-if podcastparent>"); public static TemplateTags IfBookseries { get; } = new TemplateTags("if bookseries", "Only include if part of a book series", "<-if bookseries>", "...<-if bookseries>"); } } diff --git a/Source/LibationFileManager/Templates.cs b/Source/LibationFileManager/Templates.cs index f68abeb5..f3901ed0 100644 --- a/Source/LibationFileManager/Templates.cs +++ b/Source/LibationFileManager/Templates.cs @@ -207,13 +207,13 @@ namespace LibationFileManager { TemplateTags.Narrator, lb => lb.Narrators, NameListFormat.Formatter }, { TemplateTags.FirstNarrator, lb => lb.FirstNarrator }, { TemplateTags.Series, lb => lb.SeriesName }, - { TemplateTags.SeriesNumber, lb => lb.SeriesNumber }, + { TemplateTags.SeriesNumber, lb => lb.IsPodcastParent ? null : lb.SeriesNumber }, { TemplateTags.Language, lb => lb.Language }, //Don't allow formatting of LanguageShort { TemplateTags.LanguageShort, lb =>lb.Language, getLanguageShort }, - { TemplateTags.Bitrate, lb => lb.BitRate }, - { TemplateTags.SampleRate, lb => lb.SampleRate }, - { TemplateTags.Channels, lb => lb.Channels }, + { TemplateTags.Bitrate, lb => (int?)(lb.IsPodcastParent ? null : lb.BitRate) }, + { TemplateTags.SampleRate, lb => (int?)(lb.IsPodcastParent ? null : lb.SampleRate) }, + { TemplateTags.Channels, lb => (int?)(lb.IsPodcastParent ? null :lb.Channels) }, { TemplateTags.Account, lb => lb.Account }, { TemplateTags.Locale, lb => lb.Locale }, { TemplateTags.YearPublished, lb => lb.YearPublished }, @@ -244,7 +244,12 @@ namespace LibationFileManager { { TemplateTags.IfSeries, lb => lb.IsSeries }, { TemplateTags.IfPodcast, lb => lb.IsPodcast }, - { TemplateTags.IfBookseries, lb => lb.IsSeries && !lb.IsPodcast }, + { TemplateTags.IfBookseries, lb => lb.IsSeries && !lb.IsPodcast&& !lb.IsPodcastParent }, + }; + + private static readonly ConditionalTagCollection folderConditionalTags = new() + { + { TemplateTags.IfPodcastParent, lb => lb.IsPodcastParent } }; #endregion @@ -293,7 +298,8 @@ namespace LibationFileManager public static string Name { get; }= "Folder Template"; public static string Description { get; } = Configuration.GetDescription(nameof(Configuration.FolderTemplate)); public static string DefaultTemplate { get; } = " [<id>]"; - public static IEnumerable<TagCollection> TagCollections => new TagCollection[] { filePropertyTags, conditionalTags }; + public static IEnumerable<TagCollection> TagCollections + => new TagCollection[] { filePropertyTags, conditionalTags, folderConditionalTags }; public override IEnumerable<string> Errors => TemplateText?.Length >= 2 && Path.IsPathFullyQualified(TemplateText) ? base.Errors.Append(ERROR_FULL_PATH_IS_INVALID) : base.Errors;