From dd916e5753bcecd1b91bfa8f947db0ec6da18814 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Tue, 1 Sep 2020 22:02:57 +0100 Subject: [PATCH] Added the ability to switch on and off the *arr availability scanner --- .../Jobs/ArrAvailabilityChecker.cs | 43 +++++++++++++------ .../Models/External/RadarrSettings.cs | 1 + .../Models/External/SonarrSettings.cs | 1 + .../ClientApp/src/app/interfaces/ISettings.ts | 2 + .../app/settings/radarr/radarr.component.html | 3 ++ .../app/settings/radarr/radarr.component.ts | 1 + .../app/settings/sonarr/sonarr.component.html | 3 ++ .../app/settings/sonarr/sonarr.component.ts | 1 + 8 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/Ombi.Schedule/Jobs/ArrAvailabilityChecker.cs b/src/Ombi.Schedule/Jobs/ArrAvailabilityChecker.cs index 55bb350ff..d8676ab86 100644 --- a/src/Ombi.Schedule/Jobs/ArrAvailabilityChecker.cs +++ b/src/Ombi.Schedule/Jobs/ArrAvailabilityChecker.cs @@ -7,10 +7,12 @@ using Microsoft.AspNetCore.SignalR; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Ombi.Core; +using Ombi.Core.Settings; using Ombi.Helpers; using Ombi.Hubs; using Ombi.Notifications.Models; using Ombi.Schedule.Jobs.Plex.Models; +using Ombi.Settings.Settings.Models.External; using Ombi.Store.Entities; using Ombi.Store.Repository; using Ombi.Store.Repository.Requests; @@ -20,13 +22,26 @@ namespace Ombi.Schedule.Jobs.Radarr { public class ArrAvailabilityChecker : IArrAvailabilityChecker { + private readonly IExternalRepository _radarrRepo; + private readonly IExternalRepository _sonarrRepo; + private readonly ILogger _logger; + private readonly ISettingsService _radarrSettings; + private readonly ISettingsService _sonarrSettings; + private readonly IExternalRepository _sonarrEpisodeRepo; + private readonly INotificationHelper _notification; + private readonly IHubContext _hub; + private readonly ITvRequestRepository _tvRequest; + private readonly IMovieRequestRepository _movies; + public ArrAvailabilityChecker( IExternalRepository radarrRepo, IExternalRepository sonarrRepo, IExternalRepository sonarrEpisodeRepo, INotificationHelper notification, IHubContext hub, ITvRequestRepository tvRequest, IMovieRequestRepository movies, - ILogger log) + ILogger log, + ISettingsService radarrSettings, + ISettingsService sonarrSettings) { _radarrRepo = radarrRepo; _sonarrRepo = sonarrRepo; @@ -36,21 +51,23 @@ namespace Ombi.Schedule.Jobs.Radarr _tvRequest = tvRequest; _movies = movies; _logger = log; + _radarrSettings = radarrSettings; + _sonarrSettings = sonarrSettings; } - - private readonly IExternalRepository _radarrRepo; - private readonly IExternalRepository _sonarrRepo; - private readonly ILogger _logger; - private readonly IExternalRepository _sonarrEpisodeRepo; - private readonly INotificationHelper _notification; - private readonly IHubContext _hub; - private readonly ITvRequestRepository _tvRequest; - private readonly IMovieRequestRepository _movies; - public async Task Execute(IJobExecutionContext job) { - await ProcessMovies(); - await ProcessTvShows(); + var radarrSettings = await _radarrSettings.GetSettingsAsync(); + var sonarrSettings = await _sonarrSettings.GetSettingsAsync(); + + if (radarrSettings.ScanForAvailability) + { + await ProcessMovies(); + } + + if (sonarrSettings.ScanForAvailability) + { + await ProcessTvShows(); + } } private async Task ProcessMovies() diff --git a/src/Ombi.Settings/Settings/Models/External/RadarrSettings.cs b/src/Ombi.Settings/Settings/Models/External/RadarrSettings.cs index bfed9708c..da35f8dd8 100644 --- a/src/Ombi.Settings/Settings/Models/External/RadarrSettings.cs +++ b/src/Ombi.Settings/Settings/Models/External/RadarrSettings.cs @@ -10,5 +10,6 @@ namespace Ombi.Settings.Settings.Models.External public string DefaultRootPath { get; set; } public bool AddOnly { get; set; } public string MinimumAvailability { get; set; } + public bool ScanForAvailability { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Settings/Settings/Models/External/SonarrSettings.cs b/src/Ombi.Settings/Settings/Models/External/SonarrSettings.cs index bbbe58fd3..44c910519 100644 --- a/src/Ombi.Settings/Settings/Models/External/SonarrSettings.cs +++ b/src/Ombi.Settings/Settings/Models/External/SonarrSettings.cs @@ -20,5 +20,6 @@ public bool AddOnly { get; set; } public bool V3 { get; set; } public int LanguageProfile { get; set; } + public bool ScanForAvailability { get; set; } } } \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts index 764ac25e1..ee1523a76 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts @@ -85,6 +85,7 @@ export interface ISonarrSettings extends IExternalSettings { addOnly: boolean; v3: boolean; languageProfile: number; + scanForAvailability: boolean; } export interface IRadarrSettings extends IExternalSettings { @@ -95,6 +96,7 @@ export interface IRadarrSettings extends IExternalSettings { fullRootPath: string; addOnly: boolean; minimumAvailability: string; + scanForAvailability: boolean; } export interface ILidarrSettings extends IExternalSettings { diff --git a/src/Ombi/ClientApp/src/app/settings/radarr/radarr.component.html b/src/Ombi/ClientApp/src/app/settings/radarr/radarr.component.html index 519ac8b9f..cc17543b0 100644 --- a/src/Ombi/ClientApp/src/app/settings/radarr/radarr.component.html +++ b/src/Ombi/ClientApp/src/app/settings/radarr/radarr.component.html @@ -12,6 +12,9 @@
Advanced
+
+ Scan for Availability +
diff --git a/src/Ombi/ClientApp/src/app/settings/radarr/radarr.component.ts b/src/Ombi/ClientApp/src/app/settings/radarr/radarr.component.ts index 505a188c6..cee54b65a 100644 --- a/src/Ombi/ClientApp/src/app/settings/radarr/radarr.component.ts +++ b/src/Ombi/ClientApp/src/app/settings/radarr/radarr.component.ts @@ -43,6 +43,7 @@ export class RadarrComponent implements OnInit { port: [x.port, [Validators.required]], addOnly: [x.addOnly], minimumAvailability: [x.minimumAvailability, [Validators.required]], + scanForAvailability: [x.scanForAvailability] }); if (x.defaultQualityProfile) { diff --git a/src/Ombi/ClientApp/src/app/settings/sonarr/sonarr.component.html b/src/Ombi/ClientApp/src/app/settings/sonarr/sonarr.component.html index aeda043a1..ac5327c5f 100644 --- a/src/Ombi/ClientApp/src/app/settings/sonarr/sonarr.component.html +++ b/src/Ombi/ClientApp/src/app/settings/sonarr/sonarr.component.html @@ -17,6 +17,9 @@
Advanced
+
+ Scan for Availability +
diff --git a/src/Ombi/ClientApp/src/app/settings/sonarr/sonarr.component.ts b/src/Ombi/ClientApp/src/app/settings/sonarr/sonarr.component.ts index c4cb0d920..157accf02 100644 --- a/src/Ombi/ClientApp/src/app/settings/sonarr/sonarr.component.ts +++ b/src/Ombi/ClientApp/src/app/settings/sonarr/sonarr.component.ts @@ -73,6 +73,7 @@ export class SonarrComponent implements OnInit { seasonFolders: [x.seasonFolders], v3: [x.v3], languageProfile: [x.languageProfile], + scanForAvailability: [x.scanForAvailability] }); if (x.qualityProfile) {