Merge pull request #273 from Mbucari/master
Add option to save episodes to series parent
This commit is contained in:
commit
09dc5e9846
@ -1,56 +1,70 @@
|
|||||||
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
|
||||||
{
|
{
|
||||||
public static class AudioFileStorageExt
|
public static class AudioFileStorageExt
|
||||||
{
|
{
|
||||||
private class MultipartRenamer
|
private class MultipartRenamer
|
||||||
{
|
{
|
||||||
private LibraryBook libraryBook { get; }
|
private LibraryBook libraryBook { get; }
|
||||||
|
|
||||||
internal MultipartRenamer(LibraryBook libraryBook) => this.libraryBook = libraryBook;
|
internal MultipartRenamer(LibraryBook libraryBook) => this.libraryBook = libraryBook;
|
||||||
|
|
||||||
internal string MultipartFilename(AaxDecrypter.MultiConvertFileProperties props)
|
internal string MultipartFilename(AaxDecrypter.MultiConvertFileProperties props)
|
||||||
=> Templates.ChapterFile.GetFilename(libraryBook.ToDto(), props);
|
=> Templates.ChapterFile.GetFilename(libraryBook.ToDto(), props);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Func<AaxDecrypter.MultiConvertFileProperties, string> CreateMultipartRenamerFunc(this AudioFileStorage _, LibraryBook libraryBook)
|
public static Func<AaxDecrypter.MultiConvertFileProperties, string> CreateMultipartRenamerFunc(this AudioFileStorage _, LibraryBook libraryBook)
|
||||||
=> new MultipartRenamer(libraryBook).MultipartFilename;
|
=> new MultipartRenamer(libraryBook).MultipartFilename;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// DownloadDecryptBook:
|
/// DownloadDecryptBook:
|
||||||
/// File path for where to move files into.
|
/// File path for where to move files into.
|
||||||
/// Path: directory nested inside of Books directory
|
/// Path: directory nested inside of Books directory
|
||||||
/// 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);
|
||||||
|
|
||||||
/// <summary>
|
if (seriesParent is not null)
|
||||||
/// DownloadDecryptBook:
|
{
|
||||||
/// Path: in progress directory.
|
var baseDir = Templates.Folder.GetFilename(seriesParent.ToDto());
|
||||||
/// File name: final file name.
|
return Templates.Folder.GetFilename(libraryBook.ToDto(), baseDir);
|
||||||
/// </summary>
|
}
|
||||||
public static string GetInProgressFilename(this AudioFileStorage _, LibraryBook libraryBook, string extension)
|
}
|
||||||
=> Templates.File.GetFilename(libraryBook.ToDto(), AudibleFileStorage.DecryptInProgressDirectory, extension, returnFirstExisting: true);
|
}
|
||||||
|
|
||||||
/// <summary>
|
return Templates.Folder.GetFilename(libraryBook.ToDto());
|
||||||
/// PDF: audio file does not exist
|
}
|
||||||
/// </summary>
|
|
||||||
public static string GetBooksDirectoryFilename(this AudioFileStorage _, LibraryBook libraryBook, string extension)
|
|
||||||
=> Templates.File.GetFilename(libraryBook.ToDto(), AudibleFileStorage.BooksDirectory, extension);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PDF: audio file already exists
|
/// DownloadDecryptBook:
|
||||||
/// </summary>
|
/// Path: in progress directory.
|
||||||
public static string GetCustomDirFilename(this AudioFileStorage _, LibraryBook libraryBook, string dirFullPath, string extension)
|
/// File name: final file name.
|
||||||
=> Templates.File.GetFilename(libraryBook.ToDto(), dirFullPath, extension);
|
/// </summary>
|
||||||
}
|
public static string GetInProgressFilename(this AudioFileStorage _, LibraryBook libraryBook, string extension)
|
||||||
|
=> Templates.File.GetFilename(libraryBook.ToDto(), AudibleFileStorage.DecryptInProgressDirectory, extension, returnFirstExisting: true);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PDF: audio file does not exist
|
||||||
|
/// </summary>
|
||||||
|
public static string GetBooksDirectoryFilename(this AudioFileStorage _, LibraryBook libraryBook, string extension)
|
||||||
|
=> Templates.File.GetFilename(libraryBook.ToDto(), AudibleFileStorage.BooksDirectory, extension);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PDF: audio file already exists
|
||||||
|
/// </summary>
|
||||||
|
public static string GetCustomDirFilename(this AudioFileStorage _, LibraryBook libraryBook, string dirFullPath, string extension)
|
||||||
|
=> Templates.File.GetFilename(libraryBook.ToDto(), dirFullPath, extension);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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")]
|
||||||
|
|||||||
@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
1951
Source/LibationWinForms/Dialogs/SettingsDialog.Designer.cs
generated
1951
Source/LibationWinForms/Dialogs/SettingsDialog.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user