Merge pull request #273 from Mbucari/master

Add option to save episodes to series parent
This commit is contained in:
rmcrackan 2022-06-13 12:00:05 -04:00 committed by GitHub
commit 09dc5e9846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1050 additions and 1011 deletions

View File

@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using DataLayer;
using Dinah.Core;
using FileManager;
using LibationFileManager;
namespace FileLiberator
@ -31,7 +28,24 @@ namespace FileLiberator
/// File name: n/a
/// </summary>
public static string GetDestinationDirectory(this AudioFileStorage _, LibraryBook libraryBook)
=> Templates.Folder.GetFilename(libraryBook.ToDto());
{
if (libraryBook.Book.IsEpisodeChild() && Configuration.Instance.SavePodcastsToParentFolder)
{
var series = libraryBook.Book.SeriesLink.SingleOrDefault();
if (series is not null)
{
var seriesParent = ApplicationServices.DbContexts.GetContext().GetLibraryBook_Flat_NoTracking(series.Series.AudibleSeriesId);
if (seriesParent is not null)
{
var baseDir = Templates.Folder.GetFilename(seriesParent.ToDto());
return Templates.Folder.GetFilename(libraryBook.ToDto(), baseDir);
}
}
}
return Templates.Folder.GetFilename(libraryBook.ToDto());
}
/// <summary>
/// DownloadDecryptBook:

View File

@ -275,6 +275,13 @@ namespace LibationFileManager
set => persistentDictionary.SetNonString(nameof(AutoDownloadEpisodes), value);
}
[Description("Save all podcast episodes in a series to the series parent folder?")]
public bool SavePodcastsToParentFolder
{
get => persistentDictionary.GetNonString<bool>(nameof(SavePodcastsToParentFolder));
set => persistentDictionary.SetNonString(nameof(SavePodcastsToParentFolder), value);
}
#region templates: custom file naming
[Description("How to format the folders in which files will be saved")]

View File

@ -207,8 +207,8 @@ namespace LibationFileManager
#region to file name
/// <summary>USES LIVE CONFIGURATION VALUES</summary>
public string GetFilename(LibraryBookDto libraryBookDto)
=> getFileNamingTemplate(libraryBookDto, Configuration.Instance.FolderTemplate, AudibleFileStorage.BooksDirectory, null)
public string GetFilename(LibraryBookDto libraryBookDto, string baseDir = null)
=> getFileNamingTemplate(libraryBookDto, Configuration.Instance.FolderTemplate, baseDir ?? AudibleFileStorage.BooksDirectory, null)
.GetFilePath();
#endregion
}

View File

@ -103,6 +103,7 @@
this.retainAaxFileCbox = new System.Windows.Forms.CheckBox();
this.downloadCoverArtCbox = new System.Windows.Forms.CheckBox();
this.createCueSheetCbox = new System.Windows.Forms.CheckBox();
this.saveEpisodesToSeriesFolderCbox = new System.Windows.Forms.CheckBox();
this.badBookGb.SuspendLayout();
this.tabControl.SuspendLayout();
this.tab1ImportantSettings.SuspendLayout();
@ -311,7 +312,7 @@
//
// logsBtn
//
this.logsBtn.Location = new System.Drawing.Point(256, 169);
this.logsBtn.Location = new System.Drawing.Point(256, 198);
this.logsBtn.Name = "logsBtn";
this.logsBtn.Size = new System.Drawing.Size(132, 23);
this.logsBtn.TabIndex = 5;
@ -332,7 +333,7 @@
// loggingLevelLbl
//
this.loggingLevelLbl.AutoSize = true;
this.loggingLevelLbl.Location = new System.Drawing.Point(6, 172);
this.loggingLevelLbl.Location = new System.Drawing.Point(6, 201);
this.loggingLevelLbl.Name = "loggingLevelLbl";
this.loggingLevelLbl.Size = new System.Drawing.Size(78, 15);
this.loggingLevelLbl.TabIndex = 3;
@ -342,7 +343,7 @@
//
this.loggingLevelCb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.loggingLevelCb.FormattingEnabled = true;
this.loggingLevelCb.Location = new System.Drawing.Point(90, 169);
this.loggingLevelCb.Location = new System.Drawing.Point(90, 198);
this.loggingLevelCb.Name = "loggingLevelCb";
this.loggingLevelCb.Size = new System.Drawing.Size(129, 23);
this.loggingLevelCb.TabIndex = 4;
@ -380,11 +381,12 @@
//
this.booksGb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.booksGb.Controls.Add(this.saveEpisodesToSeriesFolderCbox);
this.booksGb.Controls.Add(this.booksSelectControl);
this.booksGb.Controls.Add(this.booksLocationDescLbl);
this.booksGb.Location = new System.Drawing.Point(6, 6);
this.booksGb.Name = "booksGb";
this.booksGb.Size = new System.Drawing.Size(842, 129);
this.booksGb.Size = new System.Drawing.Size(842, 156);
this.booksGb.TabIndex = 0;
this.booksGb.TabStop = false;
this.booksGb.Text = "Books location";
@ -961,6 +963,16 @@
this.createCueSheetCbox.UseVisualStyleBackColor = true;
this.createCueSheetCbox.CheckedChanged += new System.EventHandler(this.allowLibationFixupCbox_CheckedChanged);
//
// saveEpisodesToSeriesFolderCbox
//
this.saveEpisodesToSeriesFolderCbox.AutoSize = true;
this.saveEpisodesToSeriesFolderCbox.Location = new System.Drawing.Point(7, 131);
this.saveEpisodesToSeriesFolderCbox.Name = "saveEpisodesToSeriesFolderCbox";
this.saveEpisodesToSeriesFolderCbox.Size = new System.Drawing.Size(191, 19);
this.saveEpisodesToSeriesFolderCbox.TabIndex = 3;
this.saveEpisodesToSeriesFolderCbox.Text = "[Save Episodes To Series Folder]";
this.saveEpisodesToSeriesFolderCbox.UseVisualStyleBackColor = true;
//
// SettingsDialog
//
this.AcceptButton = this.saveBtn;
@ -1085,5 +1097,6 @@
private System.Windows.Forms.CheckBox autoScanCb;
private System.Windows.Forms.CheckBox downloadCoverArtCbox;
private System.Windows.Forms.CheckBox autoDownloadEpisodesCb;
private System.Windows.Forms.CheckBox saveEpisodesToSeriesFolderCbox;
}
}

View File

@ -46,6 +46,7 @@ namespace LibationWinForms.Dialogs
this.stripUnabridgedCbox.Text = desc(nameof(config.StripUnabridged));
this.createCueSheetCbox.Text = desc(nameof(config.CreateCueSheet));
this.downloadCoverArtCbox.Text = desc(nameof(config.DownloadCoverArt));
this.saveEpisodesToSeriesFolderCbox.Text = desc(nameof(config.SavePodcastsToParentFolder));
booksSelectControl.SetSearchTitle("books location");
booksSelectControl.SetDirectoryItems(
@ -59,6 +60,8 @@ namespace LibationWinForms.Dialogs
"Books");
booksSelectControl.SelectDirectory(config.Books);
saveEpisodesToSeriesFolderCbox.Checked = config.SavePodcastsToParentFolder;
allowLibationFixupCbox.Checked = config.AllowLibationFixup;
createCueSheetCbox.Checked = config.CreateCueSheet;
retainAaxFileCbox.Checked = config.RetainAaxFile;
@ -186,6 +189,8 @@ namespace LibationWinForms.Dialogs
MessageBoxLib.VerboseLoggingWarning_ShowIfTrue();
}
config.SavePodcastsToParentFolder = saveEpisodesToSeriesFolderCbox.Checked;
config.AllowLibationFixup = allowLibationFixupCbox.Checked;
config.CreateCueSheet = createCueSheetCbox.Checked;
config.RetainAaxFile = retainAaxFileCbox.Checked;