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;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using DataLayer; using DataLayer;
using Dinah.Core;
using FileManager;
using LibationFileManager; using LibationFileManager;
namespace FileLiberator namespace FileLiberator
@ -31,7 +28,24 @@ namespace FileLiberator
/// File name: n/a /// File name: n/a
/// </summary> /// </summary>
public static string GetDestinationDirectory(this AudioFileStorage _, LibraryBook libraryBook) 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> /// <summary>
/// DownloadDecryptBook: /// DownloadDecryptBook:

View File

@ -275,6 +275,13 @@ namespace LibationFileManager
set => persistentDictionary.SetNonString(nameof(AutoDownloadEpisodes), value); 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 #region templates: custom file naming
[Description("How to format the folders in which files will be saved")] [Description("How to format the folders in which files will be saved")]

View File

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

View File

@ -103,6 +103,7 @@
this.retainAaxFileCbox = new System.Windows.Forms.CheckBox(); this.retainAaxFileCbox = new System.Windows.Forms.CheckBox();
this.downloadCoverArtCbox = new System.Windows.Forms.CheckBox(); this.downloadCoverArtCbox = new System.Windows.Forms.CheckBox();
this.createCueSheetCbox = new System.Windows.Forms.CheckBox(); this.createCueSheetCbox = new System.Windows.Forms.CheckBox();
this.saveEpisodesToSeriesFolderCbox = new System.Windows.Forms.CheckBox();
this.badBookGb.SuspendLayout(); this.badBookGb.SuspendLayout();
this.tabControl.SuspendLayout(); this.tabControl.SuspendLayout();
this.tab1ImportantSettings.SuspendLayout(); this.tab1ImportantSettings.SuspendLayout();
@ -311,7 +312,7 @@
// //
// logsBtn // 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.Name = "logsBtn";
this.logsBtn.Size = new System.Drawing.Size(132, 23); this.logsBtn.Size = new System.Drawing.Size(132, 23);
this.logsBtn.TabIndex = 5; this.logsBtn.TabIndex = 5;
@ -332,7 +333,7 @@
// loggingLevelLbl // loggingLevelLbl
// //
this.loggingLevelLbl.AutoSize = true; 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.Name = "loggingLevelLbl";
this.loggingLevelLbl.Size = new System.Drawing.Size(78, 15); this.loggingLevelLbl.Size = new System.Drawing.Size(78, 15);
this.loggingLevelLbl.TabIndex = 3; this.loggingLevelLbl.TabIndex = 3;
@ -342,7 +343,7 @@
// //
this.loggingLevelCb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.loggingLevelCb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.loggingLevelCb.FormattingEnabled = true; 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.Name = "loggingLevelCb";
this.loggingLevelCb.Size = new System.Drawing.Size(129, 23); this.loggingLevelCb.Size = new System.Drawing.Size(129, 23);
this.loggingLevelCb.TabIndex = 4; 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) this.booksGb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.booksGb.Controls.Add(this.saveEpisodesToSeriesFolderCbox);
this.booksGb.Controls.Add(this.booksSelectControl); this.booksGb.Controls.Add(this.booksSelectControl);
this.booksGb.Controls.Add(this.booksLocationDescLbl); this.booksGb.Controls.Add(this.booksLocationDescLbl);
this.booksGb.Location = new System.Drawing.Point(6, 6); this.booksGb.Location = new System.Drawing.Point(6, 6);
this.booksGb.Name = "booksGb"; 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.TabIndex = 0;
this.booksGb.TabStop = false; this.booksGb.TabStop = false;
this.booksGb.Text = "Books location"; this.booksGb.Text = "Books location";
@ -961,6 +963,16 @@
this.createCueSheetCbox.UseVisualStyleBackColor = true; this.createCueSheetCbox.UseVisualStyleBackColor = true;
this.createCueSheetCbox.CheckedChanged += new System.EventHandler(this.allowLibationFixupCbox_CheckedChanged); 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 // SettingsDialog
// //
this.AcceptButton = this.saveBtn; this.AcceptButton = this.saveBtn;
@ -1085,5 +1097,6 @@
private System.Windows.Forms.CheckBox autoScanCb; private System.Windows.Forms.CheckBox autoScanCb;
private System.Windows.Forms.CheckBox downloadCoverArtCbox; private System.Windows.Forms.CheckBox downloadCoverArtCbox;
private System.Windows.Forms.CheckBox autoDownloadEpisodesCb; 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.stripUnabridgedCbox.Text = desc(nameof(config.StripUnabridged));
this.createCueSheetCbox.Text = desc(nameof(config.CreateCueSheet)); this.createCueSheetCbox.Text = desc(nameof(config.CreateCueSheet));
this.downloadCoverArtCbox.Text = desc(nameof(config.DownloadCoverArt)); this.downloadCoverArtCbox.Text = desc(nameof(config.DownloadCoverArt));
this.saveEpisodesToSeriesFolderCbox.Text = desc(nameof(config.SavePodcastsToParentFolder));
booksSelectControl.SetSearchTitle("books location"); booksSelectControl.SetSearchTitle("books location");
booksSelectControl.SetDirectoryItems( booksSelectControl.SetDirectoryItems(
@ -59,6 +60,8 @@ namespace LibationWinForms.Dialogs
"Books"); "Books");
booksSelectControl.SelectDirectory(config.Books); booksSelectControl.SelectDirectory(config.Books);
saveEpisodesToSeriesFolderCbox.Checked = config.SavePodcastsToParentFolder;
allowLibationFixupCbox.Checked = config.AllowLibationFixup; allowLibationFixupCbox.Checked = config.AllowLibationFixup;
createCueSheetCbox.Checked = config.CreateCueSheet; createCueSheetCbox.Checked = config.CreateCueSheet;
retainAaxFileCbox.Checked = config.RetainAaxFile; retainAaxFileCbox.Checked = config.RetainAaxFile;
@ -186,6 +189,8 @@ namespace LibationWinForms.Dialogs
MessageBoxLib.VerboseLoggingWarning_ShowIfTrue(); MessageBoxLib.VerboseLoggingWarning_ShowIfTrue();
} }
config.SavePodcastsToParentFolder = saveEpisodesToSeriesFolderCbox.Checked;
config.AllowLibationFixup = allowLibationFixupCbox.Checked; config.AllowLibationFixup = allowLibationFixupCbox.Checked;
config.CreateCueSheet = createCueSheetCbox.Checked; config.CreateCueSheet = createCueSheetCbox.Checked;
config.RetainAaxFile = retainAaxFileCbox.Checked; config.RetainAaxFile = retainAaxFileCbox.Checked;