Overhaul LibationCli
Add version verb with option to check for upgrade Add Search verb to search the library Add export file type inference Add more set-status options Add console progress bar and ETA Add processable option to liberate specific book IDs Scan accounts by nickname or account ID Improve startup performance for halp and on parsing error More useful error messages
This commit is contained in:
parent
bb05847b25
commit
29803c6ba0
14 changed files with 477 additions and 146 deletions
|
|
@ -1,23 +1,34 @@
|
|||
using System;
|
||||
using ApplicationServices;
|
||||
using CommandLine;
|
||||
using DataLayer;
|
||||
using Dinah.Core;
|
||||
using FileLiberator;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ApplicationServices;
|
||||
using CommandLine;
|
||||
using DataLayer;
|
||||
using FileLiberator;
|
||||
|
||||
namespace LibationCli
|
||||
{
|
||||
public abstract class ProcessableOptionsBase : OptionsBase
|
||||
{
|
||||
|
||||
[Value(0, MetaName = "[asins]", HelpText = "Optional product IDs of books to process.")]
|
||||
public IEnumerable<string> Asins { get; set; }
|
||||
|
||||
protected static TProcessable CreateProcessable<TProcessable>(EventHandler<LibraryBook> completedAction = null)
|
||||
where TProcessable : Processable, new()
|
||||
{
|
||||
var progressBar = new ConsoleProgressBar(Console.Out);
|
||||
var strProc = new TProcessable();
|
||||
|
||||
strProc.Begin += (o, e) => Console.WriteLine($"{typeof(TProcessable).Name} Begin: {e}");
|
||||
strProc.Completed += (o, e) => Console.WriteLine($"{typeof(TProcessable).Name} Completed: {e}");
|
||||
|
||||
strProc.Completed += (o, e) =>
|
||||
{
|
||||
progressBar.Clear();
|
||||
Console.WriteLine($"{typeof(TProcessable).Name} Completed: {e}");
|
||||
};
|
||||
|
||||
strProc.Completed += (s, e) =>
|
||||
{
|
||||
|
|
@ -32,12 +43,23 @@ namespace LibationCli
|
|||
}
|
||||
};
|
||||
|
||||
strProc.StreamingTimeRemaining += (_, e) => progressBar.RemainingTime = e;
|
||||
strProc.StreamingProgressChanged += (_, e) => progressBar.Progress = e.ProgressPercentage;
|
||||
|
||||
return strProc;
|
||||
}
|
||||
|
||||
protected static async Task RunAsync(Processable Processable)
|
||||
protected async Task RunAsync(Processable Processable)
|
||||
{
|
||||
foreach (var libraryBook in Processable.GetValidLibraryBooks(DbContexts.GetLibrary_Flat_NoTracking()))
|
||||
var libraryBooks = DbContexts.GetLibrary_Flat_NoTracking().AsEnumerable();
|
||||
|
||||
if (Asins.Any())
|
||||
{
|
||||
var asinsLower = Asins.Select(a => a.ToLower()).ToArray();
|
||||
libraryBooks = libraryBooks.Where(lb => lb.Book.AudibleProductId.ToLower().In(asinsLower));
|
||||
}
|
||||
|
||||
foreach (var libraryBook in Processable.GetValidLibraryBooks(libraryBooks))
|
||||
await ProcessOneAsync(Processable, libraryBook, false);
|
||||
|
||||
var done = "Done. All books have been processed";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue