mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
feat(plex): ✨ Added the ability to configure the watchlist to request the whole TV show rather than latest season (#4774)
This commit is contained in:
parent
dc98613bb4
commit
fa65712bd5
7 changed files with 76 additions and 6 deletions
|
@ -345,7 +345,6 @@ namespace Ombi.Schedule.Tests
|
||||||
[Test]
|
[Test]
|
||||||
public async Task TvRequestFromWatchList_AlreadyRequested()
|
public async Task TvRequestFromWatchList_AlreadyRequested()
|
||||||
{
|
{
|
||||||
|
|
||||||
_mocker.Setup<ISettingsService<PlexSettings>, Task<PlexSettings>>(x => x.GetSettingsAsync()).ReturnsAsync(new PlexSettings { Enable = true, EnableWatchlistImport = true });
|
_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
|
_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.Add(It.IsAny<PlexWatchlistHistory>()), Times.Never);
|
||||||
_mocker.Verify<IExternalRepository<PlexWatchlistHistory>>(x => x.GetAll(), Times.Once);
|
_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)
|
switch (item.type)
|
||||||
{
|
{
|
||||||
case "show":
|
case "show":
|
||||||
await ProcessShow(int.Parse(providerIds.TheMovieDb), user);
|
await ProcessShow(int.Parse(providerIds.TheMovieDb), user, settings.MonitorAll);
|
||||||
break;
|
break;
|
||||||
case "movie":
|
case "movie":
|
||||||
await ProcessMovie(int.Parse(providerIds.TheMovieDb), user);
|
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);
|
_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.IsError)
|
||||||
{
|
{
|
||||||
if (response.ErrorCode == ErrorCode.AlreadyRequested)
|
if (response.ErrorCode == ErrorCode.AlreadyRequested)
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace Ombi.Core.Settings.Models.External
|
||||||
{
|
{
|
||||||
public bool Enable { get; set; }
|
public bool Enable { get; set; }
|
||||||
public bool EnableWatchlistImport { get; set; }
|
public bool EnableWatchlistImport { get; set; }
|
||||||
|
public bool MonitorAll { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is the ClientId for OAuth
|
/// This is the ClientId for OAuth
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
3
src/Ombi/.vscode/settings.json
vendored
3
src/Ombi/.vscode/settings.json
vendored
|
@ -23,7 +23,8 @@
|
||||||
"availability-rules",
|
"availability-rules",
|
||||||
"details",
|
"details",
|
||||||
"requests",
|
"requests",
|
||||||
"sonarr"
|
"sonarr",
|
||||||
|
"plex"
|
||||||
],
|
],
|
||||||
"rpc.enabled": true
|
"rpc.enabled": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,7 @@ export interface IPublicInfo {
|
||||||
export interface IPlexSettings extends ISettings {
|
export interface IPlexSettings extends ISettings {
|
||||||
enable: boolean;
|
enable: boolean;
|
||||||
enableWatchlistImport: boolean;
|
enableWatchlistImport: boolean;
|
||||||
|
monitorAll: boolean;
|
||||||
servers: IPlexServer[];
|
servers: IPlexServer[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,11 @@ import { Component, EventEmitter, Input, Output } from "@angular/core";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "settings-plex-form-field",
|
selector: "settings-plex-form-field",
|
||||||
|
styles: [`
|
||||||
|
.margin {
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
`],
|
||||||
template: `
|
template: `
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-2 align-self-center">
|
<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}}">
|
<input matInput placeholder={{placeholder}} [attr.type]="type" id="{{id}}" name="{{id}}" [ngModel]="value" (ngModelChange)="change($event)" value="{{value}}">
|
||||||
</mat-form-field>
|
</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>
|
<ng-content select="[below]"></ng-content>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,6 +11,12 @@
|
||||||
</small>
|
</small>
|
||||||
</settings-plex-form-field>
|
</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>
|
<settings-plex-form-field [label]="'Advanced Options'" [type]="'checkbox'" [id]="'advanced'" [(value)]="advanced"></settings-plex-form-field>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue