feat(sonarr): New --list-release-profiles command line option

Can be used to quickly and conveniently get a list of release profiles
(and their Trash IDs) so you know what to add in your YAML config under
`release_profiles`.
pull/63/head
Robert Dailey 2 years ago
parent d598537003
commit 305ae296ab

@ -26,6 +26,9 @@ JSON files][sonarrjson]. This breaks existing `trash.yml` and manual changes *ar
Docker.
- Sonarr: Ability to include or exclude specific optional Required, Ignored, or Preferred terms in
release profiles.
- Sonarr: New `--list-release-profiles` command line option which can be used to quickly and
conveniently get a list of release profiles (and their Trash IDs) so you know what to add in your
YAML config under `release_profiles`.
[#17]: https://github.com/rcdailey/trash-updater/issues/17
[Upgrade Guide]: https://github.com/rcdailey/trash-updater/wiki/Upgrade-Guide

@ -23,6 +23,8 @@ Automatically mirror TRaSH guides to your Sonarr/Radarr instance.
- Ability to convert preferred with negative scores to "Must not contain" terms.
- Terms mentioned as "optional" in the guide can be selectively included or excluded; based entirely
on user preference.
- Convenient command line options to get information from the guide to more easily add it to your
YAML configuration.
### Quality Definitions

@ -6,6 +6,7 @@ using Serilog.Core;
using Trash.Config;
using TrashLib.Config.Settings;
using TrashLib.Repo;
using TrashLib.Sonarr;
using TrashLib.Sonarr.Config;
using TrashLib.Sonarr.QualityDefinition;
using TrashLib.Sonarr.ReleaseProfile;
@ -20,6 +21,11 @@ public class SonarrCommand : ServiceCommand
private readonly ILogger _log;
private readonly Func<IReleaseProfileUpdater> _profileUpdaterFactory;
private readonly Func<ISonarrQualityDefinitionUpdater> _qualityUpdaterFactory;
private readonly IReleaseProfileLister _lister;
[CommandOption("list-release-profiles", Description =
"List available release profiles from the guide in YAML format.")]
public bool ListReleaseProfiles { get; [UsedImplicitly] set; } = false;
public SonarrCommand(
ILogger log,
@ -30,13 +36,15 @@ public class SonarrCommand : ServiceCommand
IRepoUpdater repoUpdater,
IConfigurationLoader<SonarrConfiguration> configLoader,
Func<IReleaseProfileUpdater> profileUpdaterFactory,
Func<ISonarrQualityDefinitionUpdater> qualityUpdaterFactory)
Func<ISonarrQualityDefinitionUpdater> qualityUpdaterFactory,
IReleaseProfileLister lister)
: base(log, loggingLevelSwitch, logJanitor, settingsPersister, settingsProvider, repoUpdater)
{
_log = log;
_configLoader = configLoader;
_profileUpdaterFactory = profileUpdaterFactory;
_qualityUpdaterFactory = qualityUpdaterFactory;
_lister = lister;
}
public override string CacheStoragePath { get; } =
@ -46,6 +54,12 @@ public class SonarrCommand : ServiceCommand
{
try
{
if (ListReleaseProfiles)
{
_lister.ListReleaseProfiles();
return;
}
foreach (var config in _configLoader.LoadMany(Config, "sonarr"))
{
_log.Information("Processing server {Url}", config.BaseUrl);

@ -0,0 +1,6 @@
namespace TrashLib.Sonarr;
public interface IReleaseProfileLister
{
void ListReleaseProfiles();
}

@ -0,0 +1,32 @@
using CliFx.Infrastructure;
using JetBrains.Annotations;
using TrashLib.Sonarr.ReleaseProfile.Guide;
namespace TrashLib.Sonarr;
[UsedImplicitly]
public class ReleaseProfileLister : IReleaseProfileLister
{
private readonly IConsole _console;
private readonly ISonarrGuideService _guide;
public ReleaseProfileLister(IConsole console, ISonarrGuideService guide)
{
_console = console;
_guide = guide;
}
public void ListReleaseProfiles()
{
_console.Output.WriteLine("\nList of Release Profiles in the TRaSH Guides:\n");
var profilesFromGuide = _guide.GetReleaseProfileData();
foreach (var profile in profilesFromGuide)
{
_console.Output.WriteLine($" - {profile.TrashId} # {profile.Name}");
}
_console.Output.WriteLine(
"\nThe above Release Profiles are in YAML format and ready to be copied & pasted under the `trash_ids:` property.");
}
}

@ -13,10 +13,8 @@ public class SonarrAutofacModule : Module
{
builder.RegisterType<SonarrApi>().As<ISonarrApi>();
builder.RegisterType<SonarrValidationMessages>().As<ISonarrValidationMessages>();
builder.RegisterType<SonarrCompatibility>()
.As<ISonarrCompatibility>()
.SingleInstance();
builder.RegisterType<SonarrCompatibility>().As<ISonarrCompatibility>().SingleInstance();
builder.RegisterType<ReleaseProfileLister>().As<IReleaseProfileLister>();
// Release Profile Support
builder.RegisterType<ReleaseProfileUpdater>().As<IReleaseProfileUpdater>();

@ -3,6 +3,7 @@
<PackageReference Include="AutoMapper" />
<PackageReference Include="Autofac" />
<PackageReference Include="Autofac.Extras.AggregateService" />
<PackageReference Include="CliFx" />
<PackageReference Include="FluentValidation" />
<PackageReference Include="Flurl" />
<PackageReference Include="Flurl.Http" />

Loading…
Cancel
Save