fix(discover): TV shows now display on the Actor Pages (#4388)

* Add TV shows to Actor discover page

* Fix actor page not loading after actor change

* Remove user filter from discover actor page

* Clean up code
pull/4395/head
sephrat 3 years ago committed by GitHub
parent 907353a54d
commit 6b716e7220
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Ombi.Api.TheMovieDb.Models;
using Ombi.Core.Models.Search;
using Ombi.Core.Models.Search.V2;
@ -10,6 +11,7 @@ namespace Ombi.Core
{
Task<SearchFullInfoTvShowViewModel> GetShowInformation(string tvdbid, CancellationToken token);
Task<SearchFullInfoTvShowViewModel> GetShowByRequest(int requestId, CancellationToken token);
Task<ActorCredits> GetTvByActor(int actorId, string langCode);
Task<IEnumerable<StreamingData>> GetStreamInformation(int movieDbId, CancellationToken cancellationToken);
Task<IEnumerable<SearchTvShowViewModel>> Popular(int currentlyLoaded, int amountToLoad, string langCustomCode = null);
Task<IEnumerable<SearchTvShowViewModel>> Anticipated(int currentlyLoaded, int amountToLoad);

@ -147,6 +147,12 @@ namespace Ombi.Core.Engine.V2
return await processed;
}
public async Task<ActorCredits> GetTvByActor(int actorId, string langCode)
{
var result = await Cache.GetOrAddAsync(nameof(GetTvByActor) + actorId + langCode,
() => _movieApi.GetActorTvCredits(actorId, langCode), DateTimeOffset.Now.AddHours(12));
return result;
}
public async Task<IEnumerable<StreamingData>> GetStreamInformation(int movieDbId, CancellationToken cancellationToken)
{

@ -31,6 +31,7 @@ namespace Ombi.Api.TheMovieDb
Task<TvInfo> GetTVInfo(string themoviedbid, string langCode = "en");
Task<TheMovieDbContainer<ActorResult>> SearchByActor(string searchTerm, string langCode);
Task<ActorCredits> GetActorMovieCredits(int actorId, string langCode);
Task<ActorCredits> GetActorTvCredits(int actorId, string langCode);
Task<TheMovieDbContainer<MultiSearch>> MultiSearch(string searchTerm, string languageCode, CancellationToken cancellationToken);
Task<TheMovieDbContainer<DiscoverMovies>> DiscoverMovies(string langCode, int keywordId);
Task<FullMovieInfo> GetFullMovieInfo(int movieId, CancellationToken cancellationToken, string langCode);

@ -139,6 +139,16 @@ namespace Ombi.Api.TheMovieDb
var result = await Api.Request<ActorCredits>(request);
return result;
}
public async Task<ActorCredits> GetActorTvCredits(int actorId, string langCode)
{
var request = new Request($"person/{actorId}/tv_credits", BaseUri, HttpMethod.Get);
request.AddQueryString("api_key", ApiToken);
request.AddQueryString("language", langCode);
var result = await Api.Request<ActorCredits>(request);
return result;
}
public async Task<List<TvSearchResult>> SearchTv(string searchTerm, string year = default)
{

@ -1,4 +1,4 @@
<div class="small-middle-container" *ngIf="actorCredits">
<div class="small-middle-container">
<div *ngIf="loadingFlag" class="row justify-content-md-center top-space loading-spinner">
<mat-spinner [color]="'accent'"></mat-spinner>

@ -1,10 +1,12 @@
import { Component } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { SearchV2Service } from "../../../services";
import { IActorCredits } from "../../../interfaces/ISearchTvResultV2";
import { IActorCredits, IActorCast } from "../../../interfaces/ISearchTvResultV2";
import { IDiscoverCardResult } from "../../interfaces";
import { RequestType } from "../../../interfaces";
import { AuthService } from "../../../auth/auth.service";
import { forkJoin } from "rxjs";
import { isEqual } from "lodash";
@Component({
templateUrl: "./discover-actor.component.html",
@ -12,7 +14,6 @@ import { AuthService } from "../../../auth/auth.service";
})
export class DiscoverActorComponent {
public actorId: number;
public actorCredits: IActorCredits;
public loadingFlag: boolean;
public isAdmin: boolean;
@ -24,24 +25,32 @@ export class DiscoverActorComponent {
this.route.params.subscribe((params: any) => {
this.actorId = params.actorId;
this.isAdmin = this.auth.isAdmin();
this.loading();
this.searchService.getMoviesByActor(this.actorId).subscribe(res => {
this.actorCredits = res;
this.createModel();
});
this.search();
});
}
private createModel() {
this.finishLoading();
private search() {
this.discoverResults = [];
this.actorCredits.cast.forEach(m => {
this.loading();
forkJoin([
this.searchService.getMoviesByActor(this.actorId),
this.searchService.getTvByActor(this.actorId)
]).subscribe(([movie, tv]) => {
this.pushDiscoverResults(movie.cast, RequestType.movie);
this.pushDiscoverResults(tv.cast, RequestType.tvShow);
this.finishLoading();
});
}
pushDiscoverResults(cast: IActorCast[], type: RequestType) {
cast.forEach(m => {
this.discoverResults.push({
available: false,
posterPath: m.poster_path ? `https://image.tmdb.org/t/p/w300/${m.poster_path}` : "../../../images/default_movie_poster.png",
requested: false,
title: m.title,
type: RequestType.movie,
type: type,
id: m.id,
url: null,
rating: 0,

@ -132,6 +132,10 @@ export class SearchV2Service extends ServiceHelpers {
return this.http.get<IActorCredits>(`${this.url}/actor/${actorId}/movie`, { headers: this.headers });
}
public getTvByActor(actorId: number): Observable<IActorCredits> {
return this.http.get<IActorCredits>(`${this.url}/actor/${actorId}/tv`, { headers: this.headers });
}
public getArtistInformation(artistId: string): Observable<IArtistSearchResult> {
return this.http.get<IArtistSearchResult>(`${this.url}/artist/${artistId}`);
}

@ -395,6 +395,19 @@ namespace Ombi.Controllers.V2
{
return await _movieEngineV2.GetMoviesByActor(actorId, null);
}
/// <summary>
/// Returns all the tv shows that is by the actor id
/// </summary>
/// <param name="actorId">TheMovieDb Actor ID</param>
/// <returns></returns>
[HttpGet("actor/{actorId}/tv")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesDefaultResponseType]
public async Task<ActorCredits> GetTvByActor(int actorId)
{
return await _tvEngineV2.GetTvByActor(actorId, null);
}
[HttpGet("artist/{artistId}")]

Loading…
Cancel
Save