diff --git a/src/Ombi.Api.Sonarr/SonarrV3Api.cs b/src/Ombi.Api.Sonarr/SonarrV3Api.cs index 6cf94b825..0f5b27ac8 100644 --- a/src/Ombi.Api.Sonarr/SonarrV3Api.cs +++ b/src/Ombi.Api.Sonarr/SonarrV3Api.cs @@ -49,7 +49,7 @@ public Task GetTag(int tagId, string apiKey, string baseUrl) public async Task> MonitorEpisode(int[] episodeIds, bool monitor, string apiKey, string baseUrl) { - var request = new Request($"{ApiBaseUrl}Episode/monitor", baseUrl, HttpMethod.Put); + var request = new Request($"{ApiBaseUrl}episode/monitor", baseUrl, HttpMethod.Put); request.AddHeader("X-Api-Key", apiKey); request.AddJsonBody(new { episodeIds = episodeIds, monitored = monitor }); return await Api.Request>(request); diff --git a/src/Ombi.Core/Senders/TvSender.cs b/src/Ombi.Core/Senders/TvSender.cs index 68a7507e7..247ce8b6e 100644 --- a/src/Ombi.Core/Senders/TvSender.cs +++ b/src/Ombi.Core/Senders/TvSender.cs @@ -1,13 +1,9 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; -using Microsoft.VisualBasic; -using Ombi.Api.DogNzb; -using Ombi.Api.DogNzb.Models; using Ombi.Api.SickRage; using Ombi.Api.SickRage.Models; using Ombi.Api.Sonarr; @@ -23,15 +19,13 @@ namespace Ombi.Core.Senders { public class TvSender : ITvSender { - public TvSender(ISonarrApi sonarrApi, ISonarrV3Api sonarrV3Api, ILogger log, ISettingsService sonarrSettings, - ISettingsService dog, IDogNzbApi dogApi, ISettingsService srSettings, + public TvSender(ISonarrV3Api sonarrV3Api, ILogger log, ISettingsService sonarrSettings, + ISettingsService srSettings, ISickRageApi srApi, IRepository userProfiles, IRepository requestQueue, INotificationHelper notify) { SonarrApi = sonarrV3Api; Logger = log; SonarrSettings = sonarrSettings; - DogNzbSettings = dog; - DogNzbApi = dogApi; SickRageSettings = srSettings; SickRageApi = srApi; UserQualityProfiles = userProfiles; @@ -40,11 +34,9 @@ public TvSender(ISonarrApi sonarrApi, ISonarrV3Api sonarrV3Api, ILogger Logger { get; } private ISettingsService SonarrSettings { get; } - private ISettingsService DogNzbSettings { get; } private ISettingsService SickRageSettings { get; } private IRepository UserQualityProfiles { get; } private readonly IRepository _requestQueueRepository; @@ -67,23 +59,7 @@ public async Task Send(ChildRequests model) }; } } - var dog = await DogNzbSettings.GetSettingsAsync(); - if (dog.Enabled) - { - var result = await SendToDogNzb(model, dog); - if (!result.Failure) - { - return new SenderResult - { - Sent = true, - Success = true - }; - } - return new SenderResult - { - Message = result.ErrorMessage - }; - } + var sr = await SickRageSettings.GetSettingsAsync(); if (sr.Enabled) { @@ -137,12 +113,6 @@ await _requestQueueRepository.Add(new RequestQueue }; } - private async Task SendToDogNzb(ChildRequests model, DogNzbSettings settings) - { - var id = model.ParentRequest.ExternalProviderId; - return await DogNzbApi.AddTvShow(settings.ApiKey, id.ToString()); - } - /// /// Send the request to Sonarr to process /// @@ -216,30 +186,19 @@ public async Task SendToSonarr(ChildRequests model, SonarrSettings s) } // Overrides on the request take priority - if (model.ParentRequest.QualityOverride.HasValue) + if (model.ParentRequest.QualityOverride.HasValue && model.ParentRequest.QualityOverride.Value > 0) { - var qualityOverride = model.ParentRequest.QualityOverride.Value; - if (qualityOverride > 0) - { - qualityToUse = qualityOverride; - } + qualityToUse = model.ParentRequest.QualityOverride.Value; } - if (model.ParentRequest.RootFolder.HasValue) + + if (model.ParentRequest.RootFolder.HasValue && model.ParentRequest.RootFolder.Value > 0) { - var rootfolderOverride = model.ParentRequest.RootFolder.Value; - if (rootfolderOverride > 0) - { - rootFolderPath = await GetSonarrRootPath(rootfolderOverride, s); - } + rootFolderPath = await GetSonarrRootPath(model.ParentRequest.RootFolder.Value, s); } - if (model.ParentRequest.LanguageProfile.HasValue) + if (model.ParentRequest.LanguageProfile.HasValue && model.ParentRequest.LanguageProfile.Value > 0) { - var languageProfile = model.ParentRequest.LanguageProfile.Value; - if (languageProfile > 0) - { - languageProfileId = languageProfile; - } + languageProfileId = model.ParentRequest.LanguageProfile.Value; } try @@ -424,10 +383,11 @@ private async Task SendToSonarr(ChildRequests model, SonarrSeries result, Sonarr await SonarrApi.MonitorEpisode(epToUnmonitored.Select(x => x.id).ToArray(), false, s.ApiKey, s.FullUri); } - // Now update the episodes that need updating - await SonarrApi.MonitorEpisode(episodesToUpdate.Where(x => x.seasonNumber == season.SeasonNumber).Select(x => x.id).ToArray(), true, s.ApiKey, s.FullUri); } + // Now update the episodes that need updating + await SonarrApi.MonitorEpisode(episodesToUpdate.Select(x => x.id).ToArray(), true, s.ApiKey, s.FullUri); + if (!s.AddOnly) { await SearchForRequest(model, sonarrEpList, result, s, episodesToUpdate);