mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-14 01:02:57 -07:00
Finished the scrolling on the discover page
This commit is contained in:
parent
961ba4297a
commit
b4bf86f03e
10 changed files with 242 additions and 37 deletions
|
@ -13,9 +13,12 @@ namespace Ombi.Core.Engine.Interfaces
|
||||||
Task<IEnumerable<SearchMovieViewModel>> TopRatedMovies();
|
Task<IEnumerable<SearchMovieViewModel>> TopRatedMovies();
|
||||||
Task<IEnumerable<SearchMovieViewModel>> UpcomingMovies();
|
Task<IEnumerable<SearchMovieViewModel>> UpcomingMovies();
|
||||||
Task<IEnumerable<SearchMovieViewModel>> NowPlayingMovies();
|
Task<IEnumerable<SearchMovieViewModel>> NowPlayingMovies();
|
||||||
|
Task<IEnumerable<SearchMovieViewModel>> NowPlayingMovies(int currentPosition, int amountToLoad);
|
||||||
Task<MovieCollectionsViewModel> GetCollection(int collectionId, string langCode = null);
|
Task<MovieCollectionsViewModel> GetCollection(int collectionId, string langCode = null);
|
||||||
Task<int> GetTvDbId(int theMovieDbId);
|
Task<int> GetTvDbId(int theMovieDbId);
|
||||||
Task<IEnumerable<SearchMovieViewModel>> PopularMovies(int currentlyLoaded, int toLoad);
|
Task<IEnumerable<SearchMovieViewModel>> PopularMovies(int currentlyLoaded, int toLoad);
|
||||||
|
Task<IEnumerable<SearchMovieViewModel>> TopRatedMovies(int currentlyLoaded, int toLoad);
|
||||||
|
Task<IEnumerable<SearchMovieViewModel>> UpcomingMovies(int currentlyLoaded, int toLoad);
|
||||||
int ResultLimit { get; set; }
|
int ResultLimit { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,8 +11,11 @@ namespace Ombi.Core.Engine.Interfaces
|
||||||
Task<IEnumerable<SearchTvShowViewModel>> Popular();
|
Task<IEnumerable<SearchTvShowViewModel>> Popular();
|
||||||
Task<IEnumerable<SearchTvShowViewModel>> Popular(int currentlyLoaded, int amountToLoad);
|
Task<IEnumerable<SearchTvShowViewModel>> Popular(int currentlyLoaded, int amountToLoad);
|
||||||
Task<IEnumerable<SearchTvShowViewModel>> Anticipated();
|
Task<IEnumerable<SearchTvShowViewModel>> Anticipated();
|
||||||
|
Task<IEnumerable<SearchTvShowViewModel>> Anticipated(int currentlyLoaded, int amountToLoad);
|
||||||
Task<IEnumerable<SearchTvShowViewModel>> MostWatches();
|
Task<IEnumerable<SearchTvShowViewModel>> MostWatches();
|
||||||
Task<IEnumerable<SearchTvShowViewModel>> Trending();
|
Task<IEnumerable<SearchTvShowViewModel>> Trending();
|
||||||
|
Task<IEnumerable<SearchTvShowViewModel>> MostWatches(int currentlyLoaded, int amountToLoad);
|
||||||
|
Task<IEnumerable<SearchTvShowViewModel>> Trending(int currentlyLoaded, int amountToLoad);
|
||||||
int ResultLimit { get; set; }
|
int ResultLimit { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -22,6 +22,7 @@ using Ombi.Helpers;
|
||||||
using Ombi.Settings.Settings.Models;
|
using Ombi.Settings.Settings.Models;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
using TraktApiSharp.Objects.Get.Shows;
|
using TraktApiSharp.Objects.Get.Shows;
|
||||||
|
using TraktApiSharp.Objects.Get.Shows.Common;
|
||||||
|
|
||||||
namespace Ombi.Core.Engine
|
namespace Ombi.Core.Engine
|
||||||
{
|
{
|
||||||
|
@ -149,6 +150,19 @@ namespace Ombi.Core.Engine
|
||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<SearchTvShowViewModel>> Anticipated(int currentlyLoaded, int amountToLoad)
|
||||||
|
{
|
||||||
|
var pages = PaginationHelper.GetNextPages(currentlyLoaded, amountToLoad, ResultLimit);
|
||||||
|
var results = new List<TraktMostAnticipatedShow>();
|
||||||
|
foreach (var pagesToLoad in pages)
|
||||||
|
{
|
||||||
|
var apiResult = await TraktApi.GetAnticipatedShows(pagesToLoad.Page, ResultLimit);
|
||||||
|
results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take));
|
||||||
|
}
|
||||||
|
var processed = ProcessResults(results);
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatches()
|
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatches()
|
||||||
{
|
{
|
||||||
var result = await Cache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(null, ResultLimit), DateTime.Now.AddHours(12));
|
var result = await Cache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(null, ResultLimit), DateTime.Now.AddHours(12));
|
||||||
|
@ -163,6 +177,32 @@ namespace Ombi.Core.Engine
|
||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatches(int currentlyLoaded, int amountToLoad)
|
||||||
|
{
|
||||||
|
var pages = PaginationHelper.GetNextPages(currentlyLoaded, amountToLoad, ResultLimit);
|
||||||
|
var results = new List<TraktMostWatchedShow>();
|
||||||
|
foreach (var pagesToLoad in pages)
|
||||||
|
{
|
||||||
|
var apiResult = await TraktApi.GetMostWatchesShows(null, pagesToLoad.Page, ResultLimit);
|
||||||
|
results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take));
|
||||||
|
}
|
||||||
|
var processed = ProcessResults(results);
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<SearchTvShowViewModel>> Trending(int currentlyLoaded, int amountToLoad)
|
||||||
|
{
|
||||||
|
var pages = PaginationHelper.GetNextPages(currentlyLoaded, amountToLoad, ResultLimit);
|
||||||
|
var results = new List<TraktTrendingShow>();
|
||||||
|
foreach (var pagesToLoad in pages)
|
||||||
|
{
|
||||||
|
var apiResult = await TraktApi.GetTrendingShows(pagesToLoad.Page, ResultLimit);
|
||||||
|
results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take));
|
||||||
|
}
|
||||||
|
var processed = ProcessResults(results);
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
protected IEnumerable<SearchTvShowViewModel> ProcessResults<T>(IEnumerable<T> items)
|
protected IEnumerable<SearchTvShowViewModel> ProcessResults<T>(IEnumerable<T> items)
|
||||||
{
|
{
|
||||||
var retVal = new List<SearchTvShowViewModel>();
|
var retVal = new List<SearchTvShowViewModel>();
|
||||||
|
|
|
@ -138,6 +138,37 @@ namespace Ombi.Core.Engine.V2
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<SearchMovieViewModel>> TopRatedMovies(int currentPosition, int amountToLoad)
|
||||||
|
{
|
||||||
|
var langCode = await DefaultLanguageCode(null);
|
||||||
|
|
||||||
|
var pages = PaginationHelper.GetNextPages(currentPosition, amountToLoad, _theMovieDbMaxPageItems);
|
||||||
|
|
||||||
|
var results = new List<MovieSearchResult>();
|
||||||
|
foreach (var pagesToLoad in pages)
|
||||||
|
{
|
||||||
|
var apiResult = await MovieApi.TopRated(langCode, pagesToLoad.Page);
|
||||||
|
results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take));
|
||||||
|
}
|
||||||
|
return await TransformMovieResultsToResponse(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<SearchMovieViewModel>> NowPlayingMovies(int currentPosition, int amountToLoad)
|
||||||
|
{
|
||||||
|
var langCode = await DefaultLanguageCode(null);
|
||||||
|
|
||||||
|
var pages = PaginationHelper.GetNextPages(currentPosition, amountToLoad, _theMovieDbMaxPageItems);
|
||||||
|
|
||||||
|
var results = new List<MovieSearchResult>();
|
||||||
|
foreach (var pagesToLoad in pages)
|
||||||
|
{
|
||||||
|
var apiResult = await MovieApi.NowPlaying(langCode, pagesToLoad.Page);
|
||||||
|
results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take));
|
||||||
|
}
|
||||||
|
return await TransformMovieResultsToResponse(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets upcoming movies.
|
/// Gets upcoming movies.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -157,6 +188,21 @@ namespace Ombi.Core.Engine.V2
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<SearchMovieViewModel>> UpcomingMovies(int currentPosition, int amountToLoad)
|
||||||
|
{
|
||||||
|
var langCode = await DefaultLanguageCode(null);
|
||||||
|
|
||||||
|
var pages = PaginationHelper.GetNextPages(currentPosition, amountToLoad, _theMovieDbMaxPageItems);
|
||||||
|
|
||||||
|
var results = new List<MovieSearchResult>();
|
||||||
|
foreach (var pagesToLoad in pages)
|
||||||
|
{
|
||||||
|
var apiResult = await MovieApi.Upcoming(langCode, pagesToLoad.Page);
|
||||||
|
results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take));
|
||||||
|
}
|
||||||
|
return await TransformMovieResultsToResponse(results);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets now playing movies.
|
/// Gets now playing movies.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -9,12 +9,12 @@ namespace Ombi.Api.TheMovieDb
|
||||||
{
|
{
|
||||||
Task<MovieResponseDto> GetMovieInformation(int movieId);
|
Task<MovieResponseDto> GetMovieInformation(int movieId);
|
||||||
Task<MovieResponseDto> GetMovieInformationWithExtraInfo(int movieId, string langCode = "en");
|
Task<MovieResponseDto> GetMovieInformationWithExtraInfo(int movieId, string langCode = "en");
|
||||||
Task<List<MovieSearchResult>> NowPlaying(string languageCode);
|
Task<List<MovieSearchResult>> NowPlaying(string languageCode, int? page = null);
|
||||||
Task<List<MovieSearchResult>> PopularMovies(string languageCode);
|
Task<List<MovieSearchResult>> PopularMovies(string languageCode, int? page = null);
|
||||||
Task<List<MovieSearchResult>> SearchMovie(string searchTerm, int? year, string languageCode);
|
Task<List<MovieSearchResult>> SearchMovie(string searchTerm, int? year, string languageCode);
|
||||||
Task<List<TvSearchResult>> SearchTv(string searchTerm);
|
Task<List<TvSearchResult>> SearchTv(string searchTerm);
|
||||||
Task<List<MovieSearchResult>> TopRated(string languageCode);
|
Task<List<MovieSearchResult>> TopRated(string languageCode, int? page = null);
|
||||||
Task<List<MovieSearchResult>> Upcoming(string languageCode);
|
Task<List<MovieSearchResult>> Upcoming(string languageCode, int? page = null);
|
||||||
Task<List<MovieSearchResult>> SimilarMovies(int movieId, string langCode);
|
Task<List<MovieSearchResult>> SimilarMovies(int movieId, string langCode);
|
||||||
Task<FindResult> Find(string externalId, ExternalSource source);
|
Task<FindResult> Find(string externalId, ExternalSource source);
|
||||||
Task<TvExternals> GetTvExternals(int theMovieDbId);
|
Task<TvExternals> GetTvExternals(int theMovieDbId);
|
||||||
|
@ -25,6 +25,5 @@ namespace Ombi.Api.TheMovieDb
|
||||||
Task<FullMovieInfo> GetFullMovieInfo(int movieId, string langCode);
|
Task<FullMovieInfo> GetFullMovieInfo(int movieId, string langCode);
|
||||||
Task<TheMovieDbContainer<DiscoverMovies>> DiscoverMovies(string langCode, int keywordId);
|
Task<TheMovieDbContainer<DiscoverMovies>> DiscoverMovies(string langCode, int keywordId);
|
||||||
Task<Collections> GetCollection(string langCode, int collectionId);
|
Task<Collections> GetCollection(string langCode, int collectionId);
|
||||||
Task<List<MovieSearchResult>> PopularMovies(string langageCode, int page);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -156,52 +156,57 @@ namespace Ombi.Api.TheMovieDb
|
||||||
return Mapper.Map<List<MovieSearchResult>>(result.results);
|
return Mapper.Map<List<MovieSearchResult>>(result.results);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<MovieSearchResult>> PopularMovies(string langageCode)
|
public async Task<List<MovieSearchResult>> PopularMovies(string langageCode, int? page = null)
|
||||||
{
|
{
|
||||||
var request = new Request($"movie/popular", BaseUri, HttpMethod.Get);
|
var request = new Request($"movie/popular", BaseUri, HttpMethod.Get);
|
||||||
request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken);
|
request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken);
|
||||||
request.FullUri = request.FullUri.AddQueryParameter("language", langageCode);
|
request.FullUri = request.FullUri.AddQueryParameter("language", langageCode);
|
||||||
|
if (page != null)
|
||||||
|
{
|
||||||
|
request.FullUri = request.FullUri.AddQueryParameter("page", page.ToString());
|
||||||
|
}
|
||||||
AddRetry(request);
|
AddRetry(request);
|
||||||
var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request);
|
var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request);
|
||||||
return Mapper.Map<List<MovieSearchResult>>(result.results);
|
return Mapper.Map<List<MovieSearchResult>>(result.results);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<MovieSearchResult>> PopularMovies(string langageCode, int page)
|
public async Task<List<MovieSearchResult>> TopRated(string langageCode, int? page = null)
|
||||||
{
|
|
||||||
var request = new Request($"movie/popular", BaseUri, HttpMethod.Get);
|
|
||||||
request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken);
|
|
||||||
request.FullUri = request.FullUri.AddQueryParameter("language", langageCode);
|
|
||||||
request.FullUri = request.FullUri.AddQueryParameter("page", page.ToString());
|
|
||||||
AddRetry(request);
|
|
||||||
var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request);
|
|
||||||
return Mapper.Map<List<MovieSearchResult>>(result.results);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<List<MovieSearchResult>> TopRated(string langageCode)
|
|
||||||
{
|
{
|
||||||
var request = new Request($"movie/top_rated", BaseUri, HttpMethod.Get);
|
var request = new Request($"movie/top_rated", BaseUri, HttpMethod.Get);
|
||||||
request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken);
|
request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken);
|
||||||
request.FullUri = request.FullUri.AddQueryParameter("language", langageCode);
|
request.FullUri = request.FullUri.AddQueryParameter("language", langageCode);
|
||||||
|
if (page != null)
|
||||||
|
{
|
||||||
|
request.FullUri = request.FullUri.AddQueryParameter("page", page.ToString());
|
||||||
|
}
|
||||||
AddRetry(request);
|
AddRetry(request);
|
||||||
var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request);
|
var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request);
|
||||||
return Mapper.Map<List<MovieSearchResult>>(result.results);
|
return Mapper.Map<List<MovieSearchResult>>(result.results);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<MovieSearchResult>> Upcoming(string langageCode)
|
public async Task<List<MovieSearchResult>> Upcoming(string langageCode, int? page = null)
|
||||||
{
|
{
|
||||||
var request = new Request($"movie/upcoming", BaseUri, HttpMethod.Get);
|
var request = new Request($"movie/upcoming", BaseUri, HttpMethod.Get);
|
||||||
request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken);
|
request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken);
|
||||||
request.FullUri = request.FullUri.AddQueryParameter("language", langageCode);
|
request.FullUri = request.FullUri.AddQueryParameter("language", langageCode);
|
||||||
|
if (page != null)
|
||||||
|
{
|
||||||
|
request.FullUri = request.FullUri.AddQueryParameter("page", page.ToString());
|
||||||
|
}
|
||||||
AddRetry(request);
|
AddRetry(request);
|
||||||
var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request);
|
var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request);
|
||||||
return Mapper.Map<List<MovieSearchResult>>(result.results);
|
return Mapper.Map<List<MovieSearchResult>>(result.results);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<MovieSearchResult>> NowPlaying(string langageCode)
|
public async Task<List<MovieSearchResult>> NowPlaying(string langageCode, int? page = null)
|
||||||
{
|
{
|
||||||
var request = new Request($"movie/now_playing", BaseUri, HttpMethod.Get);
|
var request = new Request($"movie/now_playing", BaseUri, HttpMethod.Get);
|
||||||
request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken);
|
request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken);
|
||||||
request.FullUri = request.FullUri.AddQueryParameter("language", langageCode);
|
request.FullUri = request.FullUri.AddQueryParameter("language", langageCode);
|
||||||
|
if (page != null)
|
||||||
|
{
|
||||||
|
request.FullUri = request.FullUri.AddQueryParameter("page", page.ToString());
|
||||||
|
}
|
||||||
AddRetry(request);
|
AddRetry(request);
|
||||||
var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request);
|
var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request);
|
||||||
return Mapper.Map<List<MovieSearchResult>>(result.results);
|
return Mapper.Map<List<MovieSearchResult>>(result.results);
|
||||||
|
|
|
@ -16,8 +16,9 @@
|
||||||
|
|
||||||
<div *ngIf="discoverResults" class="row full-height discoverResults"
|
<div *ngIf="discoverResults" class="row full-height discoverResults"
|
||||||
infiniteScroll
|
infiniteScroll
|
||||||
[fromRoot]="true"
|
[fromRoot]="false"
|
||||||
[infiniteScrollDistance]="1"
|
[infiniteScrollDistance]="0.5"
|
||||||
|
[infiniteScrollDisabled]="scrollDisabled"
|
||||||
(scrolled)="onScroll()">
|
(scrolled)="onScroll()">
|
||||||
<div class="col-xl-2 col-lg-3 col-md-3 col-6 col-sm-4 small-padding" *ngFor="let result of discoverResults">
|
<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>
|
<discover-card [result]="result"></discover-card>
|
||||||
|
|
|
@ -29,6 +29,7 @@ export class DiscoverComponent implements OnInit {
|
||||||
public upcomingActive: boolean;
|
public upcomingActive: boolean;
|
||||||
|
|
||||||
public loadingFlag: boolean;
|
public loadingFlag: boolean;
|
||||||
|
public scrollDisabled: boolean;
|
||||||
|
|
||||||
private contentLoaded: number;
|
private contentLoaded: number;
|
||||||
private isScrolling: boolean = false;
|
private isScrolling: boolean = false;
|
||||||
|
@ -37,14 +38,14 @@ export class DiscoverComponent implements OnInit {
|
||||||
|
|
||||||
public async ngOnInit() {
|
public async ngOnInit() {
|
||||||
this.loading()
|
this.loading()
|
||||||
|
this.scrollDisabled = true;
|
||||||
this.movies = await this.searchService.popularMoviesByPage(0,12).toPromise();
|
this.movies = await this.searchService.popularMoviesByPage(0,12);
|
||||||
this.tvShows = await this.searchService.popularTvByPage(0,12);
|
this.tvShows = await this.searchService.popularTvByPage(0,12);
|
||||||
|
|
||||||
this.contentLoaded = 12;
|
this.contentLoaded = 12;
|
||||||
|
|
||||||
this.createInitialModel();
|
this.createInitialModel();
|
||||||
|
this.scrollDisabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async onScroll() {
|
public async onScroll() {
|
||||||
|
@ -57,10 +58,18 @@ export class DiscoverComponent implements OnInit {
|
||||||
console.log("SCROLLED!")
|
console.log("SCROLLED!")
|
||||||
this.loading();
|
this.loading();
|
||||||
if (this.popularActive) {
|
if (this.popularActive) {
|
||||||
this.movies = await this.searchService.popularMoviesByPage(this.contentLoaded, 12).toPromise();
|
this.movies = await this.searchService.popularMoviesByPage(this.contentLoaded, 12);
|
||||||
this.tvShows = await this.searchService.popularTvByPage(this.contentLoaded, 12);
|
this.tvShows = await this.searchService.popularTvByPage(this.contentLoaded, 12);
|
||||||
this.contentLoaded += 12;
|
|
||||||
}
|
}
|
||||||
|
if(this.trendingActive) {
|
||||||
|
this.movies = await this.searchService.nowPlayingMoviesByPage(this.contentLoaded, 12);
|
||||||
|
this.tvShows = await this.searchService.trendingTvByPage(this.contentLoaded, 12);
|
||||||
|
}
|
||||||
|
if(this.upcomingActive) {
|
||||||
|
this.movies = await this.searchService.upcomingMoviesByPage(this.contentLoaded, 12);
|
||||||
|
this.tvShows = await this.searchService.anticipatedTvByPage(this.contentLoaded, 12);
|
||||||
|
}
|
||||||
|
this.contentLoaded += 12;
|
||||||
|
|
||||||
this.createModel();
|
this.createModel();
|
||||||
this.isScrolling = false;
|
this.isScrolling = false;
|
||||||
|
@ -69,44 +78,51 @@ export class DiscoverComponent implements OnInit {
|
||||||
|
|
||||||
public async popular() {
|
public async popular() {
|
||||||
this.clear();
|
this.clear();
|
||||||
|
this.scrollDisabled = true;
|
||||||
|
this.isScrolling = false;
|
||||||
this.contentLoaded = 12;
|
this.contentLoaded = 12;
|
||||||
this.loading()
|
this.loading()
|
||||||
this.popularActive = true;
|
this.popularActive = true;
|
||||||
this.trendingActive = false;
|
this.trendingActive = false;
|
||||||
this.upcomingActive = false;
|
this.upcomingActive = false;
|
||||||
this.movies = await this.searchService.popularMoviesByPage(0, 12).toPromise();
|
this.movies = await this.searchService.popularMoviesByPage(0, 12);
|
||||||
this.tvShows = await this.searchService.popularTvByPage(0, 12);
|
this.tvShows = await this.searchService.popularTvByPage(0, 12);
|
||||||
|
|
||||||
|
|
||||||
this.createModel();
|
this.createModel();
|
||||||
|
this.scrollDisabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async trending() {
|
public async trending() {
|
||||||
this.clear();
|
this.clear();
|
||||||
|
|
||||||
|
this.scrollDisabled = true;
|
||||||
|
this.isScrolling = false;
|
||||||
this.contentLoaded = 12;
|
this.contentLoaded = 12;
|
||||||
this.loading()
|
this.loading()
|
||||||
this.popularActive = false;
|
this.popularActive = false;
|
||||||
this.trendingActive = true;
|
this.trendingActive = true;
|
||||||
this.upcomingActive = false;
|
this.upcomingActive = false;
|
||||||
this.movies = await this.searchService.nowPlayingMovies().toPromise();
|
this.movies = await this.searchService.nowPlayingMoviesByPage(0, 12);
|
||||||
this.tvShows = await this.searchService.trendingTv().toPromise();
|
this.tvShows = await this.searchService.trendingTvByPage(0, 12);
|
||||||
|
|
||||||
this.createModel();
|
this.createModel();
|
||||||
|
this.scrollDisabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async upcoming() {
|
public async upcoming() {
|
||||||
this.clear();
|
this.clear();
|
||||||
|
this.scrollDisabled = true;
|
||||||
|
this.isScrolling = false;
|
||||||
this.contentLoaded = 12;
|
this.contentLoaded = 12;
|
||||||
this.loading()
|
this.loading()
|
||||||
this.popularActive = false;
|
this.popularActive = false;
|
||||||
this.trendingActive = false;
|
this.trendingActive = false;
|
||||||
this.upcomingActive = true;
|
this.upcomingActive = true;
|
||||||
this.movies = await this.searchService.upcomingMovies().toPromise();
|
this.movies = await this.searchService.upcomingMoviesByPage(0, 12);
|
||||||
this.tvShows = await this.searchService.anticipatedTv().toPromise();
|
this.tvShows = await this.searchService.anticipatedTvByPage(0, 12);
|
||||||
|
|
||||||
this.createModel();
|
this.createModel();
|
||||||
|
this.scrollDisabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createModel() {
|
private createModel() {
|
||||||
|
|
|
@ -34,17 +34,24 @@ export class SearchV2Service extends ServiceHelpers {
|
||||||
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/Popular`);
|
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/Popular`);
|
||||||
}
|
}
|
||||||
|
|
||||||
public popularMoviesByPage(currentlyLoaded: number, toLoad: number): Observable<ISearchMovieResult[]> {
|
public popularMoviesByPage(currentlyLoaded: number, toLoad: number): Promise<ISearchMovieResult[]> {
|
||||||
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/Popular/${currentlyLoaded}/${toLoad}`);
|
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/Popular/${currentlyLoaded}/${toLoad}`).toPromise();
|
||||||
}
|
}
|
||||||
|
|
||||||
public upcomingMovies(): Observable<ISearchMovieResult[]> {
|
public upcomingMovies(): Observable<ISearchMovieResult[]> {
|
||||||
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/upcoming`);
|
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/upcoming`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public upcomingMoviesByPage(currentlyLoaded: number, toLoad: number): Promise<ISearchMovieResult[]> {
|
||||||
|
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/upcoming/${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`);
|
||||||
}
|
}
|
||||||
|
public nowPlayingMoviesByPage(currentlyLoaded: number, toLoad: number): Promise<ISearchMovieResult[]> {
|
||||||
|
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/nowplaying/${currentlyLoaded}/${toLoad}`).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
public topRatedMovies(): Observable<ISearchMovieResult[]> {
|
public topRatedMovies(): Observable<ISearchMovieResult[]> {
|
||||||
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/toprated`);
|
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/toprated`);
|
||||||
|
@ -64,10 +71,17 @@ export class SearchV2Service extends ServiceHelpers {
|
||||||
public anticipatedTv(): Observable<ISearchTvResult[]> {
|
public anticipatedTv(): Observable<ISearchTvResult[]> {
|
||||||
return this.http.get<ISearchTvResult[]>(`${this.url}/Tv/anticipated`, { headers: this.headers });
|
return this.http.get<ISearchTvResult[]>(`${this.url}/Tv/anticipated`, { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
public anticipatedTvByPage(currentlyLoaded: number, toLoad: number): Promise<ISearchTvResult[]> {
|
||||||
|
return this.http.get<ISearchTvResult[]>(`${this.url}/Tv/anticipated/${currentlyLoaded}/${toLoad}`, { headers: this.headers }).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
public trendingTv(): Observable<ISearchTvResult[]> {
|
public trendingTv(): Observable<ISearchTvResult[]> {
|
||||||
return this.http.get<ISearchTvResult[]>(`${this.url}/Tv/trending`, { headers: this.headers });
|
return this.http.get<ISearchTvResult[]>(`${this.url}/Tv/trending`, { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public trendingTvByPage(currentlyLoaded: number, toLoad: number): Promise<ISearchTvResult[]> {
|
||||||
|
return this.http.get<ISearchTvResult[]>(`${this.url}/Tv/trending/${currentlyLoaded}/${toLoad}`, { headers: this.headers }).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
public getTvInfo(tvdbid: number): Promise<ISearchTvResultV2> {
|
public getTvInfo(tvdbid: number): Promise<ISearchTvResultV2> {
|
||||||
return this.http.get<ISearchTvResultV2>(`${this.url}/Tv/${tvdbid}`, { headers: this.headers }).toPromise();
|
return this.http.get<ISearchTvResultV2>(`${this.url}/Tv/${tvdbid}`, { headers: this.headers }).toPromise();
|
||||||
|
|
|
@ -148,6 +148,19 @@ namespace Ombi.Controllers.V2
|
||||||
return await _movieEngineV2.NowPlayingMovies();
|
return await _movieEngineV2.NowPlayingMovies();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns Now Playing Movies by page
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>We use TheMovieDb as the Movie Provider</remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("movie/nowplaying/{currentPosition}/{amountToLoad}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesDefaultResponseType]
|
||||||
|
public async Task<IEnumerable<SearchMovieViewModel>> NowPlayingMovies(int currentPosition, int amountToLoad)
|
||||||
|
{
|
||||||
|
return await _movieEngineV2.NowPlayingMovies(currentPosition, amountToLoad);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns top rated movies.
|
/// Returns top rated movies.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -161,6 +174,19 @@ namespace Ombi.Controllers.V2
|
||||||
return await _movieEngineV2.TopRatedMovies();
|
return await _movieEngineV2.TopRatedMovies();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns top rated movies by page.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <remarks>We use TheMovieDb as the Movie Provider</remarks>
|
||||||
|
[HttpGet("movie/toprated/{currentPosition}/{amountToLoad}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesDefaultResponseType]
|
||||||
|
public async Task<IEnumerable<SearchMovieViewModel>> TopRatedMovies(int currentPosition, int amountToLoad)
|
||||||
|
{
|
||||||
|
return await _movieEngineV2.TopRatedMovies(currentPosition, amountToLoad);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns Upcoming movies.
|
/// Returns Upcoming movies.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -174,6 +200,19 @@ namespace Ombi.Controllers.V2
|
||||||
return await _movieEngineV2.UpcomingMovies();
|
return await _movieEngineV2.UpcomingMovies();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns Upcoming movies by page.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>We use TheMovieDb as the Movie Provider</remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("movie/upcoming/{currentPosition}/{amountToLoad}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesDefaultResponseType]
|
||||||
|
public async Task<IEnumerable<SearchMovieViewModel>> UpcomingMovies(int currentPosition, int amountToLoad)
|
||||||
|
{
|
||||||
|
return await _movieEngineV2.UpcomingMovies(currentPosition, amountToLoad);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns Popular Tv Shows
|
/// Returns Popular Tv Shows
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -201,7 +240,7 @@ namespace Ombi.Controllers.V2
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns most Anticiplateds tv shows.
|
/// Returns most Anticipated tv shows.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
@ -213,6 +252,19 @@ namespace Ombi.Controllers.V2
|
||||||
return await _tvSearchEngine.Anticipated();
|
return await _tvSearchEngine.Anticipated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns most Anticipated tv shows by page.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("tv/anticipated/{currentPosition}/{amountToLoad}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesDefaultResponseType]
|
||||||
|
public async Task<IEnumerable<SearchTvShowViewModel>> AnticipatedTv(int currentPosition, int amountToLoad)
|
||||||
|
{
|
||||||
|
return await _tvSearchEngine.Anticipated(currentPosition, amountToLoad);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns Most watched shows.
|
/// Returns Most watched shows.
|
||||||
|
@ -227,6 +279,19 @@ namespace Ombi.Controllers.V2
|
||||||
return await _tvSearchEngine.MostWatches();
|
return await _tvSearchEngine.MostWatches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns Most watched shows by page.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("tv/mostwatched/{currentPosition}/{amountToLoad}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesDefaultResponseType]
|
||||||
|
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatched(int currentPosition, int amountToLoad)
|
||||||
|
{
|
||||||
|
return await _tvSearchEngine.MostWatches(currentPosition, amountToLoad);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns trending shows
|
/// Returns trending shows
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -239,5 +304,18 @@ namespace Ombi.Controllers.V2
|
||||||
{
|
{
|
||||||
return await _tvSearchEngine.Trending();
|
return await _tvSearchEngine.Trending();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns trending shows by page
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("tv/trending/{currentPosition}/{amountToLoad}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesDefaultResponseType]
|
||||||
|
public async Task<IEnumerable<SearchTvShowViewModel>> Trending(int currentPosition, int amountToLoad)
|
||||||
|
{
|
||||||
|
return await _tvSearchEngine.Trending(currentPosition, amountToLoad);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue