broke the UI on twitch.

pull/3895/head
tidusjar 5 years ago
parent 09f365c039
commit 3c959284f5

@ -13,6 +13,7 @@ namespace Ombi.Core.Engine.Interfaces
Task<IEnumerable<SearchMovieViewModel>> TopRatedMovies();
Task<IEnumerable<SearchMovieViewModel>> UpcomingMovies();
Task<IEnumerable<SearchMovieViewModel>> NowPlayingMovies();
Task<MovieCollectionsViewModel> GetCollection(int collectionId, string langCode = null);
Task<int> GetTvDbId(int theMovieDbId);
int ResultLimit { get; set; }
}

@ -1,24 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Ombi.Api.TheMovieDb;
using Ombi.Api.TheMovieDb.Models;
using Ombi.Core.Authentication;
using Ombi.Core.Engine.Interfaces;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Search;
using Ombi.Core.Models.Search.V2;
using Ombi.Core.Rule.Interfaces;
using Ombi.Core.Settings;
using Ombi.Helpers;
using Ombi.Settings.Settings.Models;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Threading.Tasks;
using Ombi.Core.Engine.Interfaces;
using Ombi.Core.Models.Search.V2;
namespace Ombi.Core.Engine.V2
{
@ -46,6 +46,14 @@ namespace Ombi.Core.Engine.V2
return await ProcessSingleMovie(movieInfo);
}
public async Task<MovieCollectionsViewModel> GetCollection(int collectionId, string langCode = null)
{
langCode = await DefaultLanguageCode(langCode);
var collections = await MovieApi.GetCollection(langCode, collectionId);
return await ProcessCollection(collections);
}
public async Task<int> GetTvDbId(int theMovieDbId)
{
var result = await MovieApi.GetTvExternals(theMovieDbId);
@ -180,6 +188,30 @@ namespace Ombi.Core.Engine.V2
return mapped;
}
private async Task<MovieCollectionsViewModel> ProcessCollection(Collections collection)
{
var viewMovie = Mapper.Map<MovieCollectionsViewModel>(collection);
foreach (var movie in viewMovie.Collection)
{
var mappedMovie = Mapper.Map<SearchMovieViewModel>(movie);
await RunSearchRules(mappedMovie);
// This requires the rules to be run first to populate the RequestId property
await CheckForSubscription(mappedMovie);
var mapped = Mapper.Map<MovieCollection>(movie);
mapped.Available = movie.Available;
mapped.RequestId = movie.RequestId;
mapped.Requested = movie.Requested;
mapped.PlexUrl = movie.PlexUrl;
mapped.EmbyUrl = movie.EmbyUrl;
mapped.Subscribed = movie.Subscribed;
mapped.ShowSubscribe = movie.ShowSubscribe;
}
return viewMovie;
}
private async Task<SearchMovieViewModel> ProcessSingleMovie(SearchMovieViewModel viewMovie)
{
if (viewMovie.ImdbId.IsNullOrEmpty())
@ -188,7 +220,7 @@ namespace Ombi.Core.Engine.V2
viewMovie.Id = showInfo.Id; // TheMovieDbId
viewMovie.ImdbId = showInfo.ImdbId;
}
viewMovie.TheMovieDbId = viewMovie.Id.ToString();
await RunSearchRules(viewMovie);

@ -0,0 +1,23 @@
using System.Collections.Generic;
using Ombi.Store.Entities;
namespace Ombi.Core.Models.Search.V2
{
public class MovieCollectionsViewModel
{
public string Name { get; set; }
public string Overview { get; set; }
public List<MovieCollection> Collection { get; set; }
}
public class MovieCollection : SearchViewModel
{
public int Id { get; set; }
public string Overview { get; set; }
public string PosterPath { get; set; }
public string Title { get; set; }
public override RequestType Type => RequestType.Movie;
}
}

@ -91,6 +91,19 @@ namespace Ombi.Mapping.Profiles
CreateMap<BelongsToCollection, Ombi.Core.Models.Search.V2.CollectionsViewModel>().ReverseMap();
CreateMap<Api.TheMovieDb.Models.Keywords, Ombi.Core.Models.Search.V2.Keywords>().ReverseMap();
CreateMap<KeywordsValue, Ombi.Core.Models.Search.V2.KeywordsValue>().ReverseMap();
CreateMap<Collections, Ombi.Core.Models.Search.V2.MovieCollectionsViewModel>()
.ForMember(x => x.Name, o => o.MapFrom(s => s.name))
.ForMember(x => x.Overview, o => o.MapFrom(s => s.overview))
.ForMember(x => x.Collection, o => o.MapFrom(s => s.parts));
CreateMap<Part, MovieCollection>()
.ForMember(x => x.Id, o => o.MapFrom(s => s.id))
.ForMember(x => x.Overview, o => o.MapFrom(s => s.overview))
.ForMember(x => x.PosterPath, o => o.MapFrom(s => s.poster_path))
.ForMember(x => x.Title, o => o.MapFrom(s => s.title));
CreateMap<SearchMovieViewModel, MovieCollection>().ReverseMap();
}
}
}

@ -0,0 +1,26 @@
<div class="small-middle-container">
<div class="row justify-content-md-center top-spacing">
<div class="btn-group" role="group" aria-label="Basic example">
<button type="button" (click)="popular()" [attr.color]="popularActive ? 'accent' : 'primary'"
[ngClass]="popularActive ? 'mat-accent' : 'mat-primary'" mat-raised-button
class="btn grow" >{{'Discovery.PopularTab' | translate}}</button>
<button type="button" (click)="trending()"
[attr.color]="trendingActive ? 'accent' : 'primary'"
[ngClass]="trendingActive ? 'mat-accent' : 'mat-primary'"
mat-raised-button class="btn grow" color="primary">{{'Discovery.TrendingTab' | translate}}</button>
<button type="button" (click)="upcoming()"
[attr.color]="upcomingActive ? 'accent' : 'primary'"
[ngClass]="upcomingActive ? 'mat-accent' : 'mat-primary'"
mat-raised-button class="btn grow" color="primary">{{'Discovery.UpcomingTab' | translate}}</button>
</div>
</div>
<div *ngIf="loadingFlag" class="row justify-content-md-center top-spacing loading-spinner">
<mat-spinner [color]="'accent'"></mat-spinner>
</div>
<div *ngIf="discoverResults" class="row full-height">
<div class="col-xl-2 col-lg-3 col-md-3 col-6 col-sm-4 small-padding" *ngFor="let result of discoverResults">
<discover-card [result]="result"></discover-card>
</div>
</div>
</div>

@ -0,0 +1,19 @@
.full-height {
height: 100%;
}
.small-middle-container{
margin: auto;
width: 80%;
}
.small-padding {
padding-left: 20px;
padding-right: 20px;
margin-bottom: 28px;
}
.loading-spinner {
margin: 10%;
}

@ -0,0 +1,24 @@
import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { SearchV2Service } from "../../services";
import { IMovieCollectionsViewModel } from "../../interfaces/ISearchTvResultV2";
@Component({
templateUrl: "./discover-collections.component.html",
styleUrls: ["./discover-collections.component.scss"],
})
export class DiscoverCollectionsComponent implements OnInit {
public collectionId: number;
public collection: IMovieCollectionsViewModel;
constructor(private searchService: SearchV2Service, private route: ActivatedRoute) {
this.route.params.subscribe((params: any) => {
this.collectionId = params.collectionId;
});
}
public async ngOnInit() {
this.collection = await this.searchService.getMovieCollections(this.collectionId);
}
}

@ -10,9 +10,11 @@ import { AuthGuard } from "../auth/auth.guard";
import { PipeModule } from "../pipes/pipe.module";
import { DiscoverCardDetailsComponent } from "./card/discover-card-details.component";
import { MatDialog } from "@angular/material";
import { DiscoverCollectionsComponent } from "./collections/discover-collections.component";
const routes: Routes = [
{ path: "", component: DiscoverComponent, canActivate: [AuthGuard] },
{ path: "collection/:collectionId", component: DiscoverCollectionsComponent, canActivate: [AuthGuard] }
];
@NgModule({
imports: [
@ -24,6 +26,7 @@ const routes: Routes = [
DiscoverComponent,
DiscoverCardComponent,
DiscoverCardDetailsComponent,
DiscoverCollectionsComponent,
],
entryComponents: [
DiscoverCardDetailsComponent

@ -1,4 +1,4 @@
import { INewSeasonRequests } from "./IRequestModel";
import { INewSeasonRequests, RequestType } from "./IRequestModel";
export interface ISearchTvResultV2 {
id: number;
@ -44,6 +44,26 @@ export interface ISearchTvResultV2 {
requestId: number;
}
export interface IMovieCollectionsViewModel {
name: string;
overview: string;
collection: IMovieCollection[];
}
export interface IMovieCollection {
id: number;
overview: string;
posterPath: string;
title: string;
type: RequestType;
approved: boolean;
requested: boolean;
available: boolean;
plexUrl: string;
embyUrl: string;
imdbId: string;
}
export interface INetwork {
id: number;

@ -64,7 +64,7 @@
<div class="row">
<div class="col-12 col-md-2">
<button *ngIf="movie.belongsToCollection" mat-raised-button class="spacing-below full-width mat-elevation-z8">{{movie.belongsToCollection.name}}</button>
<button *ngIf="movie.belongsToCollection" [routerLink]="/discover/{{movie.belongsToCollection.id}" mat-raised-button class="spacing-below full-width mat-elevation-z8">{{movie.belongsToCollection.name}}</button>
<mat-card class="mat-elevation-z8">
<mat-card-content class="medium-font">

@ -1,4 +1,4 @@
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
import { APP_BASE_HREF } from "@angular/common";
import { Injectable, Inject } from "@angular/core";
import { HttpClient } from "@angular/common/http";
@ -8,8 +8,7 @@ import { IMultiSearchResult, ISearchMovieResult, ISearchTvResult } from "../inte
import { ServiceHelpers } from "./service.helpers";
import { ISearchMovieResultV2 } from "../interfaces/ISearchMovieResultV2";
import { promise } from "selenium-webdriver";
import { ISearchTvResultV2 } from "../interfaces/ISearchTvResultV2";
import { ISearchTvResultV2, IMovieCollectionsViewModel } from "../interfaces/ISearchTvResultV2";
@Injectable()
export class SearchV2Service extends ServiceHelpers {
@ -64,7 +63,12 @@ export class SearchV2Service extends ServiceHelpers {
public getTvInfo(tvdbid: number): Promise<ISearchTvResultV2> {
return this.http.get<ISearchTvResultV2>(`${this.url}/Tv/${tvdbid}`, { headers: this.headers }).toPromise();
}
public getTvInfoWithMovieDbId(theMovieDbId: number): Promise<ISearchTvResultV2> {
return this.http.get<ISearchTvResultV2>(`${this.url}/Tv/moviedb/${theMovieDbId}`, { headers: this.headers }).toPromise();
}
public getMovieCollections(collectionId: number): Promise<IMovieCollectionsViewModel> {
return this.http.get<IMovieCollectionsViewModel>(`${this.url}/movie/collection/${collectionId}`, { headers: this.headers }).toPromise();
}
}

@ -60,6 +60,16 @@ namespace Ombi.Controllers.V2
return await _movieEngineV2.GetFullMovieInformation(movieDbId);
}
/// <summary>
/// Returns basic information about the provided collection
/// </summary>
/// <param name="collectionId">The collection id from TheMovieDb</param>
/// <returns></returns>
[HttpGet("movie/collection/{collectionId}")]
public async Task<MovieCollectionsViewModel> GetMovieCollections(int collectionId)
{
return await _movieEngineV2.GetCollection(collectionId);
}
/// <summary>
/// Returns details for a single show

Loading…
Cancel
Save