Merge pull request #642 from Mbucari/master
Bug fixes and minor features
This commit is contained in:
commit
85be15b843
@ -81,6 +81,9 @@ namespace FileLiberator
|
||||
extension: "mp3",
|
||||
Configuration.Instance.OverwriteExisting);
|
||||
|
||||
SetFileTime(libraryBook, realMp3Path);
|
||||
SetDirectoryTime(libraryBook, Path.GetDirectoryName(realMp3Path));
|
||||
|
||||
OnFileCreated(libraryBook, realMp3Path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,8 +99,12 @@ namespace FileLiberator
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (moveFilesTask.IsCompletedSuccessfully)
|
||||
await Task.Run(() => libraryBook.UpdateBookStatus(LiberatedStatus.Liberated, Configuration.LibationVersion));
|
||||
if (moveFilesTask.IsCompletedSuccessfully)
|
||||
{
|
||||
await Task.Run(() => libraryBook.UpdateBookStatus(LiberatedStatus.Liberated, Configuration.LibationVersion));
|
||||
|
||||
SetDirectoryTime(libraryBook, finalStorageDir);
|
||||
}
|
||||
}
|
||||
|
||||
return new StatusHandler();
|
||||
@ -366,8 +370,9 @@ namespace FileLiberator
|
||||
Path.Combine(destinationDir, Path.GetFileName(entry.Path)),
|
||||
Configuration.Instance.ReplacementCharacters,
|
||||
overwrite: Configuration.Instance.OverwriteExisting);
|
||||
|
||||
FilePathCache.Insert(libraryBook.Book.AudibleProductId, realDest);
|
||||
|
||||
SetFileTime(libraryBook, realDest);
|
||||
FilePathCache.Insert(libraryBook.Book.AudibleProductId, realDest);
|
||||
|
||||
// propagate corrected path. Must update cache with corrected path. Also want updated path for cue file (after this for-loop)
|
||||
entries[i] = entry with { Path = realDest };
|
||||
@ -375,7 +380,10 @@ namespace FileLiberator
|
||||
|
||||
var cue = entries.FirstOrDefault(f => f.FileType == FileType.Cue);
|
||||
if (cue != default)
|
||||
{
|
||||
Cue.UpdateFileName(cue.Path, getFirstAudioFile(entries).Path);
|
||||
SetFileTime(libraryBook, cue.Path);
|
||||
}
|
||||
|
||||
AudibleFileStorage.Audio.Refresh();
|
||||
}
|
||||
@ -408,7 +416,10 @@ namespace FileLiberator
|
||||
|
||||
var picBytes = PictureStorage.GetPictureSynchronously(new(libraryBook.Book.PictureLarge ?? libraryBook.Book.PictureId, PictureSize.Native));
|
||||
if (picBytes.Length > 0)
|
||||
{
|
||||
File.WriteAllBytes(coverPath, picBytes);
|
||||
SetFileTime(libraryBook, coverPath);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@ -30,6 +30,11 @@ namespace FileLiberator
|
||||
var actualDownloadedFilePath = await downloadPdfAsync(libraryBook, proposedDownloadFilePath);
|
||||
var result = verifyDownload(actualDownloadedFilePath);
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
SetFileTime(libraryBook, actualDownloadedFilePath);
|
||||
SetDirectoryTime(libraryBook, Path.GetDirectoryName(actualDownloadedFilePath));
|
||||
}
|
||||
libraryBook.UpdatePdfStatus(result.IsSuccess ? LiberatedStatus.Liberated : LiberatedStatus.NotLiberated);
|
||||
|
||||
return result;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using DataLayer;
|
||||
@ -98,5 +99,26 @@ namespace FileLiberator
|
||||
Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(Completed), Book = libraryBook.LogFriendly() });
|
||||
Completed?.Invoke(this, libraryBook);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void SetFileTime(LibraryBook libraryBook, string file)
|
||||
=> setFileSystemTime(libraryBook, new FileInfo(file));
|
||||
protected static void SetDirectoryTime(LibraryBook libraryBook, string file)
|
||||
=> setFileSystemTime(libraryBook, new DirectoryInfo(file));
|
||||
|
||||
private static void setFileSystemTime(LibraryBook libraryBook, FileSystemInfo fileInfo)
|
||||
{
|
||||
if (!fileInfo.Exists) return;
|
||||
|
||||
fileInfo.CreationTimeUtc = getTimeValue(Configuration.Instance.CreationTime) ?? fileInfo.CreationTimeUtc;
|
||||
fileInfo.LastWriteTimeUtc = getTimeValue(Configuration.Instance.LastWriteTime) ?? fileInfo.LastWriteTimeUtc;
|
||||
|
||||
DateTime? getTimeValue(Configuration.DateTimeSource source) => source switch
|
||||
{
|
||||
Configuration.DateTimeSource.Added => libraryBook.DateAdded,
|
||||
Configuration.DateTimeSource.Published => libraryBook.Book.DatePublished,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
Grid.Row="0"
|
||||
Margin="5"
|
||||
Label="Books Location">
|
||||
|
||||
|
||||
<StackPanel>
|
||||
<TextBlock
|
||||
Margin="5"
|
||||
@ -32,6 +32,40 @@
|
||||
<TextBlock Text="{CompiledBinding OverwriteExistingText}" />
|
||||
</CheckBox>
|
||||
|
||||
<Grid
|
||||
RowDefinitions="Auto,Auto"
|
||||
ColumnDefinitions="Auto,*">
|
||||
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,10,0"
|
||||
Text="{CompiledBinding CreationTimeText}" />
|
||||
|
||||
<controls:WheelComboBox
|
||||
Height="25"
|
||||
Grid.Column="1"
|
||||
Margin="0,5"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
SelectedItem="{CompiledBinding CreationTime, Mode=TwoWay}"
|
||||
ItemsSource="{CompiledBinding DateTimeSources}" />
|
||||
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Grid.Row="1"
|
||||
Margin="0,0,10,0"
|
||||
Text="{CompiledBinding LastWriteTimeText}" />
|
||||
|
||||
<controls:WheelComboBox
|
||||
Height="25"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="0,5"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
SelectedItem="{CompiledBinding LastWriteTime, Mode=TwoWay}"
|
||||
ItemsSource="{CompiledBinding DateTimeSources}" />
|
||||
|
||||
</Grid>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</controls:GroupBox>
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
CanUserSortColumns="False"
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="False"
|
||||
Name="accountsGrid"
|
||||
ItemsSource="{Binding Accounts}"
|
||||
GridLinesVisibility="All">
|
||||
|
||||
|
||||
@ -157,6 +157,8 @@ namespace LibationAvalonia.Dialogs
|
||||
{
|
||||
try
|
||||
{
|
||||
accountsGrid.CommitEdit();
|
||||
|
||||
if (!await inputIsValid())
|
||||
return;
|
||||
|
||||
|
||||
@ -41,6 +41,7 @@ namespace LibationAvalonia.Dialogs
|
||||
_accounts.Add(new listItem
|
||||
{
|
||||
Account = account,
|
||||
IsChecked = account.LibraryScan,
|
||||
Text = $"{account.AccountName} ({account.AccountId} - {account.Locale.Name})"
|
||||
});
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using ApplicationServices;
|
||||
using Avalonia.Threading;
|
||||
using LibationFileManager;
|
||||
using ReactiveUI;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -52,6 +53,10 @@ namespace LibationAvalonia.ViewModels
|
||||
updateCountsTask = Task.Run(() => LibraryCommands.GetCounts());
|
||||
var stats = await updateCountsTask;
|
||||
await Dispatcher.UIThread.InvokeAsync(() => LibraryStats = stats);
|
||||
|
||||
if (Configuration.Instance.AutoDownloadEpisodes
|
||||
&& stats.booksNoProgress + stats.pdfsNotDownloaded > 0)
|
||||
await Dispatcher.UIThread.InvokeAsync(BackupAllBooks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
using Avalonia.Collections;
|
||||
using AAXClean;
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Controls;
|
||||
using Dinah.Core;
|
||||
using LibationFileManager;
|
||||
using LibationUiBase;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace LibationAvalonia.ViewModels.Settings
|
||||
@ -19,21 +21,11 @@ namespace LibationAvalonia.ViewModels.Settings
|
||||
private int _lameBitrate;
|
||||
private int _lameVBRQuality;
|
||||
private string _chapterTitleTemplate;
|
||||
public SampleRateSelection SelectedSampleRate { get; set; }
|
||||
public EnumDiaplay<SampleRate> SelectedSampleRate { get; set; }
|
||||
public NAudio.Lame.EncoderQuality SelectedEncoderQuality { get; set; }
|
||||
|
||||
public AvaloniaList<SampleRateSelection> SampleRates { get; }
|
||||
= new(
|
||||
new[]
|
||||
{
|
||||
AAXClean.SampleRate.Hz_44100,
|
||||
AAXClean.SampleRate.Hz_32000,
|
||||
AAXClean.SampleRate.Hz_24000,
|
||||
AAXClean.SampleRate.Hz_22050,
|
||||
AAXClean.SampleRate.Hz_16000,
|
||||
AAXClean.SampleRate.Hz_12000,
|
||||
}
|
||||
.Select(s => new SampleRateSelection(s)));
|
||||
public AvaloniaList<EnumDiaplay<SampleRate>> SampleRates { get; }
|
||||
= new(Enum.GetValues<SampleRate>().Select(v => new EnumDiaplay<SampleRate>(v, $"{(int)v} Hz")));
|
||||
|
||||
public AvaloniaList<NAudio.Lame.EncoderQuality> EncoderQualities { get; }
|
||||
= new(
|
||||
@ -71,7 +63,7 @@ namespace LibationAvalonia.ViewModels.Settings
|
||||
LameBitrate = config.LameBitrate;
|
||||
LameVBRQuality = config.LameVBRQuality;
|
||||
|
||||
SelectedSampleRate = SampleRates.FirstOrDefault(s => s.SampleRate == config.MaxSampleRate);
|
||||
SelectedSampleRate = SampleRates.SingleOrDefault(s => s.Value == config.MaxSampleRate);
|
||||
SelectedEncoderQuality = config.LameEncoderQuality;
|
||||
}
|
||||
|
||||
@ -98,7 +90,7 @@ namespace LibationAvalonia.ViewModels.Settings
|
||||
config.LameVBRQuality = LameVBRQuality;
|
||||
|
||||
config.LameEncoderQuality = SelectedEncoderQuality;
|
||||
config.MaxSampleRate = SelectedSampleRate?.SampleRate ?? config.MaxSampleRate;
|
||||
config.MaxSampleRate = SelectedSampleRate?.Value ?? config.MaxSampleRate;
|
||||
}
|
||||
|
||||
public AvaloniaList<Configuration.ClipBookmarkFormat> ClipBookmarkFormats { get; } = new(Enum<Configuration.ClipBookmarkFormat>.GetValues());
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
using Dinah.Core;
|
||||
using FileManager;
|
||||
using LibationFileManager;
|
||||
using LibationUiBase;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace LibationAvalonia.ViewModels.Settings
|
||||
{
|
||||
@ -22,6 +24,8 @@ namespace LibationAvalonia.ViewModels.Settings
|
||||
BooksDirectory = config.Books.PathWithoutPrefix;
|
||||
SavePodcastsToParentFolder = config.SavePodcastsToParentFolder;
|
||||
OverwriteExisting = config.OverwriteExisting;
|
||||
CreationTime = DateTimeSources.SingleOrDefault(v => v.Value == config.CreationTime) ?? DateTimeSources[0];
|
||||
LastWriteTime = DateTimeSources.SingleOrDefault(v => v.Value == config.LastWriteTime) ?? DateTimeSources[0];
|
||||
LoggingLevel = config.LogLevel;
|
||||
ThemeVariant = initialThemeVariant
|
||||
= Configuration.Instance.GetString(propertyName: nameof(ThemeVariant)) is nameof(Avalonia.Styling.ThemeVariant.Dark)
|
||||
@ -37,6 +41,8 @@ namespace LibationAvalonia.ViewModels.Settings
|
||||
config.Books = lonNewBooks;
|
||||
config.SavePodcastsToParentFolder = SavePodcastsToParentFolder;
|
||||
config.OverwriteExisting = OverwriteExisting;
|
||||
config.CreationTime = CreationTime.Value;
|
||||
config.LastWriteTime = LastWriteTime.Value;
|
||||
config.LogLevel = LoggingLevel;
|
||||
Configuration.Instance.SetString(ThemeVariant, nameof(ThemeVariant));
|
||||
}
|
||||
@ -53,6 +59,12 @@ namespace LibationAvalonia.ViewModels.Settings
|
||||
public string BooksText { get; } = Configuration.GetDescription(nameof(Configuration.Books));
|
||||
public string SavePodcastsToParentFolderText { get; } = Configuration.GetDescription(nameof(Configuration.SavePodcastsToParentFolder));
|
||||
public string OverwriteExistingText { get; } = Configuration.GetDescription(nameof(Configuration.OverwriteExisting));
|
||||
public string CreationTimeText { get; } = Configuration.GetDescription(nameof(Configuration.CreationTime));
|
||||
public string LastWriteTimeText { get; } = Configuration.GetDescription(nameof(Configuration.LastWriteTime));
|
||||
public EnumDiaplay<Configuration.DateTimeSource>[] DateTimeSources { get; }
|
||||
= Enum.GetValues<Configuration.DateTimeSource>()
|
||||
.Select(v => new EnumDiaplay<Configuration.DateTimeSource>(v))
|
||||
.ToArray();
|
||||
public Serilog.Events.LogEventLevel[] LoggingLevels { get; } = Enum.GetValues<Serilog.Events.LogEventLevel>();
|
||||
public string BetaOptInText { get; } = Configuration.GetDescription(nameof(Configuration.BetaOptIn));
|
||||
public string[] Themes { get; } = { nameof(Avalonia.Styling.ThemeVariant.Light), nameof(Avalonia.Styling.ThemeVariant.Dark) };
|
||||
@ -60,6 +72,8 @@ namespace LibationAvalonia.ViewModels.Settings
|
||||
public string BooksDirectory { get; set; }
|
||||
public bool SavePodcastsToParentFolder { get; set; }
|
||||
public bool OverwriteExisting { get; set; }
|
||||
public EnumDiaplay<Configuration.DateTimeSource> CreationTime { get; set; }
|
||||
public EnumDiaplay<Configuration.DateTimeSource> LastWriteTime { get; set; }
|
||||
public Serilog.Events.LogEventLevel LoggingLevel { get; set; }
|
||||
|
||||
public string ThemeVariant
|
||||
|
||||
@ -194,6 +194,23 @@ namespace LibationFileManager
|
||||
Ignore = 3
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum DateTimeSource
|
||||
{
|
||||
[Description("File creation date/time")]
|
||||
File,
|
||||
[Description("Audiobook publication date")]
|
||||
Published,
|
||||
[Description("Date book was added to your Audible account")]
|
||||
Added
|
||||
}
|
||||
|
||||
[Description("Set file \"created\" timestamp to:")]
|
||||
public DateTimeSource CreationTime { get => GetNonString(defaultValue: DateTimeSource.File); set => SetNonString(value); }
|
||||
|
||||
[Description("Set file \"modified\" timestamp to:")]
|
||||
public DateTimeSource LastWriteTime { get => GetNonString(defaultValue: DateTimeSource.File); set => SetNonString(value); }
|
||||
|
||||
[Description("Indicates that this is the first time Libation has been run")]
|
||||
public bool FirstLaunch { get => GetNonString(defaultValue: true); set => SetNonString(value); }
|
||||
|
||||
|
||||
@ -179,6 +179,7 @@ namespace LibationFileManager
|
||||
while((slashIndex = part.IndexOf(Path.DirectorySeparatorChar, lastIndex)) > -1)
|
||||
{
|
||||
dir.Add(part[lastIndex..slashIndex]);
|
||||
RemoveSpaces(dir);
|
||||
directories.Add(dir);
|
||||
dir = new();
|
||||
|
||||
@ -186,11 +187,57 @@ namespace LibationFileManager
|
||||
}
|
||||
dir.Add(part[lastIndex..]);
|
||||
}
|
||||
RemoveSpaces(dir);
|
||||
directories.Add(dir);
|
||||
|
||||
return directories;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove spaces from the filename parts to ensure that after concatenation
|
||||
/// <br>-</br> There is no leading or trailing white space
|
||||
/// <br>-</br> There are no multispace instances
|
||||
/// </summary>
|
||||
private static void RemoveSpaces(List<string> parts)
|
||||
{
|
||||
while (parts.Count > 0 && string.IsNullOrWhiteSpace(parts[0]))
|
||||
parts.RemoveAt(0);
|
||||
|
||||
while (parts.Count > 0 && string.IsNullOrWhiteSpace(parts[^1]))
|
||||
parts.RemoveAt(parts.Count - 1);
|
||||
|
||||
if (parts.Count == 0) return;
|
||||
|
||||
parts[0] = parts[0].TrimStart();
|
||||
parts[^1] = parts[^1].TrimEnd();
|
||||
|
||||
//Replace all multispace substrings with single space
|
||||
for (int i = 0; i < parts.Count; i++)
|
||||
{
|
||||
string original;
|
||||
do
|
||||
{
|
||||
original = parts[i];
|
||||
parts[i] = original.Replace(" ", " ");
|
||||
}while(original.Length != parts[i].Length);
|
||||
}
|
||||
|
||||
//Remove instances of double spaces at part boundaries
|
||||
for (int i = 1; i < parts.Count; i++)
|
||||
{
|
||||
if (parts[i - 1].EndsWith(' ') && parts[i].StartsWith(' '))
|
||||
{
|
||||
parts[i] = parts[i].Substring(1);
|
||||
|
||||
if (parts[i].Length == 0)
|
||||
{
|
||||
parts.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Registered Template Properties
|
||||
|
||||
17
Source/LibationUiBase/EnumDiaplay[T].cs
Normal file
17
Source/LibationUiBase/EnumDiaplay[T].cs
Normal file
@ -0,0 +1,17 @@
|
||||
using Dinah.Core;
|
||||
using System;
|
||||
|
||||
namespace LibationUiBase
|
||||
{
|
||||
public record EnumDiaplay<T> where T : Enum
|
||||
{
|
||||
public T Value { get; }
|
||||
public string Description { get; }
|
||||
public EnumDiaplay(T value, string description = null)
|
||||
{
|
||||
Value = value;
|
||||
Description = description ?? value.GetDescription() ?? value.ToString();
|
||||
}
|
||||
public override string ToString() => Description;
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
namespace LibationUiBase
|
||||
{
|
||||
public class SampleRateSelection
|
||||
{
|
||||
public AAXClean.SampleRate SampleRate { get; }
|
||||
public SampleRateSelection(AAXClean.SampleRate sampleRate)
|
||||
{
|
||||
SampleRate = sampleRate;
|
||||
}
|
||||
public override string ToString() => $"{(int)SampleRate} Hz";
|
||||
}
|
||||
}
|
||||
@ -28,15 +28,9 @@ namespace LibationWinForms.Dialogs
|
||||
});
|
||||
|
||||
maxSampleRateCb.Items.AddRange(
|
||||
new object[]
|
||||
{
|
||||
new SampleRateSelection(AAXClean.SampleRate.Hz_44100),
|
||||
new SampleRateSelection(AAXClean.SampleRate.Hz_32000),
|
||||
new SampleRateSelection(AAXClean.SampleRate.Hz_24000),
|
||||
new SampleRateSelection(AAXClean.SampleRate.Hz_22050),
|
||||
new SampleRateSelection(AAXClean.SampleRate.Hz_16000),
|
||||
new SampleRateSelection(AAXClean.SampleRate.Hz_12000)
|
||||
});
|
||||
Enum.GetValues<AAXClean.SampleRate>()
|
||||
.Select(v => new EnumDiaplay<AAXClean.SampleRate>(v, $"{(int)v} Hz"))
|
||||
.ToArray());
|
||||
|
||||
encoderQualityCb.Items.AddRange(
|
||||
new object[]
|
||||
@ -62,7 +56,13 @@ namespace LibationWinForms.Dialogs
|
||||
|
||||
lameTargetBitrateRb.Checked = config.LameTargetBitrate;
|
||||
lameTargetQualityRb.Checked = !config.LameTargetBitrate;
|
||||
maxSampleRateCb.SelectedItem = maxSampleRateCb.Items.Cast<SampleRateSelection>().Single(s => s.SampleRate == config.MaxSampleRate);
|
||||
|
||||
maxSampleRateCb.SelectedItem
|
||||
= maxSampleRateCb.Items
|
||||
.Cast<EnumDiaplay<AAXClean.SampleRate>>()
|
||||
.SingleOrDefault(v => v.Value == config.MaxSampleRate)
|
||||
?? maxSampleRateCb.Items[0];
|
||||
|
||||
encoderQualityCb.SelectedItem = config.LameEncoderQuality;
|
||||
lameDownsampleMonoCbox.Checked = config.LameDownsampleMono;
|
||||
lameBitrateTb.Value = config.LameBitrate;
|
||||
@ -95,9 +95,8 @@ namespace LibationWinForms.Dialogs
|
||||
config.StripAudibleBrandAudio = stripAudibleBrandingCbox.Checked;
|
||||
config.DecryptToLossy = convertLossyRb.Checked;
|
||||
config.MoveMoovToBeginning = moveMoovAtomCbox.Checked;
|
||||
|
||||
config.LameTargetBitrate = lameTargetBitrateRb.Checked;
|
||||
config.MaxSampleRate = ((SampleRateSelection)maxSampleRateCb.SelectedItem).SampleRate;
|
||||
config.MaxSampleRate = ((EnumDiaplay<AAXClean.SampleRate>)maxSampleRateCb.SelectedItem).Value;
|
||||
config.LameEncoderQuality = (NAudio.Lame.EncoderQuality)encoderQualityCb.SelectedItem;
|
||||
encoderQualityCb.SelectedItem = config.LameEncoderQuality;
|
||||
config.LameDownsampleMono = lameDownsampleMonoCbox.Checked;
|
||||
|
||||
@ -53,6 +53,11 @@
|
||||
tab1ImportantSettings = new System.Windows.Forms.TabPage();
|
||||
betaOptInCbox = new System.Windows.Forms.CheckBox();
|
||||
booksGb = new System.Windows.Forms.GroupBox();
|
||||
lastWriteTimeCb = new System.Windows.Forms.ComboBox();
|
||||
creationTimeCb = new System.Windows.Forms.ComboBox();
|
||||
lastWriteTimeLbl = new System.Windows.Forms.Label();
|
||||
creationTimeLbl = new System.Windows.Forms.Label();
|
||||
overwriteExistingCbox = new System.Windows.Forms.CheckBox();
|
||||
saveEpisodesToSeriesFolderCbox = new System.Windows.Forms.CheckBox();
|
||||
tab2ImportLibrary = new System.Windows.Forms.TabPage();
|
||||
autoDownloadEpisodesCb = new System.Windows.Forms.CheckBox();
|
||||
@ -119,7 +124,6 @@
|
||||
retainAaxFileCbox = new System.Windows.Forms.CheckBox();
|
||||
downloadCoverArtCbox = new System.Windows.Forms.CheckBox();
|
||||
createCueSheetCbox = new System.Windows.Forms.CheckBox();
|
||||
overwriteExistingCbox = new System.Windows.Forms.CheckBox();
|
||||
badBookGb.SuspendLayout();
|
||||
tabControl.SuspendLayout();
|
||||
tab1ImportantSettings.SuspendLayout();
|
||||
@ -331,7 +335,7 @@
|
||||
//
|
||||
// logsBtn
|
||||
//
|
||||
logsBtn.Location = new System.Drawing.Point(256, 220);
|
||||
logsBtn.Location = new System.Drawing.Point(256, 261);
|
||||
logsBtn.Name = "logsBtn";
|
||||
logsBtn.Size = new System.Drawing.Size(132, 23);
|
||||
logsBtn.TabIndex = 5;
|
||||
@ -351,7 +355,7 @@
|
||||
// loggingLevelLbl
|
||||
//
|
||||
loggingLevelLbl.AutoSize = true;
|
||||
loggingLevelLbl.Location = new System.Drawing.Point(6, 223);
|
||||
loggingLevelLbl.Location = new System.Drawing.Point(6, 264);
|
||||
loggingLevelLbl.Name = "loggingLevelLbl";
|
||||
loggingLevelLbl.Size = new System.Drawing.Size(78, 15);
|
||||
loggingLevelLbl.TabIndex = 3;
|
||||
@ -361,7 +365,7 @@
|
||||
//
|
||||
loggingLevelCb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
loggingLevelCb.FormattingEnabled = true;
|
||||
loggingLevelCb.Location = new System.Drawing.Point(90, 220);
|
||||
loggingLevelCb.Location = new System.Drawing.Point(90, 261);
|
||||
loggingLevelCb.Name = "loggingLevelCb";
|
||||
loggingLevelCb.Size = new System.Drawing.Size(129, 23);
|
||||
loggingLevelCb.TabIndex = 4;
|
||||
@ -409,17 +413,69 @@
|
||||
// booksGb
|
||||
//
|
||||
booksGb.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
booksGb.Controls.Add(lastWriteTimeCb);
|
||||
booksGb.Controls.Add(creationTimeCb);
|
||||
booksGb.Controls.Add(lastWriteTimeLbl);
|
||||
booksGb.Controls.Add(creationTimeLbl);
|
||||
booksGb.Controls.Add(overwriteExistingCbox);
|
||||
booksGb.Controls.Add(saveEpisodesToSeriesFolderCbox);
|
||||
booksGb.Controls.Add(booksSelectControl);
|
||||
booksGb.Controls.Add(booksLocationDescLbl);
|
||||
booksGb.Location = new System.Drawing.Point(6, 6);
|
||||
booksGb.Name = "booksGb";
|
||||
booksGb.Size = new System.Drawing.Size(842, 182);
|
||||
booksGb.Size = new System.Drawing.Size(842, 249);
|
||||
booksGb.TabIndex = 0;
|
||||
booksGb.TabStop = false;
|
||||
booksGb.Text = "Books location";
|
||||
//
|
||||
// lastWriteTimeCb
|
||||
//
|
||||
lastWriteTimeCb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
lastWriteTimeCb.FormattingEnabled = true;
|
||||
lastWriteTimeCb.Location = new System.Drawing.Point(188, 214);
|
||||
lastWriteTimeCb.Name = "lastWriteTimeCb";
|
||||
lastWriteTimeCb.Size = new System.Drawing.Size(272, 23);
|
||||
lastWriteTimeCb.TabIndex = 5;
|
||||
//
|
||||
// creationTimeCb
|
||||
//
|
||||
creationTimeCb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
creationTimeCb.FormattingEnabled = true;
|
||||
creationTimeCb.Location = new System.Drawing.Point(188, 185);
|
||||
creationTimeCb.Name = "creationTimeCb";
|
||||
creationTimeCb.Size = new System.Drawing.Size(272, 23);
|
||||
creationTimeCb.TabIndex = 5;
|
||||
//
|
||||
// lastWriteTimeLbl
|
||||
//
|
||||
lastWriteTimeLbl.AutoSize = true;
|
||||
lastWriteTimeLbl.Location = new System.Drawing.Point(7, 217);
|
||||
lastWriteTimeLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
lastWriteTimeLbl.Name = "lastWriteTimeLbl";
|
||||
lastWriteTimeLbl.Size = new System.Drawing.Size(116, 15);
|
||||
lastWriteTimeLbl.TabIndex = 4;
|
||||
lastWriteTimeLbl.Text = "[last write time desc]";
|
||||
//
|
||||
// creationTimeLbl
|
||||
//
|
||||
creationTimeLbl.AutoSize = true;
|
||||
creationTimeLbl.Location = new System.Drawing.Point(7, 188);
|
||||
creationTimeLbl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
creationTimeLbl.Name = "creationTimeLbl";
|
||||
creationTimeLbl.Size = new System.Drawing.Size(112, 15);
|
||||
creationTimeLbl.TabIndex = 4;
|
||||
creationTimeLbl.Text = "[creation time desc]";
|
||||
//
|
||||
// overwriteExistingCbox
|
||||
//
|
||||
overwriteExistingCbox.AutoSize = true;
|
||||
overwriteExistingCbox.Location = new System.Drawing.Point(7, 156);
|
||||
overwriteExistingCbox.Name = "overwriteExistingCbox";
|
||||
overwriteExistingCbox.Size = new System.Drawing.Size(129, 19);
|
||||
overwriteExistingCbox.TabIndex = 3;
|
||||
overwriteExistingCbox.Text = "[Overwrite Existing]";
|
||||
overwriteExistingCbox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// saveEpisodesToSeriesFolderCbox
|
||||
//
|
||||
saveEpisodesToSeriesFolderCbox.AutoSize = true;
|
||||
@ -1145,16 +1201,6 @@
|
||||
createCueSheetCbox.UseVisualStyleBackColor = true;
|
||||
createCueSheetCbox.CheckedChanged += allowLibationFixupCbox_CheckedChanged;
|
||||
//
|
||||
// overwriteExistingCbox
|
||||
//
|
||||
overwriteExistingCbox.AutoSize = true;
|
||||
overwriteExistingCbox.Location = new System.Drawing.Point(7, 156);
|
||||
overwriteExistingCbox.Name = "overwriteExistingCbox";
|
||||
overwriteExistingCbox.Size = new System.Drawing.Size(129, 19);
|
||||
overwriteExistingCbox.TabIndex = 3;
|
||||
overwriteExistingCbox.Text = "[Overwrite Existing]";
|
||||
overwriteExistingCbox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// SettingsDialog
|
||||
//
|
||||
AcceptButton = saveBtn;
|
||||
@ -1300,5 +1346,9 @@
|
||||
private System.Windows.Forms.Label label21;
|
||||
private System.Windows.Forms.Label label20;
|
||||
private System.Windows.Forms.CheckBox overwriteExistingCbox;
|
||||
private System.Windows.Forms.Label creationTimeLbl;
|
||||
private System.Windows.Forms.ComboBox lastWriteTimeCb;
|
||||
private System.Windows.Forms.ComboBox creationTimeCb;
|
||||
private System.Windows.Forms.Label lastWriteTimeLbl;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using LibationFileManager;
|
||||
using LibationUiBase;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
@ -13,6 +14,15 @@ namespace LibationWinForms.Dialogs
|
||||
this.importEpisodesCb.Text = desc(nameof(config.ImportEpisodes));
|
||||
this.downloadEpisodesCb.Text = desc(nameof(config.DownloadEpisodes));
|
||||
this.autoDownloadEpisodesCb.Text = desc(nameof(config.AutoDownloadEpisodes));
|
||||
creationTimeLbl.Text = desc(nameof(config.CreationTime));
|
||||
lastWriteTimeLbl.Text = desc(nameof(config.LastWriteTime));
|
||||
|
||||
var dateTimeSources = Enum.GetValues<Configuration.DateTimeSource>().Select(v => new EnumDiaplay<Configuration.DateTimeSource>(v)).ToArray();
|
||||
creationTimeCb.Items.AddRange(dateTimeSources);
|
||||
lastWriteTimeCb.Items.AddRange(dateTimeSources);
|
||||
|
||||
creationTimeCb.SelectedItem = dateTimeSources.SingleOrDefault(v => v.Value == config.CreationTime) ?? dateTimeSources[0];
|
||||
lastWriteTimeCb.SelectedItem = dateTimeSources.SingleOrDefault(v => v.Value == config.LastWriteTime) ?? dateTimeSources[0];
|
||||
|
||||
autoScanCb.Checked = config.AutoScan;
|
||||
showImportedStatsCb.Checked = config.ShowImportedStats;
|
||||
@ -22,6 +32,9 @@ namespace LibationWinForms.Dialogs
|
||||
}
|
||||
private void Save_ImportLibrary(Configuration config)
|
||||
{
|
||||
config.CreationTime = ((EnumDiaplay<Configuration.DateTimeSource>)creationTimeCb.SelectedItem).Value;
|
||||
config.LastWriteTime = ((EnumDiaplay<Configuration.DateTimeSource>)lastWriteTimeCb.SelectedItem).Value;
|
||||
|
||||
config.AutoScan = autoScanCb.Checked;
|
||||
config.ShowImportedStats = showImportedStatsCb.Checked;
|
||||
config.ImportEpisodes = importEpisodesCb.Checked;
|
||||
|
||||
@ -107,6 +107,42 @@ namespace TemplatesTests
|
||||
.Should().Be(expected);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("<samplerate>", "", "", "100")]
|
||||
[DataRow(" <samplerate> ", "", "", "100")]
|
||||
[DataRow("4<samplerate>4", "", "", "100")]
|
||||
[DataRow("<bitrate> - <bitrate>", "", "", "1 8 - 1 8")]
|
||||
[DataRow("<bitrate> 42 <bitrate>", "", "", "1 8 1 8")]
|
||||
[DataRow(" <bitrate> - <bitrate> ", "", "", "1 8 - 1 8")]
|
||||
[DataRow("4<bitrate> - <bitrate> 4", "", "", "1 8 - 1 8")]
|
||||
[DataRow("4<bitrate> - <bitrate> 4", "", "", "1 8 - 1 8")]
|
||||
[DataRow("<channels><channels><samplerate><channels><channels>", "", "", "100")]
|
||||
[DataRow(" <channels> <channels> <samplerate> <channels> <channels>", "", "", "100")]
|
||||
[DataRow(" <channels> - <channels> <samplerate> <channels> - <channels>", "", "", "- 100 -")]
|
||||
|
||||
public void Tests_removeSpaces(string template, string dirFullPath, string extension, string expected)
|
||||
{
|
||||
if (Environment.OSVersion.Platform is not PlatformID.Win32NT)
|
||||
{
|
||||
dirFullPath = dirFullPath.Replace("C:", "").Replace('\\', '/');
|
||||
expected = expected.Replace("C:", "").Replace('\\', '/');
|
||||
}
|
||||
var replacements
|
||||
= new ReplacementCharacters
|
||||
{
|
||||
Replacements = Replacements.Replacements
|
||||
.Append(new Replacement('4', " ", ""))
|
||||
.Append(new Replacement('2', " ", ""))
|
||||
.ToArray() };
|
||||
|
||||
Templates.TryGetTemplate<Templates.FileTemplate>(template, out var fileTemplate).Should().BeTrue();
|
||||
|
||||
fileTemplate
|
||||
.GetFilename(GetLibraryBook(), dirFullPath, extension, replacements)
|
||||
.PathWithoutPrefix
|
||||
.Should().Be(expected);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("<bitrate>Kbps <samplerate>Hz", "128Kbps 44100Hz")]
|
||||
[DataRow("<bitrate>Kbps <samplerate[6]>Hz", "128Kbps 044100Hz")]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user