diff --git a/src/Ombi.Schedule.Tests/PlexWatchlistImportTests.cs b/src/Ombi.Schedule.Tests/PlexWatchlistImportTests.cs index 5e724b6f8..9537710a3 100644 --- a/src/Ombi.Schedule.Tests/PlexWatchlistImportTests.cs +++ b/src/Ombi.Schedule.Tests/PlexWatchlistImportTests.cs @@ -345,7 +345,6 @@ public async Task MovieRequestFromWatchList_AlreadyRequested() [Test] public async Task TvRequestFromWatchList_AlreadyRequested() { - _mocker.Setup, Task>(x => x.GetSettingsAsync()).ReturnsAsync(new PlexSettings { Enable = true, EnableWatchlistImport = true }); _mocker.Setup>(x => x.GetWatchlist(It.IsAny(), It.IsAny())).ReturnsAsync(new PlexWatchlistContainer { @@ -540,5 +539,56 @@ public async Task MovieRequestFromWatchList_AlreadyImported() _mocker.Verify>(x => x.Add(It.IsAny()), Times.Never); _mocker.Verify>(x => x.GetAll(), Times.Once); } + + + [Test] + public async Task TvRequestFromWatchList_RequestAllSeasons() + { + + _mocker.Setup, Task>(x => x.GetSettingsAsync()).ReturnsAsync(new PlexSettings { Enable = true, EnableWatchlistImport = true, MonitorAll = true }); + _mocker.Setup>(x => x.GetWatchlist(It.IsAny(), It.IsAny())).ReturnsAsync(new PlexWatchlistContainer + { + MediaContainer = new PlexWatchlist + { + Metadata = new List + { + new Metadata + { + type = "show", + ratingKey = "abc" + } + } + } + }); + _mocker.Setup>(x => x.GetWatchlistMetadata("abc", It.IsAny(), It.IsAny())) + .ReturnsAsync(new PlexWatchlistMetadataContainer + { + MediaContainer = new PlexWatchlistMetadata + { + Metadata = new WatchlistMetadata[] + { + new WatchlistMetadata + { + Guid = new List + { + new PlexGuids + { + Id = "tmdb://123" + } + } + } + } + + } + }); + _mocker.Setup>(x => x.RequestTvShow(It.IsAny())) + .ReturnsAsync(new RequestEngineResult { RequestId = 1 }); + await _subject.Execute(_context.Object); + _mocker.Verify(x => x.RequestTvShow(It.Is(x => x.TheMovieDbId == 123 && x.LatestSeason == false && x.RequestAll == true)), Times.Once); + _mocker.Verify(x => x.GetWatchlistMetadata("abc", It.IsAny(), It.IsAny()), Times.Once); + _mocker.Verify(x => x.SetUser(It.Is(x => x.Id == "abc")), Times.Once); + _mocker.Verify>(x => x.GetAll(), Times.Once); + _mocker.Verify>(x => x.Add(It.IsAny()), Times.Once); + } } } diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexWatchlistImport.cs b/src/Ombi.Schedule/Jobs/Plex/PlexWatchlistImport.cs index 3891723b7..326cf35f9 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexWatchlistImport.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexWatchlistImport.cs @@ -125,7 +125,7 @@ await _userError.Add(new PlexWatchlistUserError switch (item.type) { case "show": - await ProcessShow(int.Parse(providerIds.TheMovieDb), user); + await ProcessShow(int.Parse(providerIds.TheMovieDb), user, settings.MonitorAll); break; case "movie": await ProcessMovie(int.Parse(providerIds.TheMovieDb), user); @@ -165,10 +165,16 @@ private async Task ProcessMovie(int theMovieDbId, OmbiUser user) } } - private async Task ProcessShow(int theMovieDbId, OmbiUser user) + private async Task ProcessShow(int theMovieDbId, OmbiUser user, bool requestAll) { _tvRequestEngine.SetUser(user); - var response = await _tvRequestEngine.RequestTvShow(new TvRequestViewModelV2 { LatestSeason = true, TheMovieDbId = theMovieDbId, Source = RequestSource.PlexWatchlist }); + var requestModel = new TvRequestViewModelV2 { LatestSeason = true, TheMovieDbId = theMovieDbId, Source = RequestSource.PlexWatchlist }; + if (requestAll) + { + requestModel.RequestAll = true; + requestModel.LatestSeason = false; + } + var response = await _tvRequestEngine.RequestTvShow(requestModel); if (response.IsError) { if (response.ErrorCode == ErrorCode.AlreadyRequested) diff --git a/src/Ombi.Settings/Settings/Models/External/PlexSettings.cs b/src/Ombi.Settings/Settings/Models/External/PlexSettings.cs index 5917e2592..6edfe0351 100644 --- a/src/Ombi.Settings/Settings/Models/External/PlexSettings.cs +++ b/src/Ombi.Settings/Settings/Models/External/PlexSettings.cs @@ -8,6 +8,7 @@ public sealed class PlexSettings : Ombi.Settings.Settings.Models.Settings { public bool Enable { get; set; } public bool EnableWatchlistImport { get; set; } + public bool MonitorAll { get; set; } /// /// This is the ClientId for OAuth /// diff --git a/src/Ombi/.vscode/settings.json b/src/Ombi/.vscode/settings.json index d0eaf2fe6..6274dd334 100644 --- a/src/Ombi/.vscode/settings.json +++ b/src/Ombi/.vscode/settings.json @@ -23,7 +23,8 @@ "availability-rules", "details", "requests", - "sonarr" + "sonarr", + "plex" ], "rpc.enabled": true } diff --git a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts index 1c66fff92..91874d967 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts @@ -113,6 +113,7 @@ export interface IPublicInfo { export interface IPlexSettings extends ISettings { enable: boolean; enableWatchlistImport: boolean; + monitorAll: boolean; servers: IPlexServer[]; } diff --git a/src/Ombi/ClientApp/src/app/settings/plex/components/form-field/plex-form-field.component.ts b/src/Ombi/ClientApp/src/app/settings/plex/components/form-field/plex-form-field.component.ts index 46518b0d0..0e2f518c5 100644 --- a/src/Ombi/ClientApp/src/app/settings/plex/components/form-field/plex-form-field.component.ts +++ b/src/Ombi/ClientApp/src/app/settings/plex/components/form-field/plex-form-field.component.ts @@ -2,6 +2,11 @@ import { Component, EventEmitter, Input, Output } from "@angular/core"; @Component({ selector: "settings-plex-form-field", + styles: [` + .margin { + margin: 10px; + } + `], template: `
@@ -16,7 +21,7 @@ import { Component, EventEmitter, Input, Output } from "@angular/core"; - +
diff --git a/src/Ombi/ClientApp/src/app/settings/plex/plex.component.html b/src/Ombi/ClientApp/src/app/settings/plex/plex.component.html index 53b0eed29..53077fe01 100644 --- a/src/Ombi/ClientApp/src/app/settings/plex/plex.component.html +++ b/src/Ombi/ClientApp/src/app/settings/plex/plex.component.html @@ -11,6 +11,12 @@ + + If true then watchlist requests for TV Shows, it will request the whole season. Otherwise it will only request the latest season. + + + +