mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-31 03:50:08 -07:00
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
This commit is contained in:
parent
907353a54d
commit
6b716e7220
8 changed files with 57 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Ombi.Api.TheMovieDb.Models;
|
||||||
using Ombi.Core.Models.Search;
|
using Ombi.Core.Models.Search;
|
||||||
using Ombi.Core.Models.Search.V2;
|
using Ombi.Core.Models.Search.V2;
|
||||||
|
|
||||||
|
@ -10,6 +11,7 @@ namespace Ombi.Core
|
||||||
{
|
{
|
||||||
Task<SearchFullInfoTvShowViewModel> GetShowInformation(string tvdbid, CancellationToken token);
|
Task<SearchFullInfoTvShowViewModel> GetShowInformation(string tvdbid, CancellationToken token);
|
||||||
Task<SearchFullInfoTvShowViewModel> GetShowByRequest(int requestId, 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<StreamingData>> GetStreamInformation(int movieDbId, CancellationToken cancellationToken);
|
||||||
Task<IEnumerable<SearchTvShowViewModel>> Popular(int currentlyLoaded, int amountToLoad, string langCustomCode = null);
|
Task<IEnumerable<SearchTvShowViewModel>> Popular(int currentlyLoaded, int amountToLoad, string langCustomCode = null);
|
||||||
Task<IEnumerable<SearchTvShowViewModel>> Anticipated(int currentlyLoaded, int amountToLoad);
|
Task<IEnumerable<SearchTvShowViewModel>> Anticipated(int currentlyLoaded, int amountToLoad);
|
||||||
|
|
|
@ -147,6 +147,12 @@ namespace Ombi.Core.Engine.V2
|
||||||
return await processed;
|
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)
|
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<TvInfo> GetTVInfo(string themoviedbid, string langCode = "en");
|
||||||
Task<TheMovieDbContainer<ActorResult>> SearchByActor(string searchTerm, string langCode);
|
Task<TheMovieDbContainer<ActorResult>> SearchByActor(string searchTerm, string langCode);
|
||||||
Task<ActorCredits> GetActorMovieCredits(int actorId, 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<MultiSearch>> MultiSearch(string searchTerm, string languageCode, CancellationToken cancellationToken);
|
||||||
Task<TheMovieDbContainer<DiscoverMovies>> DiscoverMovies(string langCode, int keywordId);
|
Task<TheMovieDbContainer<DiscoverMovies>> DiscoverMovies(string langCode, int keywordId);
|
||||||
Task<FullMovieInfo> GetFullMovieInfo(int movieId, CancellationToken cancellationToken, string langCode);
|
Task<FullMovieInfo> GetFullMovieInfo(int movieId, CancellationToken cancellationToken, string langCode);
|
||||||
|
|
|
@ -139,6 +139,16 @@ namespace Ombi.Api.TheMovieDb
|
||||||
var result = await Api.Request<ActorCredits>(request);
|
var result = await Api.Request<ActorCredits>(request);
|
||||||
return result;
|
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)
|
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">
|
<div *ngIf="loadingFlag" class="row justify-content-md-center top-space loading-spinner">
|
||||||
<mat-spinner [color]="'accent'"></mat-spinner>
|
<mat-spinner [color]="'accent'"></mat-spinner>
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
import { ActivatedRoute } from "@angular/router";
|
import { ActivatedRoute } from "@angular/router";
|
||||||
import { SearchV2Service } from "../../../services";
|
import { SearchV2Service } from "../../../services";
|
||||||
import { IActorCredits } from "../../../interfaces/ISearchTvResultV2";
|
import { IActorCredits, IActorCast } from "../../../interfaces/ISearchTvResultV2";
|
||||||
import { IDiscoverCardResult } from "../../interfaces";
|
import { IDiscoverCardResult } from "../../interfaces";
|
||||||
import { RequestType } from "../../../interfaces";
|
import { RequestType } from "../../../interfaces";
|
||||||
import { AuthService } from "../../../auth/auth.service";
|
import { AuthService } from "../../../auth/auth.service";
|
||||||
|
import { forkJoin } from "rxjs";
|
||||||
|
import { isEqual } from "lodash";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: "./discover-actor.component.html",
|
templateUrl: "./discover-actor.component.html",
|
||||||
|
@ -12,7 +14,6 @@ import { AuthService } from "../../../auth/auth.service";
|
||||||
})
|
})
|
||||||
export class DiscoverActorComponent {
|
export class DiscoverActorComponent {
|
||||||
public actorId: number;
|
public actorId: number;
|
||||||
public actorCredits: IActorCredits;
|
|
||||||
public loadingFlag: boolean;
|
public loadingFlag: boolean;
|
||||||
public isAdmin: boolean;
|
public isAdmin: boolean;
|
||||||
|
|
||||||
|
@ -24,24 +25,32 @@ export class DiscoverActorComponent {
|
||||||
this.route.params.subscribe((params: any) => {
|
this.route.params.subscribe((params: any) => {
|
||||||
this.actorId = params.actorId;
|
this.actorId = params.actorId;
|
||||||
this.isAdmin = this.auth.isAdmin();
|
this.isAdmin = this.auth.isAdmin();
|
||||||
this.loading();
|
this.search();
|
||||||
this.searchService.getMoviesByActor(this.actorId).subscribe(res => {
|
|
||||||
this.actorCredits = res;
|
|
||||||
this.createModel();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private createModel() {
|
private search() {
|
||||||
this.finishLoading();
|
|
||||||
this.discoverResults = [];
|
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({
|
this.discoverResults.push({
|
||||||
available: false,
|
available: false,
|
||||||
posterPath: m.poster_path ? `https://image.tmdb.org/t/p/w300/${m.poster_path}` : "../../../images/default_movie_poster.png",
|
posterPath: m.poster_path ? `https://image.tmdb.org/t/p/w300/${m.poster_path}` : "../../../images/default_movie_poster.png",
|
||||||
requested: false,
|
requested: false,
|
||||||
title: m.title,
|
title: m.title,
|
||||||
type: RequestType.movie,
|
type: type,
|
||||||
id: m.id,
|
id: m.id,
|
||||||
url: null,
|
url: null,
|
||||||
rating: 0,
|
rating: 0,
|
||||||
|
|
|
@ -132,6 +132,10 @@ export class SearchV2Service extends ServiceHelpers {
|
||||||
return this.http.get<IActorCredits>(`${this.url}/actor/${actorId}/movie`, { headers: this.headers });
|
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> {
|
public getArtistInformation(artistId: string): Observable<IArtistSearchResult> {
|
||||||
return this.http.get<IArtistSearchResult>(`${this.url}/artist/${artistId}`);
|
return this.http.get<IArtistSearchResult>(`${this.url}/artist/${artistId}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -395,6 +395,19 @@ namespace Ombi.Controllers.V2
|
||||||
{
|
{
|
||||||
return await _movieEngineV2.GetMoviesByActor(actorId, null);
|
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}")]
|
[HttpGet("artist/{artistId}")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue