|
|
|
@ -35,6 +35,7 @@ using PlexRequests.Api.Models.Sonarr;
|
|
|
|
|
using PlexRequests.Core.SettingModels;
|
|
|
|
|
using PlexRequests.Store;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
using PlexRequests.Helpers.Exceptions;
|
|
|
|
@ -81,7 +82,7 @@ namespace PlexRequests.UI.Helpers
|
|
|
|
|
// Series Exists
|
|
|
|
|
// Request the episodes in the existing series
|
|
|
|
|
await RequestEpisodesWithExistingSeries(model, series, sonarrSettings);
|
|
|
|
|
return new SonarrAddSeries {title = series.title};
|
|
|
|
|
return new SonarrAddSeries { title = series.title };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -93,7 +94,7 @@ namespace PlexRequests.UI.Helpers
|
|
|
|
|
|
|
|
|
|
// Get the series that was just added
|
|
|
|
|
series = await GetSonarrSeries(sonarrSettings, model.ProviderId);
|
|
|
|
|
series.monitored = false; // Un-monitor the series
|
|
|
|
|
series.monitored = true; // We want to make sure we are monitoring the series
|
|
|
|
|
|
|
|
|
|
// Un-monitor all seasons
|
|
|
|
|
foreach (var season in series.seasons)
|
|
|
|
@ -112,6 +113,12 @@ namespace PlexRequests.UI.Helpers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (series != null)
|
|
|
|
|
{
|
|
|
|
|
var requestAll = model.SeasonsRequested.Equals("All", StringComparison.CurrentCultureIgnoreCase);
|
|
|
|
|
var first = model.SeasonsRequested.Equals("First", StringComparison.CurrentCultureIgnoreCase);
|
|
|
|
|
var latest = model.SeasonsRequested.Equals("Latest", StringComparison.CurrentCultureIgnoreCase);
|
|
|
|
|
|
|
|
|
|
if (model.SeasonList.Any())
|
|
|
|
|
{
|
|
|
|
|
// Monitor the seasons that we have chosen
|
|
|
|
|
foreach (var season in series.seasons)
|
|
|
|
@ -121,6 +128,29 @@ namespace PlexRequests.UI.Helpers
|
|
|
|
|
season.monitored = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (requestAll)
|
|
|
|
|
{
|
|
|
|
|
// Monitor all seasons
|
|
|
|
|
foreach (var season in series.seasons)
|
|
|
|
|
{
|
|
|
|
|
season.monitored = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (first)
|
|
|
|
|
{
|
|
|
|
|
var firstSeries = series?.seasons?.OrderBy(x => x.seasonNumber)?.FirstOrDefault() ?? new Season();
|
|
|
|
|
firstSeries.monitored = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (latest)
|
|
|
|
|
{
|
|
|
|
|
var lastSeries = series?.seasons?.OrderByDescending(x => x.seasonNumber)?.FirstOrDefault() ?? new Season();
|
|
|
|
|
lastSeries.monitored = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update the series in sonarr with the new monitored status
|
|
|
|
|
SonarrApi.UpdateSeries(series, sonarrSettings.ApiKey, sonarrSettings.FullUri);
|
|
|
|
@ -201,7 +231,7 @@ namespace PlexRequests.UI.Helpers
|
|
|
|
|
var tasks = new List<Task>();
|
|
|
|
|
foreach (var r in episodes)
|
|
|
|
|
{
|
|
|
|
|
if(r.monitored || r.hasFile) // If it's already montiored or has the file, there is no point in updating it
|
|
|
|
|
if (r.monitored || r.hasFile) // If it's already montiored or has the file, there is no point in updating it
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|