From 4836ab7e6c2429dc9f56a2714f1e016258d82617 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 3 Apr 2017 21:11:59 +0100 Subject: [PATCH] Finished reworking the Sonarr Integration. Seems to be working as expected, faster and most stable. It's Not A Toomah! --- Ombi.Core/Tv/TvSenderV2.cs | 14 ++++++-------- Ombi.Services/Jobs/PlexEpisodeCacher.cs | 8 ++++---- Ombi.UI/Modules/SearchModule.cs | 7 ++++--- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Ombi.Core/Tv/TvSenderV2.cs b/Ombi.Core/Tv/TvSenderV2.cs index d3ad64fa4..11a97f498 100644 --- a/Ombi.Core/Tv/TvSenderV2.cs +++ b/Ombi.Core/Tv/TvSenderV2.cs @@ -120,24 +120,21 @@ namespace Ombi.Core.Tv // Add the series return AddSeries(sonarrSettings, model, rootFolderPath, qualityId); } - + // Also make sure the series is now monitored otherwise we won't search for it series.monitored = true; foreach (var seasons in series.seasons) { - if (model.SeasonList.Any(x => x == seasons.seasonNumber)) - { - seasons.monitored = true; - } + seasons.monitored = true; } // Send the update command series = SonarrApi.UpdateSeries(series, sonarrSettings.ApiKey, sonarrSettings.FullUri); SonarrApi.SearchForSeries(series.id, sonarrSettings.ApiKey, sonarrSettings.FullUri); - return new SonarrAddSeries{title = series.title}; + return new SonarrAddSeries { title = series.title }; } - + private async Task ProcessSonarrEpisodeRequest(SonarrSettings sonarrSettings, RequestedModel model, int qualityId, string rootFolderPath) { @@ -186,7 +183,7 @@ namespace Ombi.Core.Tv await RequestEpisodesForSonarr(model, series.id, sonarrSettings); } - return new SonarrAddSeries(){title = model.Title}; + return new SonarrAddSeries() { title = model.Title }; } public SonarrAddSeries AddSeries(SonarrSettings sonarrSettings, RequestedModel model, string rootFolderPath, int qualityId) @@ -217,6 +214,7 @@ namespace Ombi.Core.Tv var season = new Season { seasonNumber = i, + // The model.SeasonList.Lenth is 0 when this is a "request all" monitored = model.SeasonList.Length == 0 || model.SeasonList.Any(x => x == i) }; seriesToAdd.seasons.Add(season); diff --git a/Ombi.Services/Jobs/PlexEpisodeCacher.cs b/Ombi.Services/Jobs/PlexEpisodeCacher.cs index 26820de94..6939ae924 100644 --- a/Ombi.Services/Jobs/PlexEpisodeCacher.cs +++ b/Ombi.Services/Jobs/PlexEpisodeCacher.cs @@ -109,7 +109,7 @@ namespace Ombi.Services.Jobs var metadata = PlexApi.GetEpisodeMetaData(settings.PlexAuthToken, settings.FullUri, video.RatingKey); // Loop through the metadata and create the model to insert into the DB - foreach (var metadataVideo in metadata.Video) + foreach (var metadataVideo in metadata?.Video ?? new List