mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Added the new banner background for tv shows
This commit is contained in:
parent
c84e0c5ee8
commit
5e48c66325
7 changed files with 63 additions and 18 deletions
|
@ -18,5 +18,6 @@ namespace Ombi.Helpers
|
|||
public const string NowPlayingMovies = nameof(NowPlayingMovies);
|
||||
public const string RadarrRootProfiles = nameof(RadarrRootProfiles);
|
||||
public const string RadarrQualityProfiles = nameof(RadarrQualityProfiles);
|
||||
public const string FanartTv = nameof(FanartTv);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
{
|
||||
|
||||
Logger.LogInformation("Getting all content from server {0}", servers.Name);
|
||||
var allContent = GetAllContent(servers);
|
||||
var allContent = await GetAllContent(servers);
|
||||
Logger.LogInformation("We found {0} items", allContent.Count);
|
||||
|
||||
// Let's now process this.
|
||||
|
@ -222,9 +222,9 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
/// </summary>
|
||||
/// <param name="plexSettings">The plex settings.</param>
|
||||
/// <returns></returns>
|
||||
private List<Mediacontainer> GetAllContent(PlexServers plexSettings)
|
||||
private async Task<List<Mediacontainer>> GetAllContent(PlexServers plexSettings)
|
||||
{
|
||||
var sections = PlexApi.GetLibrarySections(plexSettings.PlexAuthToken, plexSettings.FullUri).Result;
|
||||
var sections = await PlexApi.GetLibrarySections(plexSettings.PlexAuthToken, plexSettings.FullUri);
|
||||
|
||||
var libs = new List<Mediacontainer>();
|
||||
if (sections != null)
|
||||
|
@ -246,7 +246,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
}
|
||||
}
|
||||
}
|
||||
var lib = PlexApi.GetLibrary(plexSettings.PlexAuthToken, plexSettings.FullUri, dir.key).Result;
|
||||
var lib = await PlexApi.GetLibrary(plexSettings.PlexAuthToken, plexSettings.FullUri, dir.key);
|
||||
if (lib != null)
|
||||
{
|
||||
libs.Add(lib.MediaContainer);
|
||||
|
|
|
@ -40,13 +40,13 @@
|
|||
<ng-template let-col let-node="rowData" pTemplate="body">
|
||||
<!--This is the section that holds the parent level search results set-->
|
||||
<div *ngIf="!node.leaf">
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
<div class="row backdrop" [style.background-image]="node?.data?.background">
|
||||
<div class="col-sm-2 small-padding">
|
||||
|
||||
<img *ngIf="node?.data?.banner" class="img-responsive poster" width="150" [src]="node.data.banner" alt="poster">
|
||||
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<div class="col-sm-8 small-padding">
|
||||
<div>
|
||||
|
||||
<a href="http://www.imdb.com/title/{{node.data.imdbId}}/" target="_blank">
|
||||
|
@ -73,11 +73,11 @@
|
|||
<br />
|
||||
<br />
|
||||
</div>
|
||||
<p style="font-size: 0.9rem !important">{{node.data.overview}}</p>
|
||||
<p class="tv-overview">{{node.data.overview}}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-2">
|
||||
<div class="col-sm-2 small-padding">
|
||||
<div *ngIf="!node.data.fullyAvailable" class="dropdown">
|
||||
<button class="btn btn-primary-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||
<i class="fa fa-plus"></i> Request
|
||||
|
@ -112,7 +112,8 @@
|
|||
<seriesinformation [seriesId]="node.data.id"></seriesinformation>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
<br/>
|
||||
<br/>
|
||||
</ng-template>
|
||||
</p-column>
|
||||
</p-treeTable>
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import { Component, OnDestroy, OnInit } from "@angular/core";
|
||||
import { DomSanitizer } from "@angular/platform-browser";
|
||||
import { Router } from "@angular/router";
|
||||
import { Subject } from "rxjs/Subject";
|
||||
|
||||
import { AuthService } from "../auth/auth.service";
|
||||
import { NotificationService } from "../services";
|
||||
import { RequestService } from "../services";
|
||||
import { SearchService } from "../services";
|
||||
import { ImageService, NotificationService, RequestService, SearchService} from "../services";
|
||||
|
||||
import { TreeNode } from "primeng/primeng";
|
||||
import { IRequestEngineResult } from "../interfaces";
|
||||
|
@ -27,10 +26,11 @@ export class TvSearchComponent implements OnInit, OnDestroy {
|
|||
private subscriptions = new Subject<void>();
|
||||
|
||||
constructor(private searchService: SearchService, private requestService: RequestService,
|
||||
private notificationService: NotificationService, private route: Router, private authService: AuthService) {
|
||||
private notificationService: NotificationService, private route: Router, private authService: AuthService,
|
||||
private imageService: ImageService, private sanitizer: DomSanitizer) {
|
||||
|
||||
this.searchChanged
|
||||
.debounceTime(600) // Wait Xms afterthe last event before emitting last event
|
||||
.debounceTime(600) // Wait Xms after the last event before emitting last event
|
||||
.distinctUntilChanged() // only emit if value is different from previous value
|
||||
.takeUntil(this.subscriptions)
|
||||
.subscribe(x => {
|
||||
|
@ -130,6 +130,13 @@ export class TvSearchComponent implements OnInit, OnDestroy {
|
|||
|
||||
public getExtraInfo() {
|
||||
this.tvResults.forEach((val, index) => {
|
||||
|
||||
this.imageService.getTvBanner(val.data.id).subscribe(x => {
|
||||
|
||||
val.data.background = this.sanitizer.
|
||||
bypassSecurityTrustStyle
|
||||
("linear-gradient(to bottom, rgba(0,0,0,0.6) 0%,rgba(0,0,0,0.6) 100%),url(" + x + ")");
|
||||
});
|
||||
this.searchService.getShowInformationTreeNode(val.data.id)
|
||||
.takeUntil(this.subscriptions)
|
||||
.subscribe(x => {
|
||||
|
@ -203,6 +210,7 @@ export class TvSearchComponent implements OnInit, OnDestroy {
|
|||
this.tvResults[index].data.seasonRequests = updated.data.seasonRequests;
|
||||
this.tvResults[index].data.seriesId = updated.data.seriesId;
|
||||
this.tvResults[index].data.fullyAvailable = updated.data.fullyAvailable;
|
||||
this.tvResults[index].data.backdrop = updated.data.backdrop;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,4 +15,8 @@ export class ImageService extends ServiceHelpers {
|
|||
public getRandomBackground(): Observable<IImages> {
|
||||
return this.http.get(`${this.url}background/`, { headers: this.headers }).map(this.extractData);
|
||||
}
|
||||
|
||||
public getTvBanner(tvdbid: number): Observable<string> {
|
||||
return this.http.get(`${this.url}tv/${tvdbid}`, { headers: this.headers }).map(this.extractData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -842,4 +842,12 @@ a > h4:hover {
|
|||
.backdrop{
|
||||
box-shadow: 3px 3px 10px #000000;
|
||||
background-position: center;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.tv-overview{
|
||||
-webkit-text-fill-color: white;
|
||||
-webkit-text-stroke-width: 0.3px;
|
||||
-webkit-text-stroke-color: black;
|
||||
font-size: 0.9rem !important
|
||||
}
|
|
@ -5,8 +5,11 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Ombi.Config;
|
||||
using Ombi.Helpers;
|
||||
|
||||
namespace Ombi.Controllers
|
||||
{
|
||||
|
@ -14,16 +17,32 @@ namespace Ombi.Controllers
|
|||
[Produces("application/json")]
|
||||
public class ImagesController : Controller
|
||||
{
|
||||
public ImagesController(IFanartTvApi api, IApplicationConfigRepository config, IOptions<LandingPageBackground> options)
|
||||
public ImagesController(IFanartTvApi api, IApplicationConfigRepository config,
|
||||
IOptions<LandingPageBackground> options, IMemoryCache c)
|
||||
{
|
||||
Api = api;
|
||||
Config = config;
|
||||
Options = options.Value;
|
||||
_cache = c;
|
||||
}
|
||||
|
||||
private IFanartTvApi Api { get; }
|
||||
private IApplicationConfigRepository Config { get; }
|
||||
private LandingPageBackground Options { get; }
|
||||
private readonly IMemoryCache _cache;
|
||||
|
||||
[HttpGet("tv/{tvdbid}")]
|
||||
public async Task<string> GetTvBanner(int tvdbid)
|
||||
{
|
||||
var key = await _cache.GetOrCreateAsync(CacheKeys.FanartTv, async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromDays(1);
|
||||
return await Config.Get(Store.Entities.ConfigurationTypes.FanartTv);
|
||||
});
|
||||
|
||||
var images = await Api.GetTvImages(tvdbid, key.Value);
|
||||
return images.tvbanner.FirstOrDefault()?.url ?? string.Empty;
|
||||
}
|
||||
|
||||
[HttpGet("background")]
|
||||
public async Task<object> GetBackgroundImage()
|
||||
|
@ -35,10 +54,15 @@ namespace Ombi.Controllers
|
|||
var movieUrl = string.Empty;
|
||||
var tvUrl = string.Empty;
|
||||
|
||||
var key = await _cache.GetOrCreateAsync(CacheKeys.FanartTv, async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromDays(1);
|
||||
return await Config.Get(Store.Entities.ConfigurationTypes.FanartTv);
|
||||
});
|
||||
|
||||
if (moviesArray.Any())
|
||||
{
|
||||
var item = rand.Next(moviesArray.Length);
|
||||
var key = await Config.Get(Store.Entities.ConfigurationTypes.FanartTv);
|
||||
var result = await Api.GetMovieImages(moviesArray[item], key.Value);
|
||||
|
||||
while (!result.moviebackground.Any())
|
||||
|
@ -51,7 +75,6 @@ namespace Ombi.Controllers
|
|||
if(tvArray.Any())
|
||||
{
|
||||
var item = rand.Next(tvArray.Length);
|
||||
var key = await Config.Get(Store.Entities.ConfigurationTypes.FanartTv);
|
||||
var result = await Api.GetTvImages(tvArray[item], key.Value);
|
||||
|
||||
while (!result.showbackground.Any())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue