diff --git a/src/Ombi/ClientApp/app/issues/issueDetails.component.ts b/src/Ombi/ClientApp/app/issues/issueDetails.component.ts index 8dd0e742d..c4b84644e 100644 --- a/src/Ombi/ClientApp/app/issues/issueDetails.component.ts +++ b/src/Ombi/ClientApp/app/issues/issueDetails.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from "@angular/core"; import { ActivatedRoute } from "@angular/router"; import { AuthService } from "../auth/auth.service"; -import { ImageService, IssuesService, NotificationService, SearchService, SettingsService } from "../services"; +import { ImageService, IssuesService, NotificationService, SettingsService } from "../services"; import { DomSanitizer } from "@angular/platform-browser"; import { IIssues, IIssuesChat, IIssueSettings, INewIssueComments, IssueStatus } from "../interfaces"; @@ -34,7 +34,6 @@ export class IssueDetailsComponent implements OnInit { private settingsService: SettingsService, private notificationService: NotificationService, private imageService: ImageService, - private searchService: SearchService, private sanitizer: DomSanitizer) { this.route.params .subscribe((params: any) => { @@ -94,19 +93,21 @@ export class IssueDetailsComponent implements OnInit { private setBackground(issue: any) { if (issue.requestType === 1) { - this.searchService.getMovieInformation(Number(issue.providerId)).subscribe(x => { + this.imageService.getMovieBackground(Number(issue.providerId)).subscribe(x => { this.backgroundPath = this.sanitizer.bypassSecurityTrustStyle - ("url(" + "https://image.tmdb.org/t/p/w1280" + x.backdropPath + ")"); - this.posterPath = "https://image.tmdb.org/t/p/w300/" + x.posterPath; + ("url(" + x + ")"); + }); + this.imageService.getMoviePoster(Number(issue.providerId)).subscribe(x => { + this.posterPath = x.toString(); }); - + } else { - this.imageService.getTvBanner(Number(issue.providerId)).subscribe(x => { + this.imageService.getTvBackground(Number(issue.providerId)).subscribe(x => { this.backgroundPath = this.sanitizer.bypassSecurityTrustStyle ("url(" + x + ")"); }); - this.searchService.getShowInformationTreeNode(Number(issue.providerId)).subscribe(x => { - this.posterPath = x.data.banner; + this.imageService.getTvPoster(Number(issue.providerId)).subscribe(x => { + this.posterPath = x.toString(); }); } diff --git a/src/Ombi/ClientApp/app/services/image.service.ts b/src/Ombi/ClientApp/app/services/image.service.ts index 022f382ca..f9266e19f 100644 --- a/src/Ombi/ClientApp/app/services/image.service.ts +++ b/src/Ombi/ClientApp/app/services/image.service.ts @@ -20,4 +20,20 @@ export class ImageService extends ServiceHelpers { public getTvBanner(tvdbid: number): Observable { return this.http.get(`${this.url}tv/${tvdbid}`, {headers: this.headers}); } + + public getTvBackground(tvdbid: number): Observable { + return this.http.get(`${this.url}background/tv/${tvdbid}`, { headers: this.headers }); + } + + public getTvPoster(tvdbid: number): Observable { + return this.http.get(`${this.url}poster/tv/${tvdbid}`, { headers: this.headers }); + } + + public getMovieBackground(themoviedb: number): Observable { + return this.http.get(`${this.url}movies/${themoviedb}`, { headers: this.headers }); + } + + public getMoviePoster(themoviedb: number): Observable { + return this.http.get(`${this.url}poster/movies/${themoviedb}`, { headers: this.headers }); + } } diff --git a/src/Ombi/Controllers/ImagesController.cs b/src/Ombi/Controllers/ImagesController.cs index a6d18bad0..e963d3a36 100644 --- a/src/Ombi/Controllers/ImagesController.cs +++ b/src/Ombi/Controllers/ImagesController.cs @@ -41,6 +41,15 @@ namespace Ombi.Controllers { return images.tvbanner.FirstOrDefault()?.url ?? string.Empty; } + return string.Empty; + } + + [HttpGet("background/tv/{tvdbid}")] + public async Task GetTvBackground(int tvdbid) + { + var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1)); + + var images = await Api.GetTvImages(tvdbid, key.Value); if (images.showbackground != null) { return images.showbackground.FirstOrDefault()?.url ?? string.Empty; @@ -48,6 +57,45 @@ namespace Ombi.Controllers return string.Empty; } + [HttpGet("poster/tv/{tvdbid}")] + public async Task GetTvPoster(int tvdbid) + { + var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1)); + + var images = await Api.GetTvImages(tvdbid, key.Value); + if (images.tvposter != null) + { + return images.tvposter.FirstOrDefault()?.url ?? string.Empty; + } + return string.Empty; + } + + [HttpGet("movies/{themoviedb}")] + public async Task GetMovieBackground(int themoviedb) + { + var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1)); + + var images = await Api.GetMovieImages(themoviedb, key.Value); + if (images.moviebackground != null) + { + return images.moviebackground.FirstOrDefault()?.url ?? string.Empty; + } + return string.Empty; + } + + [HttpGet("poster/movies/{themoviedb}")] + public async Task GetMoviePoster(int themoviedb) + { + var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1)); + + var images = await Api.GetMovieImages(themoviedb, key.Value); + if (images.movieposter != null) + { + return images.movieposter.FirstOrDefault()?.url ?? string.Empty; + } + return string.Empty; + } + [HttpGet("background")] public async Task GetBackgroundImage() { diff --git a/src/Ombi/webpack.config.vendor.ts b/src/Ombi/webpack.config.vendor.ts index d4fe38c3a..b50e784f4 100644 --- a/src/Ombi/webpack.config.vendor.ts +++ b/src/Ombi/webpack.config.vendor.ts @@ -80,7 +80,7 @@ module.exports = (env: any) => { }, plugins: [ new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery", Hammer: "hammerjs/hammer" }), // Global identifiers - new webpack.ContextReplacementPlugin(/\@angular(\\|\/)core(\\|\/)esm5/, path.join(__dirname, './client')), // Workaround for https://github.com/angular/angular/issues/20357 + new webpack.ContextReplacementPlugin(/\@angular(\\|\/)core(\\|\/)esm5/, path.join(__dirname, "./client")), // Workaround for https://github.com/angular/angular/issues/20357 new webpack.ContextReplacementPlugin(/\@angular\b.*\b(bundles|linker)/, path.join(__dirname, "./ClientApp")), // Workaround for https://github.com/angular/angular/issues/11580 new webpack.ContextReplacementPlugin(/angular(\\|\/)core(\\|\/)@angular/, path.join(__dirname, "./ClientApp")), // Workaround for https://github.com/angular/angular/issues/14898 extractCSS,