From 168c51c29319c4d3823df5365b1c7bb66451412f Mon Sep 17 00:00:00 2001 From: tidusjar Date: Thu, 26 Oct 2017 21:27:27 +0100 Subject: [PATCH] Fixed sonarr not monitoring the latest season #1534 --- src/Ombi.Api.Sonarr/ISonarrApi.cs | 1 + src/Ombi.Api.Sonarr/Models/SeasonPass.cs | 41 ++++++++++++++++++++++++ src/Ombi.Api.Sonarr/SonarrApi.cs | 25 ++++++++++++++- src/Ombi.Core/Senders/TvSender.cs | 2 +- 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 src/Ombi.Api.Sonarr/Models/SeasonPass.cs diff --git a/src/Ombi.Api.Sonarr/ISonarrApi.cs b/src/Ombi.Api.Sonarr/ISonarrApi.cs index adde47b58..9816b9604 100644 --- a/src/Ombi.Api.Sonarr/ISonarrApi.cs +++ b/src/Ombi.Api.Sonarr/ISonarrApi.cs @@ -20,5 +20,6 @@ namespace Ombi.Api.Sonarr Task SeasonSearch(int seriesId, int seasonNumber, string apiKey, string baseUrl); Task SeriesSearch(int seriesId, string apiKey, string baseUrl); Task SystemStatus(string apiKey, string baseUrl); + Task SeasonPass(string apiKey, string baseUrl, SonarrSeries series); } } \ No newline at end of file diff --git a/src/Ombi.Api.Sonarr/Models/SeasonPass.cs b/src/Ombi.Api.Sonarr/Models/SeasonPass.cs new file mode 100644 index 000000000..6903bd418 --- /dev/null +++ b/src/Ombi.Api.Sonarr/Models/SeasonPass.cs @@ -0,0 +1,41 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2017 Jamie Rees +// File: SeasonPass.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion +namespace Ombi.Api.Sonarr.Models +{ + + public class SeasonPass + { + public SonarrSeries[] series { get; set; } + public Monitoringoptions monitoringOptions { get; set; } + } + + public class Monitoringoptions + { + public bool ignoreEpisodesWithFiles { get; set; } + public bool ignoreEpisodesWithoutFiles { get; set; } + } +} \ No newline at end of file diff --git a/src/Ombi.Api.Sonarr/SonarrApi.cs b/src/Ombi.Api.Sonarr/SonarrApi.cs index 4b5be973d..8753203a2 100644 --- a/src/Ombi.Api.Sonarr/SonarrApi.cs +++ b/src/Ombi.Api.Sonarr/SonarrApi.cs @@ -1,4 +1,5 @@ -using System.Net.Http; +using System; +using System.Net.Http; using System.Collections.Generic; using System.Threading.Tasks; @@ -199,5 +200,27 @@ namespace Ombi.Api.Sonarr return await Api.Request(request); } + + public async Task SeasonPass(string apiKey, string baseUrl, SonarrSeries series) + { + var seasonPass = new SeasonPass + { + series = new [] + { + series + }, + monitoringOptions = new Monitoringoptions + { + ignoreEpisodesWithFiles = false, + ignoreEpisodesWithoutFiles = false, + } + }; + var request = new Request("/api/seasonpass", baseUrl, HttpMethod.Post); + request.AddHeader("X-Api-Key", apiKey); + request.AddJsonBody(seasonPass); + + var content = await Api.RequestContent(request); + return content.Equals("ok", StringComparison.CurrentCultureIgnoreCase); + } } } diff --git a/src/Ombi.Core/Senders/TvSender.cs b/src/Ombi.Core/Senders/TvSender.cs index 45f960a36..a4acd24fa 100644 --- a/src/Ombi.Core/Senders/TvSender.cs +++ b/src/Ombi.Core/Senders/TvSender.cs @@ -230,7 +230,7 @@ namespace Ombi.Core.Senders } if (seriesChanges) { - await SonarrApi.UpdateSeries(result, s.ApiKey, s.FullUri); + await SonarrApi.SeasonPass(s.ApiKey, s.FullUri, result); }