feat(plex): Added the ability to configure the watchlist to request the whole TV show rather than latest season (#4774)

pull/4777/head
Jamie 2 years ago committed by GitHub
parent dc98613bb4
commit fa65712bd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -345,7 +345,6 @@ namespace Ombi.Schedule.Tests
[Test]
public async Task TvRequestFromWatchList_AlreadyRequested()
{
_mocker.Setup<ISettingsService<PlexSettings>, Task<PlexSettings>>(x => x.GetSettingsAsync()).ReturnsAsync(new PlexSettings { Enable = true, EnableWatchlistImport = true });
_mocker.Setup<IPlexApi, Task<PlexWatchlistContainer>>(x => x.GetWatchlist(It.IsAny<string>(), It.IsAny<CancellationToken>())).ReturnsAsync(new PlexWatchlistContainer
{
@ -540,5 +539,56 @@ namespace Ombi.Schedule.Tests
_mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.Add(It.IsAny<PlexWatchlistHistory>()), Times.Never);
_mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.GetAll(), Times.Once);
}
[Test]
public async Task TvRequestFromWatchList_RequestAllSeasons()
{
_mocker.Setup<ISettingsService<PlexSettings>, Task<PlexSettings>>(x => x.GetSettingsAsync()).ReturnsAsync(new PlexSettings { Enable = true, EnableWatchlistImport = true, MonitorAll = true });
_mocker.Setup<IPlexApi, Task<PlexWatchlistContainer>>(x => x.GetWatchlist(It.IsAny<string>(), It.IsAny<CancellationToken>())).ReturnsAsync(new PlexWatchlistContainer
{
MediaContainer = new PlexWatchlist
{
Metadata = new List<Metadata>
{
new Metadata
{
type = "show",
ratingKey = "abc"
}
}
}
});
_mocker.Setup<IPlexApi, Task<PlexWatchlistMetadataContainer>>(x => x.GetWatchlistMetadata("abc", It.IsAny<string>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(new PlexWatchlistMetadataContainer
{
MediaContainer = new PlexWatchlistMetadata
{
Metadata = new WatchlistMetadata[]
{
new WatchlistMetadata
{
Guid = new List<PlexGuids>
{
new PlexGuids
{
Id = "tmdb://123"
}
}
}
}
}
});
_mocker.Setup<ITvRequestEngine, Task<RequestEngineResult>>(x => x.RequestTvShow(It.IsAny<TvRequestViewModelV2>()))
.ReturnsAsync(new RequestEngineResult { RequestId = 1 });
await _subject.Execute(_context.Object);
_mocker.Verify<ITvRequestEngine>(x => x.RequestTvShow(It.Is<TvRequestViewModelV2>(x => x.TheMovieDbId == 123 && x.LatestSeason == false && x.RequestAll == true)), Times.Once);
_mocker.Verify<IPlexApi>(x => x.GetWatchlistMetadata("abc", It.IsAny<string>(), It.IsAny<CancellationToken>()), Times.Once);
_mocker.Verify<ITvRequestEngine>(x => x.SetUser(It.Is<OmbiUser>(x => x.Id == "abc")), Times.Once);
_mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.GetAll(), Times.Once);
_mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.Add(It.IsAny<PlexWatchlistHistory>()), Times.Once);
}
}
}

@ -125,7 +125,7 @@ namespace Ombi.Schedule.Jobs.Plex
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 @@ namespace Ombi.Schedule.Jobs.Plex
}
}
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)

@ -8,6 +8,7 @@ namespace Ombi.Core.Settings.Models.External
{
public bool Enable { get; set; }
public bool EnableWatchlistImport { get; set; }
public bool MonitorAll { get; set; }
/// <summary>
/// This is the ClientId for OAuth
/// </summary>

@ -23,7 +23,8 @@
"availability-rules",
"details",
"requests",
"sonarr"
"sonarr",
"plex"
],
"rpc.enabled": true
}

@ -113,6 +113,7 @@ export interface IPublicInfo {
export interface IPlexSettings extends ISettings {
enable: boolean;
enableWatchlistImport: boolean;
monitorAll: boolean;
servers: IPlexServer[];
}

@ -2,6 +2,11 @@ import { Component, EventEmitter, Input, Output } from "@angular/core";
@Component({
selector: "settings-plex-form-field",
styles: [`
.margin {
margin: 10px;
}
`],
template: `
<div class="row">
<div class="col-2 align-self-center">
@ -16,7 +21,7 @@ import { Component, EventEmitter, Input, Output } from "@angular/core";
<input matInput placeholder={{placeholder}} [attr.type]="type" id="{{id}}" name="{{id}}" [ngModel]="value" (ngModelChange)="change($event)" value="{{value}}">
</mat-form-field>
<mat-slide-toggle *ngIf="type === 'checkbox'" id="{{id}}" [ngModel]="value" (ngModelChange)="change($event)" [checked]="value"></mat-slide-toggle>
<mat-slide-toggle class="margin" *ngIf="type === 'checkbox'" id="{{id}}" [ngModel]="value" (ngModelChange)="change($event)" [checked]="value"></mat-slide-toggle>
<ng-content select="[below]"></ng-content>
</div>

@ -11,6 +11,12 @@
</small>
</settings-plex-form-field>
<settings-plex-form-field [label]="'Request All'" disabled [type]="'checkbox'" [id]="'monitorAll'" [(value)]="settings.monitorAll">
<small bottom>If true then watchlist requests for TV Shows, it will request the <strong><em>whole</em></strong> season. Otherwise it will only request the latest season.
</small>
</settings-plex-form-field>
<settings-plex-form-field [label]="'Advanced Options'" [type]="'checkbox'" [id]="'advanced'" [(value)]="advanced"></settings-plex-form-field>
<hr>

Loading…
Cancel
Save