mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 04:49:33 -07:00
wip
This commit is contained in:
parent
10c47d0233
commit
e39f35ca51
11 changed files with 82 additions and 345 deletions
|
@ -27,5 +27,6 @@ namespace Ombi.Core.Engine.Interfaces
|
||||||
|
|
||||||
Task<MovieFullInfoViewModel> GetMovieInfoByImdbId(string imdbId, CancellationToken requestAborted);
|
Task<MovieFullInfoViewModel> GetMovieInfoByImdbId(string imdbId, CancellationToken requestAborted);
|
||||||
Task<IEnumerable<StreamingData>> GetStreamInformation(int movieDbId, CancellationToken cancellationToken);
|
Task<IEnumerable<StreamingData>> GetStreamInformation(int movieDbId, CancellationToken cancellationToken);
|
||||||
|
Task<IEnumerable<SearchMovieViewModel>> RecentlyRequestedMovies(int currentlyLoaded, int toLoad, CancellationToken cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,11 +8,13 @@ using Ombi.Core.Engine.Interfaces;
|
||||||
using Ombi.Core.Models.Requests;
|
using Ombi.Core.Models.Requests;
|
||||||
using Ombi.Core.Models.Search;
|
using Ombi.Core.Models.Search;
|
||||||
using Ombi.Core.Models.Search.V2;
|
using Ombi.Core.Models.Search.V2;
|
||||||
|
using Ombi.Core.Models.UI;
|
||||||
using Ombi.Core.Rule.Interfaces;
|
using Ombi.Core.Rule.Interfaces;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
using Ombi.Settings.Settings.Models;
|
using Ombi.Settings.Settings.Models;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
|
using Ombi.Store.Entities.Requests;
|
||||||
using Ombi.Store.Repository;
|
using Ombi.Store.Repository;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -27,20 +29,21 @@ namespace Ombi.Core.Engine.V2
|
||||||
{
|
{
|
||||||
public MovieSearchEngineV2(IPrincipal identity, IRequestServiceMain service, IMovieDbApi movApi, IMapper mapper,
|
public MovieSearchEngineV2(IPrincipal identity, IRequestServiceMain service, IMovieDbApi movApi, IMapper mapper,
|
||||||
ILogger<MovieSearchEngineV2> logger, IRuleEvaluator r, OmbiUserManager um, ICacheService mem, ISettingsService<OmbiSettings> s, IRepository<RequestSubscription> sub,
|
ILogger<MovieSearchEngineV2> logger, IRuleEvaluator r, OmbiUserManager um, ICacheService mem, ISettingsService<OmbiSettings> s, IRepository<RequestSubscription> sub,
|
||||||
ISettingsService<CustomizationSettings> customizationSettings)
|
ISettingsService<CustomizationSettings> customizationSettings, IMovieRequestEngine movieRequestEngine)
|
||||||
: base(identity, service, r, um, mem, s, sub)
|
: base(identity, service, r, um, mem, s, sub)
|
||||||
{
|
{
|
||||||
MovieApi = movApi;
|
MovieApi = movApi;
|
||||||
Mapper = mapper;
|
Mapper = mapper;
|
||||||
Logger = logger;
|
Logger = logger;
|
||||||
_customizationSettings = customizationSettings;
|
_customizationSettings = customizationSettings;
|
||||||
|
_movieRequestEngine = movieRequestEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IMovieDbApi MovieApi { get; }
|
private IMovieDbApi MovieApi { get; }
|
||||||
private IMapper Mapper { get; }
|
private IMapper Mapper { get; }
|
||||||
private ILogger Logger { get; }
|
private ILogger Logger { get; }
|
||||||
private readonly ISettingsService<CustomizationSettings> _customizationSettings;
|
private readonly ISettingsService<CustomizationSettings> _customizationSettings;
|
||||||
|
private readonly IMovieRequestEngine _movieRequestEngine;
|
||||||
|
|
||||||
public async Task<MovieFullInfoViewModel> GetFullMovieInformation(int theMovieDbId, CancellationToken cancellationToken, string langCode = null)
|
public async Task<MovieFullInfoViewModel> GetFullMovieInformation(int theMovieDbId, CancellationToken cancellationToken, string langCode = null)
|
||||||
{
|
{
|
||||||
|
@ -187,6 +190,41 @@ namespace Ombi.Core.Engine.V2
|
||||||
return await TransformMovieResultsToResponse(results);
|
return await TransformMovieResultsToResponse(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets recently requested movies
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IEnumerable<SearchMovieViewModel>> RecentlyRequestedMovies(int currentlyLoaded, int toLoad, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var langCode = await DefaultLanguageCode(null);
|
||||||
|
|
||||||
|
var results = new List<MovieResponseDto>();
|
||||||
|
|
||||||
|
var requestResult = await Cache.GetOrAdd(nameof(RecentlyRequestedMovies) + "Requests" + toLoad + langCode,
|
||||||
|
async () =>
|
||||||
|
{
|
||||||
|
return await _movieRequestEngine.GetRequests(toLoad, currentlyLoaded, new Models.UI.OrderFilterModel
|
||||||
|
{
|
||||||
|
OrderType = OrderType.RequestedDateDesc
|
||||||
|
});
|
||||||
|
}, DateTime.Now.AddMinutes(15), cancellationToken);
|
||||||
|
|
||||||
|
var movieDBResults = await Cache.GetOrAdd(nameof(RecentlyRequestedMovies) + toLoad + langCode,
|
||||||
|
async () =>
|
||||||
|
{
|
||||||
|
var responses = new List<MovieResponseDto>();
|
||||||
|
foreach(var movie in requestResult.Collection)
|
||||||
|
{
|
||||||
|
responses.Add(await MovieApi.GetMovieInformation(movie.TheMovieDbId));
|
||||||
|
}
|
||||||
|
return responses;
|
||||||
|
}, DateTime.Now.AddHours(12), cancellationToken);
|
||||||
|
|
||||||
|
results.AddRange(movieDBResults);
|
||||||
|
|
||||||
|
return await TransformMovieResultsToResponse(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets upcoming movies.
|
/// Gets upcoming movies.
|
||||||
|
@ -269,8 +307,8 @@ namespace Ombi.Core.Engine.V2
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task<List<SearchMovieViewModel>> TransformMovieResultsToResponse(
|
protected async Task<List<SearchMovieViewModel>> TransformMovieResultsToResponse<T>(
|
||||||
IEnumerable<MovieDbSearchResult> movies)
|
IEnumerable<T> movies) where T: new()
|
||||||
{
|
{
|
||||||
var settings = await _customizationSettings.GetSettingsAsync();
|
var settings = await _customizationSettings.GetSettingsAsync();
|
||||||
var viewMovies = new List<SearchMovieViewModel>();
|
var viewMovies = new List<SearchMovieViewModel>();
|
||||||
|
@ -286,7 +324,7 @@ namespace Ombi.Core.Engine.V2
|
||||||
return viewMovies;
|
return viewMovies;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<SearchMovieViewModel> ProcessSingleMovie(MovieDbSearchResult movie)
|
private async Task<SearchMovieViewModel> ProcessSingleMovie<T>(T movie) where T : new()
|
||||||
{
|
{
|
||||||
var viewMovie = Mapper.Map<SearchMovieViewModel>(movie);
|
var viewMovie = Mapper.Map<SearchMovieViewModel>(movie);
|
||||||
return await ProcessSingleMovie(viewMovie);
|
return await ProcessSingleMovie(viewMovie);
|
||||||
|
|
|
@ -4,6 +4,7 @@ using AutoMapper;
|
||||||
using Ombi.Api.TheMovieDb.Models;
|
using Ombi.Api.TheMovieDb.Models;
|
||||||
using Ombi.Core.Models.Search;
|
using Ombi.Core.Models.Search;
|
||||||
using Ombi.Core.Models.Search.V2;
|
using Ombi.Core.Models.Search.V2;
|
||||||
|
using Ombi.Store.Entities.Requests;
|
||||||
using Ombi.TheMovieDbApi.Models;
|
using Ombi.TheMovieDbApi.Models;
|
||||||
using Keywords = Ombi.Core.Models.Search.V2.Keywords;
|
using Keywords = Ombi.Core.Models.Search.V2.Keywords;
|
||||||
using KeywordsValue = Ombi.Api.TheMovieDb.Models.KeywordsValue;
|
using KeywordsValue = Ombi.Api.TheMovieDb.Models.KeywordsValue;
|
||||||
|
@ -76,6 +77,7 @@ namespace Ombi.Mapping.Profiles
|
||||||
CreateMap<TheMovieDbApi.Models.Genre, GenreDto>();
|
CreateMap<TheMovieDbApi.Models.Genre, GenreDto>();
|
||||||
|
|
||||||
CreateMap<MovieDbSearchResult, SearchMovieViewModel>().ReverseMap();
|
CreateMap<MovieDbSearchResult, SearchMovieViewModel>().ReverseMap();
|
||||||
|
|
||||||
CreateMap<MovieResponseDto, SearchMovieViewModel>().ReverseMap();
|
CreateMap<MovieResponseDto, SearchMovieViewModel>().ReverseMap();
|
||||||
|
|
||||||
CreateMap<FullMovieInfo, SearchMovieViewModel>().ReverseMap();
|
CreateMap<FullMovieInfo, SearchMovieViewModel>().ReverseMap();
|
||||||
|
|
|
@ -10,6 +10,7 @@ export enum DiscoverType {
|
||||||
Upcoming,
|
Upcoming,
|
||||||
Trending,
|
Trending,
|
||||||
Popular,
|
Popular,
|
||||||
|
RecentlyRequested,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -216,6 +217,8 @@ export class CarouselListComponent implements OnInit {
|
||||||
case DiscoverType.Upcoming:
|
case DiscoverType.Upcoming:
|
||||||
this.movies = await this.searchService.upcomingMoviesByPage(this.currentlyLoaded, this.amountToLoad);
|
this.movies = await this.searchService.upcomingMoviesByPage(this.currentlyLoaded, this.amountToLoad);
|
||||||
break
|
break
|
||||||
|
case DiscoverType.RecentlyRequested:
|
||||||
|
this.movies = await this.searchService.recentlyRequestedMoviesByPage(this.currentlyLoaded, this.amountToLoad);
|
||||||
}
|
}
|
||||||
this.currentlyLoaded += this.amountToLoad;
|
this.currentlyLoaded += this.amountToLoad;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
<div class="small-middle-container">
|
<div class="small-middle-container">
|
||||||
<div *ngIf="loadingFlag" class="row justify-content-md-center top-spacing loading-spinner">
|
|
||||||
</div>
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h2>Popular</h2>
|
<h2>{{'Discovery.PopularTab' | translate}}</h2>
|
||||||
<div>
|
<div>
|
||||||
<carousel-list [id]="'popular'" [discoverType]="DiscoverType.Popular"></carousel-list>
|
<carousel-list [id]="'popular'" [discoverType]="DiscoverType.Popular"></carousel-list>
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,7 +8,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h2>Trending</h2>
|
<h2>{{'Discovery.TrendingTab' | translate}}</h2>
|
||||||
<div >
|
<div >
|
||||||
<carousel-list [id]="'trending'" [discoverType]="DiscoverType.Trending"></carousel-list>
|
<carousel-list [id]="'trending'" [discoverType]="DiscoverType.Trending"></carousel-list>
|
||||||
</div>
|
</div>
|
||||||
|
@ -18,10 +16,15 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h2>Upcoming</h2>
|
<h2>{{'Discovery.UpcomingTab' | translate}}</h2>
|
||||||
<div>
|
<div>
|
||||||
<carousel-list [id]="'upcoming'" [discoverType]="DiscoverType.Upcoming"></carousel-list>
|
<carousel-list [id]="'upcoming'" [discoverType]="DiscoverType.Upcoming"></carousel-list>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<!-- <div class="section">
|
||||||
|
<h2>{{'Discovery.RecentlyRequestedTab' | translate}}</h2>
|
||||||
|
<div>
|
||||||
|
<carousel-list [id]="'recentlyRequested'" [discoverType]="DiscoverType.RecentlyRequested"></carousel-list>
|
||||||
|
</div>
|
||||||
|
</div> -->
|
||||||
</div>
|
</div>
|
|
@ -1,344 +1,15 @@
|
||||||
import { Component, OnInit, Inject } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
import { SearchV2Service } from "../../../services";
|
|
||||||
import { ISearchMovieResult, ISearchTvResult, RequestType } from "../../../interfaces";
|
|
||||||
import { IDiscoverCardResult, DiscoverOption, DisplayOption } from "../../interfaces";
|
|
||||||
import { trigger, transition, style, animate } from "@angular/animations";
|
|
||||||
import { StorageService } from "../../../shared/storage/storage-service";
|
|
||||||
import { DOCUMENT } from "@angular/common";
|
|
||||||
import { ISearchTvResultV2 } from "../../../interfaces/ISearchTvResultV2";
|
|
||||||
import { DiscoverType } from "../carousel-list/carousel-list.component";
|
import { DiscoverType } from "../carousel-list/carousel-list.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: "./discover.component.html",
|
templateUrl: "./discover.component.html",
|
||||||
styleUrls: ["./discover.component.scss"],
|
styleUrls: ["./discover.component.scss"],
|
||||||
animations: [
|
|
||||||
trigger('slideIn', [
|
|
||||||
transition(':enter', [
|
|
||||||
style({ transform: 'translateX(100%)' }),
|
|
||||||
animate('200ms ease-in', style({ transform: 'translateY(0%)' }))
|
|
||||||
])
|
|
||||||
])
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
export class DiscoverComponent implements OnInit {
|
export class DiscoverComponent {
|
||||||
|
|
||||||
public upcomingMovies: IDiscoverCardResult[] = [];
|
|
||||||
public trendingMovies: IDiscoverCardResult[] = [];
|
|
||||||
|
|
||||||
|
|
||||||
public discoverResults: IDiscoverCardResult[] = [];
|
|
||||||
public movies: ISearchMovieResult[] = [];
|
|
||||||
public tvShows: ISearchTvResult[] = [];
|
|
||||||
|
|
||||||
public discoverOptions: DiscoverOption = DiscoverOption.Combined;
|
|
||||||
public DiscoverType = DiscoverType;
|
public DiscoverType = DiscoverType;
|
||||||
public DiscoverOption = DiscoverOption;
|
|
||||||
public displayOption: DisplayOption = DisplayOption.Card;
|
|
||||||
public DisplayOption = DisplayOption;
|
|
||||||
|
|
||||||
public defaultTvPoster: string;
|
constructor() { }
|
||||||
|
|
||||||
public popularActive: boolean = true;
|
|
||||||
public trendingActive: boolean;
|
|
||||||
public upcomingActive: boolean;
|
|
||||||
|
|
||||||
public loadingFlag: boolean;
|
|
||||||
public scrollDisabled: boolean;
|
|
||||||
|
|
||||||
private amountToLoad = 14;
|
|
||||||
|
|
||||||
private contentLoaded: number;
|
|
||||||
private isScrolling: boolean = false;
|
|
||||||
private mediaTypeStorageKey = "DiscoverOptions";
|
|
||||||
private displayOptionsKey = "DiscoverDisplayOptions";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
constructor(private searchService: SearchV2Service,
|
|
||||||
private storageService: StorageService,
|
|
||||||
@Inject(DOCUMENT) private container: Document) { }
|
|
||||||
|
|
||||||
|
|
||||||
public async ngOnInit() {
|
|
||||||
this.loading()
|
|
||||||
// this.upcomingMovies = this.mapTvModel(await this.searchService.popularTvByPage(0, 14));
|
|
||||||
// this.trendingMovies = this.mapMovieModel(await this.searchService.popularMoviesByPage(0, 14));
|
|
||||||
this.finishLoading();
|
|
||||||
// const localDiscoverOptions = +this.storageService.get(this.mediaTypeStorageKey);
|
|
||||||
// if (localDiscoverOptions) {
|
|
||||||
// this.discoverOptions = DiscoverOption[DiscoverOption[localDiscoverOptions]];
|
|
||||||
// }
|
|
||||||
// const localDisplayOptions = +this.storageService.get(this.displayOptionsKey);
|
|
||||||
// if (localDisplayOptions) {
|
|
||||||
// this.displayOption = DisplayOption[DisplayOption[localDisplayOptions]];
|
|
||||||
// }
|
|
||||||
// this.scrollDisabled = true;
|
|
||||||
// switch (this.discoverOptions) {
|
|
||||||
// case DiscoverOption.Combined:
|
|
||||||
// this.movies = await this.searchService.popularMoviesByPage(0, this.amountToLoad);
|
|
||||||
// this.tvShows = await this.searchService.popularTvByPage(0, this.amountToLoad);
|
|
||||||
// break;
|
|
||||||
// case DiscoverOption.Movie:
|
|
||||||
// this.movies = await this.searchService.popularMoviesByPage(0, this.amountToLoad);
|
|
||||||
// break;
|
|
||||||
// case DiscoverOption.Tv:
|
|
||||||
// this.tvShows = await this.searchService.popularTvByPage(0, this.amountToLoad);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// this.contentLoaded = this.amountToLoad;
|
|
||||||
|
|
||||||
// this.createInitialModel();
|
|
||||||
// this.scrollDisabled = false;
|
|
||||||
// if (!this.containerHasScrollBar()) {
|
|
||||||
// await this.onScroll();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
public async onScroll() {
|
|
||||||
console.log("scrolled");
|
|
||||||
if (!this.contentLoaded) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!this.isScrolling) {
|
|
||||||
this.isScrolling = true;
|
|
||||||
this.loading();
|
|
||||||
if (this.popularActive) {
|
|
||||||
switch (this.discoverOptions) {
|
|
||||||
case DiscoverOption.Combined:
|
|
||||||
this.movies = await this.searchService.popularMoviesByPage(this.contentLoaded, this.amountToLoad);
|
|
||||||
this.tvShows = await this.searchService.popularTvByPage(this.contentLoaded, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
case DiscoverOption.Movie:
|
|
||||||
this.movies = await this.searchService.popularMoviesByPage(this.contentLoaded, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
case DiscoverOption.Tv:
|
|
||||||
this.tvShows = await this.searchService.popularTvByPage(this.contentLoaded, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.trendingActive) {
|
|
||||||
switch (this.discoverOptions) {
|
|
||||||
case DiscoverOption.Combined:
|
|
||||||
this.movies = await this.searchService.nowPlayingMoviesByPage(this.contentLoaded, this.amountToLoad);
|
|
||||||
this.tvShows = await this.searchService.trendingTvByPage(this.contentLoaded, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
case DiscoverOption.Movie:
|
|
||||||
this.movies = await this.searchService.nowPlayingMoviesByPage(this.contentLoaded, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
case DiscoverOption.Tv:
|
|
||||||
this.tvShows = await this.searchService.trendingTvByPage(this.contentLoaded, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.upcomingActive) {
|
|
||||||
switch (this.discoverOptions) {
|
|
||||||
case DiscoverOption.Combined:
|
|
||||||
this.movies = await this.searchService.upcomingMoviesByPage(this.contentLoaded, this.amountToLoad);
|
|
||||||
this.tvShows = await this.searchService.anticipatedTvByPage(this.contentLoaded, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
case DiscoverOption.Movie:
|
|
||||||
this.movies = await this.searchService.upcomingMoviesByPage(this.contentLoaded, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
case DiscoverOption.Tv:
|
|
||||||
this.tvShows = await this.searchService.anticipatedTvByPage(this.contentLoaded, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.contentLoaded += 12;
|
|
||||||
|
|
||||||
this.createModel();
|
|
||||||
this.isScrolling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async popular() {
|
|
||||||
this.clear();
|
|
||||||
this.scrollDisabled = true;
|
|
||||||
this.isScrolling = false;
|
|
||||||
this.contentLoaded = 12;
|
|
||||||
this.loading()
|
|
||||||
this.popularActive = true;
|
|
||||||
this.trendingActive = false;
|
|
||||||
this.upcomingActive = false;
|
|
||||||
switch (this.discoverOptions) {
|
|
||||||
case DiscoverOption.Combined:
|
|
||||||
this.movies = await this.searchService.popularMoviesByPage(0, this.amountToLoad);
|
|
||||||
this.tvShows = await this.searchService.popularTvByPage(0, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
case DiscoverOption.Movie:
|
|
||||||
this.movies = await this.searchService.popularMoviesByPage(0, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
case DiscoverOption.Tv:
|
|
||||||
this.tvShows = await this.searchService.popularTvByPage(0, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.createModel();
|
|
||||||
this.scrollDisabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async trending() {
|
|
||||||
this.clear();
|
|
||||||
|
|
||||||
this.scrollDisabled = true;
|
|
||||||
this.isScrolling = false;
|
|
||||||
this.contentLoaded = 12;
|
|
||||||
this.loading()
|
|
||||||
this.popularActive = false;
|
|
||||||
this.trendingActive = true;
|
|
||||||
this.upcomingActive = false;
|
|
||||||
switch (this.discoverOptions) {
|
|
||||||
case DiscoverOption.Combined:
|
|
||||||
this.movies = await this.searchService.nowPlayingMoviesByPage(0, this.amountToLoad);
|
|
||||||
this.tvShows = await this.searchService.trendingTvByPage(0, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
case DiscoverOption.Movie:
|
|
||||||
this.movies = await this.searchService.nowPlayingMoviesByPage(0, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
case DiscoverOption.Tv:
|
|
||||||
this.tvShows = await this.searchService.trendingTvByPage(0, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.createModel();
|
|
||||||
this.scrollDisabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async upcoming() {
|
|
||||||
this.clear();
|
|
||||||
this.scrollDisabled = true;
|
|
||||||
this.isScrolling = false;
|
|
||||||
this.contentLoaded = 12;
|
|
||||||
this.loading()
|
|
||||||
this.popularActive = false;
|
|
||||||
this.trendingActive = false;
|
|
||||||
this.upcomingActive = true;
|
|
||||||
switch (this.discoverOptions) {
|
|
||||||
case DiscoverOption.Combined:
|
|
||||||
this.movies = await this.searchService.upcomingMoviesByPage(0, this.amountToLoad);
|
|
||||||
this.tvShows = await this.searchService.anticipatedTvByPage(0, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
case DiscoverOption.Movie:
|
|
||||||
this.movies = await this.searchService.upcomingMoviesByPage(0, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
case DiscoverOption.Tv:
|
|
||||||
this.tvShows = await this.searchService.anticipatedTvByPage(0, this.amountToLoad);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.createModel();
|
|
||||||
this.scrollDisabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async switchDiscoverMode(newMode: DiscoverOption) {
|
|
||||||
this.loading();
|
|
||||||
this.clear();
|
|
||||||
this.discoverOptions = newMode;
|
|
||||||
this.storageService.save(this.mediaTypeStorageKey, newMode.toString());
|
|
||||||
await this.ngOnInit();
|
|
||||||
this.finishLoading();
|
|
||||||
}
|
|
||||||
|
|
||||||
public changeView(view: DisplayOption) {
|
|
||||||
this.displayOption = view;
|
|
||||||
this.storageService.save(this.displayOptionsKey, view.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private createModel() {
|
|
||||||
const tempResults = <IDiscoverCardResult[]>[];
|
|
||||||
|
|
||||||
// switch (this.discoverOptions) {
|
|
||||||
// case DiscoverOption.Combined:
|
|
||||||
// tempResults.push(...this.mapMovieModel());
|
|
||||||
// tempResults.push(...this.mapTvModel());
|
|
||||||
// break;
|
|
||||||
// case DiscoverOption.Movie:
|
|
||||||
// tempResults.push(...this.mapMovieModel());
|
|
||||||
// break;
|
|
||||||
// case DiscoverOption.Tv:
|
|
||||||
// tempResults.push(...this.mapTvModel());
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
this.shuffle(tempResults);
|
|
||||||
this.discoverResults.push(...tempResults);
|
|
||||||
|
|
||||||
this.finishLoading();
|
|
||||||
}
|
|
||||||
|
|
||||||
private mapMovieModel(movies: ISearchMovieResult[]): IDiscoverCardResult[] {
|
|
||||||
const tempResults = <IDiscoverCardResult[]>[];
|
|
||||||
movies.forEach(m => {
|
|
||||||
tempResults.push({
|
|
||||||
available: m.available,
|
|
||||||
posterPath: m.posterPath ? `https://image.tmdb.org/t/p/w500/${m.posterPath}` : "../../../images/default_movie_poster.png",
|
|
||||||
requested: m.requested,
|
|
||||||
title: m.title,
|
|
||||||
type: RequestType.movie,
|
|
||||||
id: m.id,
|
|
||||||
url: `http://www.imdb.com/title/${m.imdbId}/`,
|
|
||||||
rating: m.voteAverage,
|
|
||||||
overview: m.overview,
|
|
||||||
approved: m.approved,
|
|
||||||
imdbid: m.imdbId,
|
|
||||||
denied: false,
|
|
||||||
background: m.backdropPath
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return tempResults;
|
|
||||||
}
|
|
||||||
|
|
||||||
private mapTvModel(tv: ISearchTvResult[]): IDiscoverCardResult[] {
|
|
||||||
const tempResults = <IDiscoverCardResult[]>[];
|
|
||||||
tv.forEach(m => {
|
|
||||||
tempResults.push({
|
|
||||||
available: m.available,
|
|
||||||
posterPath: "../../../images/default_tv_poster.png",
|
|
||||||
requested: m.requested,
|
|
||||||
title: m.title,
|
|
||||||
type: RequestType.tvShow,
|
|
||||||
id: m.id,
|
|
||||||
url: undefined,
|
|
||||||
rating: +m.rating,
|
|
||||||
overview: m.overview,
|
|
||||||
approved: m.approved || m.partlyAvailable,
|
|
||||||
imdbid: m.imdbId,
|
|
||||||
denied: false,
|
|
||||||
background: m.background
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return tempResults;
|
|
||||||
}
|
|
||||||
|
|
||||||
private createInitialModel() {
|
|
||||||
this.clear();
|
|
||||||
this.createModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
private shuffle(discover: IDiscoverCardResult[]): IDiscoverCardResult[] {
|
|
||||||
for (let i = discover.length - 1; i > 0; i--) {
|
|
||||||
const j = Math.floor(Math.random() * (i + 1));
|
|
||||||
[discover[i], discover[j]] = [discover[j], discover[i]];
|
|
||||||
}
|
|
||||||
return discover;
|
|
||||||
}
|
|
||||||
|
|
||||||
private loading() {
|
|
||||||
this.loadingFlag = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private clear() {
|
|
||||||
this.discoverResults = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
private finishLoading() {
|
|
||||||
this.loadingFlag = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private containerHasScrollBar(): boolean {
|
|
||||||
return this.container.documentElement.scrollHeight > this.container.documentElement.clientHeight;
|
|
||||||
// div.scrollHeight > div.clientHeight;
|
|
||||||
// this.container.documentElement.scrollHeight > (window.innerHeight + window.pageYOffset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,10 @@ export class SearchV2Service extends ServiceHelpers {
|
||||||
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/upcoming/${currentlyLoaded}/${toLoad}`).toPromise();
|
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/upcoming/${currentlyLoaded}/${toLoad}`).toPromise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public recentlyRequestedMoviesByPage(currentlyLoaded: number, toLoad: number): Promise<ISearchMovieResult[]> {
|
||||||
|
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/requested/${currentlyLoaded}/${toLoad}`).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
public nowPlayingMovies(): Observable<ISearchMovieResult[]> {
|
public nowPlayingMovies(): Observable<ISearchMovieResult[]> {
|
||||||
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/nowplaying`);
|
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/nowplaying`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,6 +286,7 @@ namespace Ombi.Controllers.V1
|
||||||
/// <param name="tv">The tv.</param>
|
/// <param name="tv">The tv.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("tv")]
|
[HttpPost("tv")]
|
||||||
|
[Obsolete("This method is obsolete, please use v2 API")]
|
||||||
public async Task<RequestEngineResult> RequestTv([FromBody] TvRequestViewModel tv)
|
public async Task<RequestEngineResult> RequestTv([FromBody] TvRequestViewModel tv)
|
||||||
{
|
{
|
||||||
tv.RequestedByAlias = GetApiAlias();
|
tv.RequestedByAlias = GetApiAlias();
|
||||||
|
|
|
@ -167,6 +167,19 @@ namespace Ombi.Controllers.V2
|
||||||
return await _movieEngineV2.PopularMovies(currentPosition, amountToLoad, Request.HttpContext.RequestAborted);
|
return await _movieEngineV2.PopularMovies(currentPosition, amountToLoad, Request.HttpContext.RequestAborted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns Recently Requested Movies using Paging
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>We use TheMovieDb as the Movie Provider</remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("movie/requested/{currentPosition}/{amountToLoad}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesDefaultResponseType]
|
||||||
|
public async Task<IEnumerable<SearchMovieViewModel>> RecentlyRequestedMovies(int currentPosition, int amountToLoad)
|
||||||
|
{
|
||||||
|
return await _movieEngineV2.RecentlyRequestedMovies(currentPosition, amountToLoad, Request.HttpContext.RequestAborted);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns Now Playing Movies
|
/// Returns Now Playing Movies
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -181,11 +181,11 @@ namespace Ombi
|
||||||
{
|
{
|
||||||
if (settings.BaseUrl.HasValue())
|
if (settings.BaseUrl.HasValue())
|
||||||
{
|
{
|
||||||
c.SwaggerEndpoint($"{settings.BaseUrl}/swagger/v1/swagger.json", "My API V1");
|
c.SwaggerEndpoint($"{settings.BaseUrl}/swagger/v1/swagger.json", "Ombi API");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Ombi API");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -287,6 +287,7 @@
|
||||||
"PopularTab": "Popular",
|
"PopularTab": "Popular",
|
||||||
"TrendingTab": "Trending",
|
"TrendingTab": "Trending",
|
||||||
"UpcomingTab": "Upcoming",
|
"UpcomingTab": "Upcoming",
|
||||||
|
"RecentlyRequestedTab": "Recently Requested",
|
||||||
"Movies": "Movies",
|
"Movies": "Movies",
|
||||||
"Combined": "Combined",
|
"Combined": "Combined",
|
||||||
"Tv": "TV",
|
"Tv": "TV",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue