mirror of https://github.com/Ombi-app/Ombi
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.6 KiB
86 lines
2.6 KiB
import { Component, OnInit, Input } from "@angular/core";
|
|
import { IDiscoverCardResult } from "../../interfaces";
|
|
import { RequestType} from "../../../interfaces";
|
|
import { SearchV2Service } from "../../../services";
|
|
import { ISearchTvResultV2 } from "../../../interfaces/ISearchTvResultV2";
|
|
import { ISearchMovieResultV2 } from "../../../interfaces/ISearchMovieResultV2";
|
|
|
|
@Component({
|
|
selector: "movie-list",
|
|
templateUrl: "./movie-list.component.html",
|
|
styleUrls: ["./movie-list.component.scss"],
|
|
})
|
|
export class MovieListComponent implements OnInit {
|
|
|
|
public RequestType = RequestType;
|
|
@Input() public result: IDiscoverCardResult;
|
|
|
|
constructor(private searchService: SearchV2Service) { }
|
|
|
|
public ngOnInit() {
|
|
if (this.result.type == RequestType.tvShow) {
|
|
this.getExtraTvInfo();
|
|
}
|
|
if (this.result.type == RequestType.movie) {
|
|
this.getExtraMovieInfo();
|
|
}
|
|
}
|
|
|
|
|
|
public async getExtraTvInfo() {
|
|
var result = await this.searchService.getTvInfo(this.result.id);
|
|
this.setTvDefaults(result);
|
|
this.updateTvItem(result);
|
|
|
|
}
|
|
|
|
public getStatusClass(): string {
|
|
if (this.result.available) {
|
|
return "available";
|
|
}
|
|
if (this.result.approved) {
|
|
return "approved";
|
|
}
|
|
if (this.result.requested) {
|
|
return "requested";
|
|
}
|
|
return "notrequested";
|
|
}
|
|
|
|
private getExtraMovieInfo() {
|
|
if (!this.result.imdbid) {
|
|
this.searchService.getFullMovieDetails(this.result.id)
|
|
.subscribe(m => {
|
|
this.updateMovieItem(m);
|
|
});
|
|
}
|
|
}
|
|
|
|
private updateMovieItem(updated: ISearchMovieResultV2) {
|
|
this.result.url = "http://www.imdb.com/title/" + updated.imdbId + "/";
|
|
this.result.available = updated.available;
|
|
this.result.requested = updated.requested;
|
|
this.result.requested = updated.requestProcessing;
|
|
this.result.rating = updated.voteAverage;
|
|
}
|
|
|
|
|
|
private setTvDefaults(x: ISearchTvResultV2) {
|
|
if (!x.imdbId) {
|
|
x.imdbId = "https://www.tvmaze.com/shows/" + x.seriesId;
|
|
} else {
|
|
x.imdbId = "http://www.imdb.com/title/" + x.imdbId + "/";
|
|
}
|
|
}
|
|
|
|
private updateTvItem(updated: ISearchTvResultV2) {
|
|
this.result.title = updated.title;
|
|
this.result.id = updated.id;
|
|
this.result.available = updated.fullyAvailable;
|
|
this.result.posterPath = updated.banner;
|
|
this.result.requested = updated.requested;
|
|
this.result.url = updated.imdbId;
|
|
}
|
|
|
|
}
|