mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 05:43:19 -07:00
trying to do a fucking banner !wip
This commit is contained in:
parent
ce33a4212d
commit
2d6ed4056b
8 changed files with 133 additions and 22 deletions
|
@ -69,6 +69,7 @@ const routes: Routes = [
|
||||||
{ loadChildren: "./search/search.module#SearchModule", path: "search" },
|
{ loadChildren: "./search/search.module#SearchModule", path: "search" },
|
||||||
{ loadChildren: "./recentlyAdded/recentlyAdded.module#RecentlyAddedModule", path: "recentlyadded" },
|
{ loadChildren: "./recentlyAdded/recentlyAdded.module#RecentlyAddedModule", path: "recentlyadded" },
|
||||||
{ loadChildren: "./vote/vote.module#VoteModule", path: "vote" },
|
{ loadChildren: "./vote/vote.module#VoteModule", path: "vote" },
|
||||||
|
{ loadChildren: "./media-details/media-details.module#MediaDetailsModule", path: "details" },
|
||||||
];
|
];
|
||||||
|
|
||||||
// AoT requires an exported function for factories
|
// AoT requires an exported function for factories
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
import { NgModule } from "@angular/core";
|
||||||
|
import { RouterModule, Routes } from "@angular/router";
|
||||||
|
|
||||||
|
import { SearchService } from "../services";
|
||||||
|
|
||||||
|
import { SharedModule } from "../shared/shared.module";
|
||||||
|
import { MovieDetailsComponent } from "./movie-details.component";
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{ path: "movie/:movieDbId", component: MovieDetailsComponent },
|
||||||
|
];
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
RouterModule.forChild(routes),
|
||||||
|
SharedModule,
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
MovieDetailsComponent,
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
RouterModule,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
SearchService
|
||||||
|
],
|
||||||
|
|
||||||
|
})
|
||||||
|
export class MediaDetailsModule { }
|
|
@ -0,0 +1,12 @@
|
||||||
|
<div *ngIf="movie">
|
||||||
|
<div>
|
||||||
|
<img src="{{movie.background}}" class="banner" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div>
|
||||||
|
{{movie.title}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,7 @@
|
||||||
|
.banner {
|
||||||
|
position: absolute;
|
||||||
|
top: 0px;
|
||||||
|
left: 0px;
|
||||||
|
right: 0px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
import { Component } from "@angular/core";
|
||||||
|
import { SearchService, ImageService } from "../services";
|
||||||
|
import { ActivatedRoute } from "@angular/router";
|
||||||
|
import { ISearchMovieResult } from "../interfaces";
|
||||||
|
import { DomSanitizer } from "@angular/platform-browser";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
templateUrl: "./movie-details.component.html",
|
||||||
|
styleUrls: ["./movie-details.component.scss"],
|
||||||
|
})
|
||||||
|
export class MovieDetailsComponent {
|
||||||
|
public movie: ISearchMovieResult;
|
||||||
|
private theMovidDbId: number;
|
||||||
|
|
||||||
|
constructor(private searchService: SearchService, private route: ActivatedRoute,
|
||||||
|
private sanitizer: DomSanitizer, private imageService: ImageService) {
|
||||||
|
this.route.params.subscribe((params: any) => {
|
||||||
|
this.theMovidDbId = params.movieDbId;
|
||||||
|
this.load();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public load() {
|
||||||
|
this.searchService.getMovieInformation(this.theMovidDbId).subscribe(x => {
|
||||||
|
this.movie = x;
|
||||||
|
|
||||||
|
this.imageService.getMovieBanner(this.theMovidDbId.toString()).subscribe(x => this.movie.background = x);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
|
||||||
import { SearchV2Service } from '../services/searchV2.service';
|
import { SearchV2Service } from '../services/searchV2.service';
|
||||||
import { IMultiSearchResult } from '../interfaces';
|
import { IMultiSearchResult } from '../interfaces';
|
||||||
import { MatAutocompleteSelectedEvent } from '@angular/material';
|
import { MatAutocompleteSelectedEvent } from '@angular/material';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-nav-search',
|
selector: 'app-nav-search',
|
||||||
|
@ -17,7 +18,7 @@ export class NavSearchComponent {
|
||||||
public searchText: string;
|
public searchText: string;
|
||||||
public searchResult: IMultiSearchResult[];
|
public searchResult: IMultiSearchResult[];
|
||||||
|
|
||||||
constructor(private searchService: SearchV2Service) {
|
constructor(private searchService: SearchV2Service, private router: Router) {
|
||||||
this.searchChanged.pipe(
|
this.searchChanged.pipe(
|
||||||
debounceTime(600), // Wait Xms after the 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
|
distinctUntilChanged(), // only emit if value is different from previous value
|
||||||
|
@ -33,6 +34,9 @@ export class NavSearchComponent {
|
||||||
|
|
||||||
public selected(option: MatAutocompleteSelectedEvent) {
|
public selected(option: MatAutocompleteSelectedEvent) {
|
||||||
var selected = option.option.value as IMultiSearchResult;
|
var selected = option.option.value as IMultiSearchResult;
|
||||||
|
if (selected.media_type == "movie") {
|
||||||
|
this.router.navigate([`details/movie/${selected.id}`]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,9 @@ export class ImageService extends ServiceHelpers {
|
||||||
public getMovieBackground(movieDbId: string): Observable<string> {
|
public getMovieBackground(movieDbId: string): Observable<string> {
|
||||||
return this.http.get<string>(`${this.url}background/movie/${movieDbId}`, { headers: this.headers });
|
return this.http.get<string>(`${this.url}background/movie/${movieDbId}`, { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
public getMovieBanner(movieDbId: string): Observable<string> {
|
||||||
|
return this.http.get<string>(`${this.url}banner/movie/${movieDbId}`, { headers: this.headers });
|
||||||
|
}
|
||||||
|
|
||||||
public getTvBackground(tvdbid: number): Observable<string> {
|
public getTvBackground(tvdbid: number): Observable<string> {
|
||||||
return this.http.get<string>(`${this.url}background/tv/${tvdbid}`, { headers: this.headers });
|
return this.http.get<string>(`${this.url}background/tv/${tvdbid}`, { headers: this.headers });
|
||||||
|
|
|
@ -147,6 +147,31 @@ namespace Ombi.Controllers.V1
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("banner/movie/{movieDbId}")]
|
||||||
|
public async Task<string> GetMovieBanner(string movieDbId)
|
||||||
|
{
|
||||||
|
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.GetAsync(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
|
||||||
|
|
||||||
|
var images = await FanartTvApi.GetMovieImages(movieDbId, key.Value);
|
||||||
|
|
||||||
|
if (images == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (images.moviebanner?.Any() ?? false)
|
||||||
|
{
|
||||||
|
var enImage = images.moviebanner.Where(x => x.lang == "en").OrderByDescending(x => x.likes).Select(x => x.url).FirstOrDefault();
|
||||||
|
if (enImage == null)
|
||||||
|
{
|
||||||
|
return images.moviebanner.OrderByDescending(x => x.likes).Select(x => x.url).FirstOrDefault();
|
||||||
|
}
|
||||||
|
return enImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("background/tv/{tvdbid}")]
|
[HttpGet("background/tv/{tvdbid}")]
|
||||||
public async Task<string> GetTvBackground(int tvdbid)
|
public async Task<string> GetTvBackground(int tvdbid)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue