|
|
@ -1,6 +1,5 @@
|
|
|
|
import { PlatformLocation } from "@angular/common";
|
|
|
|
import { PlatformLocation } from "@angular/common";
|
|
|
|
import { Component, Input, OnInit } from "@angular/core";
|
|
|
|
import { Component, Input, OnInit } from "@angular/core";
|
|
|
|
import { DomSanitizer } from "@angular/platform-browser";
|
|
|
|
|
|
|
|
import { TranslateService } from "@ngx-translate/core";
|
|
|
|
import { TranslateService } from "@ngx-translate/core";
|
|
|
|
import { Subject } from "rxjs";
|
|
|
|
import { Subject } from "rxjs";
|
|
|
|
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
|
|
|
|
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
|
|
|
@ -33,7 +32,7 @@ export class MusicSearchComponent implements OnInit {
|
|
|
|
constructor(
|
|
|
|
constructor(
|
|
|
|
private searchService: SearchService, private requestService: RequestService,
|
|
|
|
private searchService: SearchService, private requestService: RequestService,
|
|
|
|
private notificationService: NotificationService, private authService: AuthService,
|
|
|
|
private notificationService: NotificationService, private authService: AuthService,
|
|
|
|
private readonly translate: TranslateService, private sanitizer: DomSanitizer,
|
|
|
|
private readonly translate: TranslateService,
|
|
|
|
private readonly platformLocation: PlatformLocation) {
|
|
|
|
private readonly platformLocation: PlatformLocation) {
|
|
|
|
|
|
|
|
|
|
|
|
this.searchChanged.pipe(
|
|
|
|
this.searchChanged.pipe(
|
|
|
@ -49,9 +48,6 @@ export class MusicSearchComponent implements OnInit {
|
|
|
|
.subscribe(x => {
|
|
|
|
.subscribe(x => {
|
|
|
|
this.movieResults = x;
|
|
|
|
this.movieResults = x;
|
|
|
|
this.searchApplied = true;
|
|
|
|
this.searchApplied = true;
|
|
|
|
// Now let's load some extra info including IMDB Id
|
|
|
|
|
|
|
|
// This way the search is fast at displaying results.
|
|
|
|
|
|
|
|
this.getExtraInfo();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.defaultPoster = "../../../images/default_movie_poster.png";
|
|
|
|
this.defaultPoster = "../../../images/default_movie_poster.png";
|
|
|
@ -120,7 +116,6 @@ export class MusicSearchComponent implements OnInit {
|
|
|
|
this.searchService.popularMovies()
|
|
|
|
this.searchService.popularMovies()
|
|
|
|
.subscribe(x => {
|
|
|
|
.subscribe(x => {
|
|
|
|
this.movieResults = x;
|
|
|
|
this.movieResults = x;
|
|
|
|
this.getExtraInfo();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public nowPlayingMovies() {
|
|
|
|
public nowPlayingMovies() {
|
|
|
@ -128,7 +123,6 @@ export class MusicSearchComponent implements OnInit {
|
|
|
|
this.searchService.nowPlayingMovies()
|
|
|
|
this.searchService.nowPlayingMovies()
|
|
|
|
.subscribe(x => {
|
|
|
|
.subscribe(x => {
|
|
|
|
this.movieResults = x;
|
|
|
|
this.movieResults = x;
|
|
|
|
this.getExtraInfo();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public topRatedMovies() {
|
|
|
|
public topRatedMovies() {
|
|
|
@ -136,7 +130,6 @@ export class MusicSearchComponent implements OnInit {
|
|
|
|
this.searchService.topRatedMovies()
|
|
|
|
this.searchService.topRatedMovies()
|
|
|
|
.subscribe(x => {
|
|
|
|
.subscribe(x => {
|
|
|
|
this.movieResults = x;
|
|
|
|
this.movieResults = x;
|
|
|
|
this.getExtraInfo();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public upcomingMovies() {
|
|
|
|
public upcomingMovies() {
|
|
|
@ -144,7 +137,6 @@ export class MusicSearchComponent implements OnInit {
|
|
|
|
this.searchService.upcomingMovies()
|
|
|
|
this.searchService.upcomingMovies()
|
|
|
|
.subscribe(x => {
|
|
|
|
.subscribe(x => {
|
|
|
|
this.movieResults = x;
|
|
|
|
this.movieResults = x;
|
|
|
|
this.getExtraInfo();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -181,23 +173,6 @@ export class MusicSearchComponent implements OnInit {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private getExtraInfo() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.movieResults.forEach((val, index) => {
|
|
|
|
|
|
|
|
if (val.posterPath === null) {
|
|
|
|
|
|
|
|
val.posterPath = this.defaultPoster;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
val.posterPath = "https://image.tmdb.org/t/p/w300/" + val.posterPath;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
val.background = this.sanitizer.bypassSecurityTrustStyle
|
|
|
|
|
|
|
|
("url(" + "https://image.tmdb.org/t/p/w1280" + val.backdropPath + ")");
|
|
|
|
|
|
|
|
this.searchService.getMovieInformation(val.id)
|
|
|
|
|
|
|
|
.subscribe(m => {
|
|
|
|
|
|
|
|
this.updateItem(val, m);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private updateItem(key: ISearchMovieResult, updated: ISearchMovieResult) {
|
|
|
|
private updateItem(key: ISearchMovieResult, updated: ISearchMovieResult) {
|
|
|
|
const index = this.movieResults.indexOf(key, 0);
|
|
|
|
const index = this.movieResults.indexOf(key, 0);
|
|
|
|
if (index > -1) {
|
|
|
|
if (index > -1) {
|
|
|
|