feat(radarr): New --list-qualities argument

For listing quality definition types in the guide.
pull/113/head
Robert Dailey 2 years ago
parent 0c835d0807
commit 227e4e82e5

@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Radarr: New `--list-qualities` argument to get a list of quality definition types from the guide.
### Changed
- Quality definition data is now pulled from JSON files.

@ -17,13 +17,17 @@ internal class RadarrCommand : ServiceCommand
"List available custom formats from the guide in YAML format.")]
public bool ListCustomFormats { get; [UsedImplicitly] set; }
[CommandOption("list-qualities", Description =
"List available quality definition types from the guide.")]
public bool ListQualities { get; [UsedImplicitly] set; }
public override string Name => "Radarr";
public override async Task Process(IServiceLocatorProxy container)
{
await base.Process(container);
var lister = container.Resolve<ICustomFormatLister>();
var lister = container.Resolve<IRadarrGuideDataLister>();
var log = container.Resolve<ILogger>();
var customFormatUpdaterFactory = container.Resolve<Func<ICustomFormatUpdater>>();
var qualityUpdaterFactory = container.Resolve<Func<IRadarrQualityDefinitionUpdater>>();
@ -35,6 +39,12 @@ internal class RadarrCommand : ServiceCommand
return;
}
if (ListQualities)
{
lister.ListQualities();
return;
}
foreach (var config in configLoader.LoadMany(Config, "radarr"))
{
log.Information("Processing server {Url}", FlurlLogging.SanitizeUrl(config.BaseUrl));

@ -12,13 +12,13 @@ namespace TrashLib.Tests.Radarr.CustomFormat;
[TestFixture]
[Parallelizable(ParallelScope.All)]
public class CustomFormatListerTest
public class RadarrGuideDataListerTest
{
[Test, AutoMockData]
public void Custom_formats_appear_in_console_output(
[Frozen] IRadarrGuideService guide,
[Frozen(Matching.ImplementedInterfaces)] FakeInMemoryConsole console,
CustomFormatLister sut)
RadarrGuideDataLister sut)
{
var testData = new[]
{

@ -1,6 +1,7 @@
namespace TrashLib.Services.Radarr.CustomFormat;
public interface ICustomFormatLister
public interface IRadarrGuideDataLister
{
void ListCustomFormats();
void ListQualities();
}

@ -1,16 +1,17 @@
using CliFx.Infrastructure;
using JetBrains.Annotations;
using MoreLinq;
using TrashLib.Services.Radarr.CustomFormat.Guide;
namespace TrashLib.Services.Radarr.CustomFormat;
[UsedImplicitly]
public class CustomFormatLister : ICustomFormatLister
public class RadarrGuideDataLister : IRadarrGuideDataLister
{
private readonly IConsole _console;
private readonly IRadarrGuideService _guide;
public CustomFormatLister(IConsole console, IRadarrGuideService guide)
public RadarrGuideDataLister(IConsole console, IRadarrGuideService guide)
{
_console = console;
_guide = guide;
@ -30,4 +31,17 @@ public class CustomFormatLister : ICustomFormatLister
"\nThe above Custom Formats are in YAML format and ready to be copied & pasted " +
"under the `trash_ids:` property.");
}
public void ListQualities()
{
_console.Output.WriteLine("\nList of Quality Definition types in the TRaSH Guides:\n");
_guide.GetQualities()
.Select(x => x.Type)
.ForEach(x => _console.Output.WriteLine($" - {x}"));
_console.Output.WriteLine(
"\nThe above quality definition types can be used with the `quality_definition:` property in your " +
"recyclarr.yml file.");
}
}

@ -33,7 +33,7 @@ public class RadarrAutofacModule : Module
builder.RegisterType<CustomFormatUpdater>().As<ICustomFormatUpdater>();
builder.RegisterType<LocalRepoRadarrGuideService>().As<IRadarrGuideService>();
builder.RegisterType<CachePersister>().As<ICachePersister>();
builder.RegisterType<CustomFormatLister>().As<ICustomFormatLister>();
builder.RegisterType<RadarrGuideDataLister>().As<IRadarrGuideDataLister>();
// Guide Processor

Loading…
Cancel
Save