Add Locate Audiobooks function (#485)

This commit is contained in:
Mbucari 2023-02-10 09:35:21 -07:00
parent c4acd5d208
commit bba9c2ba7b
16 changed files with 530 additions and 20 deletions

View file

@ -1,6 +1,7 @@
using ApplicationServices;
using Avalonia.Controls;
using Avalonia.Platform.Storage;
using FileManager;
using LibationFileManager;
using System;
using System.Linq;
@ -20,14 +21,14 @@ namespace LibationAvalonia.Views
{
Title = "Where to export Library",
SuggestedStartLocation = new Avalonia.Platform.Storage.FileIO.BclStorageFolder(Configuration.Instance.Books.PathWithoutPrefix),
SuggestedFileName = $"Libation Library Export {DateTime.Now:yyyy-MM-dd}.xlsx",
SuggestedFileName = $"Libation Library Export {DateTime.Now:yyyy-MM-dd}",
DefaultExtension = "xlsx",
ShowOverwritePrompt = true,
FileTypeChoices = new FilePickerFileType[]
{
new("Excel Workbook (*.xlsx)") { Patterns = new[] { "xlsx" } },
new("CSV files (*.csv)") { Patterns = new[] { "csv" } },
new("JSON files (*.json)") { Patterns = new[] { "json" } },
new("Excel Workbook (*.xlsx)") { Patterns = new[] { "*.xlsx" } },
new("CSV files (*.csv)") { Patterns = new[] { "*.csv" } },
new("JSON files (*.json)") { Patterns = new[] { "*.json" } },
new("All files (*.*)") { Patterns = new[] { "*" } },
}
};
@ -36,17 +37,17 @@ namespace LibationAvalonia.Views
if (selectedFile?.TryGetUri(out var uri) is not true) return;
var ext = System.IO.Path.GetExtension(uri.LocalPath);
var ext = FileUtility.GetStandardizedExtension(System.IO.Path.GetExtension(uri.LocalPath));
switch (ext)
{
case "xlsx": // xlsx
case ".xlsx": // xlsx
default:
LibraryExporter.ToXlsx(uri.LocalPath);
break;
case "csv": // csv
case ".csv": // csv
LibraryExporter.ToCsv(uri.LocalPath);
break;
case "json": // json
case ".json": // json
LibraryExporter.ToJson(uri.LocalPath);
break;
}

View file

@ -1,6 +1,7 @@
using ApplicationServices;
using AudibleUtilities;
using Avalonia.Controls;
using LibationAvalonia.Dialogs;
using LibationFileManager;
using System;
using System.Collections.Generic;
@ -77,5 +78,11 @@ namespace LibationAvalonia.Views
ex);
}
}
private async void locateAudiobooksToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
{
var locateDialog = new LocateAudiobooksDialog();
await locateDialog.ShowDialog(this);
}
}
}

View file

@ -51,6 +51,9 @@
<MenuItem IsVisible="{Binding OneAccount}" IsEnabled="{Binding RemoveMenuItemsEnabled}" Click="removeLibraryBooksToolStripMenuItem_Click" Header="_Remove Library Books" />
<MenuItem IsVisible="{Binding MultipleAccounts}" IsEnabled="{Binding RemoveMenuItemsEnabled}" Click="removeAllAccountsToolStripMenuItem_Click" Header="_Remove Books from All Accounts" />
<MenuItem IsVisible="{Binding MultipleAccounts}" IsEnabled="{Binding RemoveMenuItemsEnabled}" Click="removeSomeAccountsToolStripMenuItem_Click" Header="_Remove Books from Some Accounts" />
<Separator />
<MenuItem Click="locateAudiobooksToolStripMenuItem_Click" Header="Locate Audiobooks" />
</MenuItem>