First start on replacing tv maze

pull/4097/head
tidusjar 4 years ago
parent cf07204b73
commit 4e0ee5fee5

@ -28,7 +28,7 @@ namespace Ombi.Core.Engine.Demo
ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um, ICacheService memCache, ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um, ICacheService memCache,
ISettingsService<OmbiSettings> s, IRepository<RequestSubscription> sub, IOptions<DemoLists> lists, IImageService imageService, ISettingsService<OmbiSettings> s, IRepository<RequestSubscription> sub, IOptions<DemoLists> lists, IImageService imageService,
ISettingsService<CustomizationSettings> custom) ISettingsService<CustomizationSettings> custom)
: base(identity, service, tvMaze, mapper, trakt, r, um, custom, memCache, s, sub, imageService) : base(identity, service, tvMaze, mapper, trakt, r, um, custom, memCache, s, sub, imageService, null)
{ {
_demoLists = lists.Value; _demoLists = lists.Value;
} }

@ -189,7 +189,7 @@ namespace Ombi.Core.Engine
} }
protected async Task<List<SearchMovieViewModel>> TransformMovieResultsToResponse( protected async Task<List<SearchMovieViewModel>> TransformMovieResultsToResponse(
IEnumerable<MovieSearchResult> movies) IEnumerable<MovieDbSearchResult> movies)
{ {
var viewMovies = new List<SearchMovieViewModel>(); var viewMovies = new List<SearchMovieViewModel>();
foreach (var movie in movies) foreach (var movie in movies)
@ -244,7 +244,7 @@ namespace Ombi.Core.Engine
} }
} }
private async Task<SearchMovieViewModel> ProcessSingleMovie(MovieSearchResult movie) private async Task<SearchMovieViewModel> ProcessSingleMovie(MovieDbSearchResult movie)
{ {
var viewMovie = Mapper.Map<SearchMovieViewModel>(movie); var viewMovie = Mapper.Map<SearchMovieViewModel>(movie);
return await ProcessSingleMovie(viewMovie); return await ProcessSingleMovie(viewMovie);

@ -22,6 +22,8 @@ using Ombi.Helpers;
using Ombi.Settings.Settings.Models; using Ombi.Settings.Settings.Models;
using Ombi.Store.Entities; using Ombi.Store.Entities;
using TraktSharp.Entities; using TraktSharp.Entities;
using Ombi.Api.TheMovieDb;
using Ombi.Api.TheMovieDb.Models;
namespace Ombi.Core.Engine namespace Ombi.Core.Engine
{ {
@ -29,13 +31,16 @@ namespace Ombi.Core.Engine
{ {
private readonly ISettingsService<CustomizationSettings> _customizationSettings; private readonly ISettingsService<CustomizationSettings> _customizationSettings;
private readonly IImageService _imageService; private readonly IImageService _imageService;
private readonly IMovieDbApi _theMovieDbApi;
public TvSearchEngine(IPrincipal identity, IRequestServiceMain service, ITvMazeApi tvMaze, IMapper mapper, public TvSearchEngine(IPrincipal identity, IRequestServiceMain service, ITvMazeApi tvMaze, IMapper mapper,
ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um, ISettingsService<CustomizationSettings> customizationSettings, ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um, ISettingsService<CustomizationSettings> customizationSettings,
ICacheService memCache, ISettingsService<OmbiSettings> s, IRepository<RequestSubscription> sub, IImageService imageService) ICacheService memCache, ISettingsService<OmbiSettings> s, IRepository<RequestSubscription> sub, IImageService imageService,
IMovieDbApi theMovieDbApi)
: base(identity, service, r, um, memCache, s, sub) : base(identity, service, r, um, memCache, s, sub)
{ {
_imageService = imageService; _imageService = imageService;
_theMovieDbApi = theMovieDbApi;
TvMazeApi = tvMaze; TvMazeApi = tvMaze;
Mapper = mapper; Mapper = mapper;
TraktApi = trakt; TraktApi = trakt;
@ -48,18 +53,18 @@ namespace Ombi.Core.Engine
public async Task<IEnumerable<SearchTvShowViewModel>> Search(string searchTerm) public async Task<IEnumerable<SearchTvShowViewModel>> Search(string searchTerm)
{ {
var searchResult = await TvMazeApi.Search(searchTerm); var searchResult = await _theMovieDbApi.SearchTv(searchTerm);
if (searchResult != null) if (searchResult != null)
{ {
var retVal = new List<SearchTvShowViewModel>(); var retVal = new List<SearchTvShowViewModel>();
foreach (var tvMazeSearch in searchResult) foreach (var result in searchResult)
{ {
if (tvMazeSearch.show.externals == null || !(tvMazeSearch.show.externals?.thetvdb.HasValue ?? false)) //if (tvMazeSearch.show.externals == null || !(tvMazeSearch.show.externals?.thetvdb.HasValue ?? false))
{ //{
continue; // continue;
} //}
var mappedResult = await ProcessResult(tvMazeSearch, false); var mappedResult = await ProcessResult(result, false);
if (mappedResult == null) if (mappedResult == null)
{ {
continue; continue;
@ -135,12 +140,14 @@ namespace Ombi.Core.Engine
public async Task<IEnumerable<SearchTvShowViewModel>> Popular(int currentlyLoaded, int amountToLoad, bool includeImages = false) public async Task<IEnumerable<SearchTvShowViewModel>> Popular(int currentlyLoaded, int amountToLoad, bool includeImages = false)
{ {
var langCode = await DefaultLanguageCode(null);
var pages = PaginationHelper.GetNextPages(currentlyLoaded, amountToLoad, ResultLimit); var pages = PaginationHelper.GetNextPages(currentlyLoaded, amountToLoad, ResultLimit);
var results = new List<TraktShow>(); var results = new List<MovieDbSearchResult>();
foreach (var pagesToLoad in pages) foreach (var pagesToLoad in pages)
{ {
var apiResult = await Cache.GetOrAdd(nameof(Popular) + pagesToLoad.Page, var apiResult = await Cache.GetOrAdd(nameof(Popular) + langCode + pagesToLoad.Page,
async () => await TraktApi.GetPopularShows(pagesToLoad.Page, ResultLimit), DateTime.Now.AddHours(12)); async () => await _theMovieDbApi.PopularTv(langCode, pagesToLoad.Page), DateTime.Now.AddHours(12));
results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take)); results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take));
} }
@ -158,12 +165,14 @@ namespace Ombi.Core.Engine
public async Task<IEnumerable<SearchTvShowViewModel>> Anticipated(int currentlyLoaded, int amountToLoad) public async Task<IEnumerable<SearchTvShowViewModel>> Anticipated(int currentlyLoaded, int amountToLoad)
{ {
var langCode = await DefaultLanguageCode(null);
var pages = PaginationHelper.GetNextPages(currentlyLoaded, amountToLoad, ResultLimit); var pages = PaginationHelper.GetNextPages(currentlyLoaded, amountToLoad, ResultLimit);
var results = new List<TraktShow>(); var results = new List<MovieDbSearchResult>();
foreach (var pagesToLoad in pages) foreach (var pagesToLoad in pages)
{ {
var apiResult = await Cache.GetOrAdd(nameof(Anticipated) + pagesToLoad.Page, var apiResult = await Cache.GetOrAdd(nameof(Anticipated) + langCode + pagesToLoad.Page,
async () => await TraktApi.GetAnticipatedShows(pagesToLoad.Page, ResultLimit), DateTime.Now.AddHours(12)); async () => await _theMovieDbApi.UpcomingTv(langCode, pagesToLoad.Page), DateTime.Now.AddHours(12));
results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take)); results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take));
} }
var processed = ProcessResults(results); var processed = ProcessResults(results);
@ -180,12 +189,14 @@ namespace Ombi.Core.Engine
public async Task<IEnumerable<SearchTvShowViewModel>> Trending(int currentlyLoaded, int amountToLoad) public async Task<IEnumerable<SearchTvShowViewModel>> Trending(int currentlyLoaded, int amountToLoad)
{ {
var langCode = await DefaultLanguageCode(null);
var pages = PaginationHelper.GetNextPages(currentlyLoaded, amountToLoad, ResultLimit); var pages = PaginationHelper.GetNextPages(currentlyLoaded, amountToLoad, ResultLimit);
var results = new List<TraktShow>(); var results = new List<MovieDbSearchResult>();
foreach (var pagesToLoad in pages) foreach (var pagesToLoad in pages)
{ {
var apiResult = await Cache.GetOrAdd(nameof(Trending) + pagesToLoad.Page, var apiResult = await Cache.GetOrAdd(nameof(Trending) + langCode + pagesToLoad.Page,
async () => await TraktApi.GetTrendingShows(pagesToLoad.Page, ResultLimit), DateTime.Now.AddHours(12)); async () => await _theMovieDbApi.TopRatedTv(langCode, pagesToLoad.Page), DateTime.Now.AddHours(12));
results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take)); results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take));
} }
var processed = ProcessResults(results); var processed = ProcessResults(results);
@ -220,14 +231,15 @@ namespace Ombi.Core.Engine
{ {
return null; return null;
} }
item.TheTvDbId = item.Id.ToString(); item.TheMovieDbId = item.Id.ToString();
if (includeImages) //item.TheTvDbId = item.Id.ToString();
{ //if (includeImages)
if (item.TheTvDbId.HasValue()) //{
{ // if (item.TheTvDbId.HasValue())
item.BackdropPath = await _imageService.GetTvBackground(item.TheTvDbId); // {
} // item.BackdropPath = await _imageService.GetTvBackground(item.TheTvDbId);
} // }
//}
await RunSearchRules(item); await RunSearchRules(item);

@ -127,7 +127,7 @@ namespace Ombi.Core.Engine.V2
var pages = PaginationHelper.GetNextPages(currentlyLoaded, toLoad, _theMovieDbMaxPageItems); var pages = PaginationHelper.GetNextPages(currentlyLoaded, toLoad, _theMovieDbMaxPageItems);
var results = new List<MovieSearchResult>(); var results = new List<MovieDbSearchResult>();
foreach (var pagesToLoad in pages) foreach (var pagesToLoad in pages)
{ {
var apiResult = await Cache.GetOrAdd(nameof(PopularMovies) + pagesToLoad.Page + langCode, var apiResult = await Cache.GetOrAdd(nameof(PopularMovies) + pagesToLoad.Page + langCode,
@ -161,7 +161,7 @@ namespace Ombi.Core.Engine.V2
var pages = PaginationHelper.GetNextPages(currentPosition, amountToLoad, _theMovieDbMaxPageItems); var pages = PaginationHelper.GetNextPages(currentPosition, amountToLoad, _theMovieDbMaxPageItems);
var results = new List<MovieSearchResult>(); var results = new List<MovieDbSearchResult>();
foreach (var pagesToLoad in pages) foreach (var pagesToLoad in pages)
{ {
var apiResult = await Cache.GetOrAdd(nameof(TopRatedMovies) + pagesToLoad.Page + langCode, var apiResult = await Cache.GetOrAdd(nameof(TopRatedMovies) + pagesToLoad.Page + langCode,
@ -177,7 +177,7 @@ namespace Ombi.Core.Engine.V2
var pages = PaginationHelper.GetNextPages(currentPosition, amountToLoad, _theMovieDbMaxPageItems); var pages = PaginationHelper.GetNextPages(currentPosition, amountToLoad, _theMovieDbMaxPageItems);
var results = new List<MovieSearchResult>(); var results = new List<MovieDbSearchResult>();
foreach (var pagesToLoad in pages) foreach (var pagesToLoad in pages)
{ {
var apiResult = await Cache.GetOrAdd(nameof(NowPlayingMovies) + pagesToLoad.Page + langCode, var apiResult = await Cache.GetOrAdd(nameof(NowPlayingMovies) + pagesToLoad.Page + langCode,
@ -213,7 +213,7 @@ namespace Ombi.Core.Engine.V2
var pages = PaginationHelper.GetNextPages(currentPosition, amountToLoad, _theMovieDbMaxPageItems); var pages = PaginationHelper.GetNextPages(currentPosition, amountToLoad, _theMovieDbMaxPageItems);
var results = new List<MovieSearchResult>(); var results = new List<MovieDbSearchResult>();
foreach (var pagesToLoad in pages) foreach (var pagesToLoad in pages)
{ {
var apiResult = await Cache.GetOrAdd(nameof(UpcomingMovies) + pagesToLoad.Page + langCode, var apiResult = await Cache.GetOrAdd(nameof(UpcomingMovies) + pagesToLoad.Page + langCode,
@ -270,7 +270,7 @@ namespace Ombi.Core.Engine.V2
} }
protected async Task<List<SearchMovieViewModel>> TransformMovieResultsToResponse( protected async Task<List<SearchMovieViewModel>> TransformMovieResultsToResponse(
IEnumerable<MovieSearchResult> movies) IEnumerable<MovieDbSearchResult> movies)
{ {
var settings = await _customizationSettings.GetSettingsAsync(); var settings = await _customizationSettings.GetSettingsAsync();
var viewMovies = new List<SearchMovieViewModel>(); var viewMovies = new List<SearchMovieViewModel>();
@ -286,7 +286,7 @@ namespace Ombi.Core.Engine.V2
return viewMovies; return viewMovies;
} }
private async Task<SearchMovieViewModel> ProcessSingleMovie(MovieSearchResult movie) private async Task<SearchMovieViewModel> ProcessSingleMovie(MovieDbSearchResult movie)
{ {
var viewMovie = Mapper.Map<SearchMovieViewModel>(movie); var viewMovie = Mapper.Map<SearchMovieViewModel>(movie);
return await ProcessSingleMovie(viewMovie); return await ProcessSingleMovie(viewMovie);

@ -14,7 +14,7 @@ namespace Ombi.Mapping.Profiles
{ {
public MovieProfile() public MovieProfile()
{ {
CreateMap<SearchResult, MovieSearchResult>() CreateMap<SearchResult, MovieDbSearchResult>()
.ForMember(dest => dest.Adult, opts => opts.MapFrom(src => src.adult)) .ForMember(dest => dest.Adult, opts => opts.MapFrom(src => src.adult))
.ForMember(dest => dest.BackdropPath, opts => opts.MapFrom(src => src.backdrop_path)) .ForMember(dest => dest.BackdropPath, opts => opts.MapFrom(src => src.backdrop_path))
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.id)) .ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.id))
@ -24,7 +24,7 @@ namespace Ombi.Mapping.Profiles
.ForMember(dest => dest.Popularity, opts => opts.MapFrom(src => src.popularity)) .ForMember(dest => dest.Popularity, opts => opts.MapFrom(src => src.popularity))
.ForMember(dest => dest.PosterPath, opts => opts.MapFrom(src => src.poster_path)) .ForMember(dest => dest.PosterPath, opts => opts.MapFrom(src => src.poster_path))
.ForMember(dest => dest.ReleaseDate, opts => opts.MapFrom(src => src.release_date)) .ForMember(dest => dest.ReleaseDate, opts => opts.MapFrom(src => src.release_date))
.ForMember(dest => dest.Title, opts => opts.MapFrom(src => src.title)) .ForMember(dest => dest.Title, opts => opts.MapFrom(src => string.IsNullOrEmpty(src.title) ? src.name : src.title))
.ForMember(dest => dest.Video, opts => opts.MapFrom(src => src.video)) .ForMember(dest => dest.Video, opts => opts.MapFrom(src => src.video))
.ForMember(dest => dest.VoteAverage, opts => opts.MapFrom(src => src.vote_average)) .ForMember(dest => dest.VoteAverage, opts => opts.MapFrom(src => src.vote_average))
.ForMember(dest => dest.VoteCount, opts => opts.MapFrom(src => src.vote_count)); .ForMember(dest => dest.VoteCount, opts => opts.MapFrom(src => src.vote_count));
@ -75,7 +75,7 @@ namespace Ombi.Mapping.Profiles
CreateMap<TheMovieDbApi.Models.Genre, GenreDto>(); CreateMap<TheMovieDbApi.Models.Genre, GenreDto>();
CreateMap<MovieSearchResult, SearchMovieViewModel>().ReverseMap(); CreateMap<MovieDbSearchResult, SearchMovieViewModel>().ReverseMap();
CreateMap<MovieResponseDto, SearchMovieViewModel>().ReverseMap(); CreateMap<MovieResponseDto, SearchMovieViewModel>().ReverseMap();
CreateMap<FullMovieInfo, SearchMovieViewModel>().ReverseMap(); CreateMap<FullMovieInfo, SearchMovieViewModel>().ReverseMap();

@ -1,6 +1,7 @@
using System; using System;
using System.Globalization; using System.Globalization;
using AutoMapper; using AutoMapper;
using Ombi.Api.TheMovieDb.Models;
using Ombi.Api.TvMaze.Models; using Ombi.Api.TvMaze.Models;
using Ombi.Core.Models.Search; using Ombi.Core.Models.Search;
using Ombi.Helpers; using Ombi.Helpers;
@ -27,6 +28,15 @@ namespace Ombi.Mapping.Profiles
.ForMember(dest => dest.Banner, opts => opts.MapFrom(src => !string.IsNullOrEmpty(src.show.image.medium) ? src.show.image.medium.ToHttpsUrl() : string.Empty)) .ForMember(dest => dest.Banner, opts => opts.MapFrom(src => !string.IsNullOrEmpty(src.show.image.medium) ? src.show.image.medium.ToHttpsUrl() : string.Empty))
.ForMember(dest => dest.Status, opts => opts.MapFrom(src => src.show.status)); .ForMember(dest => dest.Status, opts => opts.MapFrom(src => src.show.status));
CreateMap<TvSearchResult, SearchTvShowViewModel>()
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.Id))
.ForMember(dest => dest.TheMovieDbId, opts => opts.MapFrom(src => src.Id.ToString()))
.ForMember(dest => dest.FirstAired, opts => opts.MapFrom(src => src.ReleaseDate))
.ForMember(dest => dest.Overview, opts => opts.MapFrom(src => src.Overview))
.ForMember(dest => dest.Rating, opts => opts.MapFrom(src => src.VoteAverage.ToString(CultureInfo.CurrentUICulture)))
.ForMember(dest => dest.Title, opts => opts.MapFrom(src => src.Name))
.ForMember(dest => dest.Banner, opts => opts.MapFrom(src => !string.IsNullOrEmpty(src.BackdropPath) ? src.BackdropPath.ToHttpsUrl() : src.PosterPath));
CreateMap<TvMazeShow, SearchTvShowViewModel>() CreateMap<TvMazeShow, SearchTvShowViewModel>()
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.externals.thetvdb)) .ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.externals.thetvdb))
.ForMember(dest => dest.FirstAired, opts => opts.MapFrom(src => src.premiered)) .ForMember(dest => dest.FirstAired, opts => opts.MapFrom(src => src.premiered))
@ -56,10 +66,27 @@ namespace Ombi.Mapping.Profiles
.ForMember(dest => dest.Runtime, opts => opts.MapFrom(src => src.Runtime.ToString())) .ForMember(dest => dest.Runtime, opts => opts.MapFrom(src => src.Runtime.ToString()))
.ForMember(dest => dest.Title, opts => opts.MapFrom(src => src.Title)) .ForMember(dest => dest.Title, opts => opts.MapFrom(src => src.Title))
.ForMember(dest => dest.Status, opts => opts.MapFrom(src => TraktEnumHelper.GetDescription(src.Status))) .ForMember(dest => dest.Status, opts => opts.MapFrom(src => TraktEnumHelper.GetDescription(src.Status)))
.ForMember(dest => dest.Trailer, .ForMember(dest => dest.Trailer,
opts => opts.MapFrom(src => src.Trailer != null ? src.Trailer.ToString().ToHttpsUrl() : string.Empty)) opts => opts.MapFrom(src => src.Trailer != null ? src.Trailer.ToString().ToHttpsUrl() : string.Empty))
.ForMember(dest => dest.Homepage, .ForMember(dest => dest.Homepage,
opts => opts.MapFrom(src => src.Homepage != null ? src.Homepage.ToString().ToHttpsUrl() : string.Empty)); opts => opts.MapFrom(src => src.Homepage != null ? src.Homepage.ToString().ToHttpsUrl() : string.Empty));
CreateMap<MovieDbSearchResult, SearchTvShowViewModel>()
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.Id))
.ForMember(dest => dest.FirstAired, opts => opts.MapFrom(src => src.ReleaseDate))
//.ForMember(dest => dest.ImdbId, opts => opts.MapFrom(src => src.Ids.Imdb))
//.ForMember(dest => dest.Network, opts => opts.MapFrom(src => src.Network))
.ForMember(dest => dest.Overview, opts => opts.MapFrom(src => src.Overview))
.ForMember(dest => dest.Rating, opts => opts.MapFrom(src => src.VoteAverage.ToString()))
.ForMember(dest => dest.BackdropPath, opts => opts.MapFrom(src => src.PosterPath))
//.ForMember(dest => dest.Runtime, opts => opts.MapFrom(src => src.Runtime.ToString()))
.ForMember(dest => dest.Title, opts => opts.MapFrom(src => src.Title));
//.ForMember(dest => dest.Status, opts => opts.MapFrom(src => TraktEnumHelper.GetDescription(src.Status)))
//.ForMember(dest => dest.Trailer,
// opts => opts.MapFrom(src => src.Trailer != null ? src.Trailer.ToString().ToHttpsUrl() : string.Empty))
//.ForMember(dest => dest.Homepage,
// opts => opts.MapFrom(src => src.Homepage != null ? src.Homepage.ToString().ToHttpsUrl() : string.Empty));
} }
} }
} }

@ -7,6 +7,7 @@ namespace Ombi.Store.Entities.Requests
public class TvRequests : Entity public class TvRequests : Entity
{ {
public int TvDbId { get; set; } public int TvDbId { get; set; }
//public int ExternalProviderId { get; set; }
public string ImdbId { get; set; } public string ImdbId { get; set; }
public int? QualityOverride { get; set; } public int? QualityOverride { get; set; }
public int? RootFolder { get; set; } public int? RootFolder { get; set; }

@ -10,13 +10,16 @@ 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, int? page = null); Task<List<MovieDbSearchResult>> NowPlaying(string languageCode, int? page = null);
Task<List<MovieSearchResult>> PopularMovies(string languageCode, int? page = null, CancellationToken cancellationToken = default(CancellationToken)); Task<List<MovieDbSearchResult>> PopularMovies(string languageCode, int? page = null, CancellationToken cancellationToken = default(CancellationToken));
Task<List<MovieSearchResult>> SearchMovie(string searchTerm, int? year, string languageCode); Task<List<MovieDbSearchResult>> PopularTv(string langCode, int? page = null, CancellationToken cancellationToken = default(CancellationToken));
Task<List<MovieDbSearchResult>> SearchMovie(string searchTerm, int? year, string languageCode);
Task<List<TvSearchResult>> SearchTv(string searchTerm, string year = default); Task<List<TvSearchResult>> SearchTv(string searchTerm, string year = default);
Task<List<MovieSearchResult>> TopRated(string languageCode, int? page = null); Task<List<MovieDbSearchResult>> TopRated(string languageCode, int? page = null);
Task<List<MovieSearchResult>> Upcoming(string languageCode, int? page = null); Task<List<MovieDbSearchResult>> Upcoming(string languageCode, int? page = null);
Task<List<MovieSearchResult>> SimilarMovies(int movieId, string langCode); Task<List<MovieDbSearchResult>> TopRatedTv(string languageCode, int? page = null);
Task<List<MovieDbSearchResult>> UpcomingTv(string languageCode, int? page = null);
Task<List<MovieDbSearchResult>> 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);
Task<TvInfo> GetTVInfo(string themoviedbid); Task<TvInfo> GetTVInfo(string themoviedbid);

@ -1,6 +1,6 @@
namespace Ombi.Api.TheMovieDb.Models namespace Ombi.Api.TheMovieDb.Models
{ {
public class MovieSearchResult public class MovieDbSearchResult
{ {
public string PosterPath { get; set; } public string PosterPath { get; set; }
public bool Adult { get; set; } public bool Adult { get; set; }

@ -132,7 +132,7 @@ namespace Ombi.Api.TheMovieDb
return await Api.Request<TvExternals>(request); return await Api.Request<TvExternals>(request);
} }
public async Task<List<MovieSearchResult>> SimilarMovies(int movieId, string langCode) public async Task<List<MovieDbSearchResult>> SimilarMovies(int movieId, string langCode)
{ {
var request = new Request($"movie/{movieId}/similar", BaseUri, HttpMethod.Get); var request = new Request($"movie/{movieId}/similar", BaseUri, HttpMethod.Get);
request.AddQueryString("api_key", ApiToken); request.AddQueryString("api_key", ApiToken);
@ -140,7 +140,7 @@ namespace Ombi.Api.TheMovieDb
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<MovieDbSearchResult>>(result.results);
} }
public async Task<MovieResponseDto> GetMovieInformationWithExtraInfo(int movieId, string langCode = "en") public async Task<MovieResponseDto> GetMovieInformationWithExtraInfo(int movieId, string langCode = "en")
@ -154,7 +154,7 @@ namespace Ombi.Api.TheMovieDb
return Mapper.Map<MovieResponseDto>(result); return Mapper.Map<MovieResponseDto>(result);
} }
public async Task<List<MovieSearchResult>> SearchMovie(string searchTerm, int? year, string langCode) public async Task<List<MovieDbSearchResult>> SearchMovie(string searchTerm, int? year, string langCode)
{ {
var request = new Request($"search/movie", BaseUri, HttpMethod.Get); var request = new Request($"search/movie", BaseUri, HttpMethod.Get);
request.AddQueryString("api_key", ApiToken); request.AddQueryString("api_key", ApiToken);
@ -171,15 +171,25 @@ namespace Ombi.Api.TheMovieDb
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<MovieDbSearchResult>>(result.results);
} }
/// <remarks> /// <remarks>
/// Maintains filter parity with <a href="https://developers.themoviedb.org/3/movies/get-popular-movies">/movie/popular</a>. /// Maintains filter parity with <a href="https://developers.themoviedb.org/3/movies/get-popular-movies">/movie/popular</a>.
/// </remarks> /// </remarks>
public async Task<List<MovieSearchResult>> PopularMovies(string langCode, int? page = null, CancellationToken cancellationToken = default(CancellationToken)) public async Task<List<MovieDbSearchResult>> PopularMovies(string langCode, int? page = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var request = new Request($"discover/movie", BaseUri, HttpMethod.Get); return await Popular("movie", langCode, page, cancellationToken);
}
public async Task<List<MovieDbSearchResult>> PopularTv(string langCode, int? page = null, CancellationToken cancellationToken = default(CancellationToken))
{
return await Popular("tv", langCode, page, cancellationToken);
}
public async Task<List<MovieDbSearchResult>> Popular(string type, string langCode, int? page = null, CancellationToken cancellationToken = default(CancellationToken))
{
var request = new Request($"discover/{type}", BaseUri, HttpMethod.Get);
request.AddQueryString("api_key", ApiToken); request.AddQueryString("api_key", ApiToken);
request.AddQueryString("language", langCode); request.AddQueryString("language", langCode);
request.AddQueryString("sort_by", "popularity.desc"); request.AddQueryString("sort_by", "popularity.desc");
@ -187,18 +197,28 @@ namespace Ombi.Api.TheMovieDb
{ {
request.AddQueryString("page", page.ToString()); request.AddQueryString("page", page.ToString());
} }
await AddDiscoverMovieSettings(request); await AddDiscoverSettings(request);
AddRetry(request); AddRetry(request);
var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request, cancellationToken); var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request, cancellationToken);
return Mapper.Map<List<MovieSearchResult>>(result.results); return Mapper.Map<List<MovieDbSearchResult>>(result.results);
}
public Task<List<MovieDbSearchResult>> TopRated(string langCode, int? page = null)
{
return TopRated("movie", langCode, page);
}
public Task<List<MovieDbSearchResult>> TopRatedTv(string langCode, int? page = null)
{
return TopRated("tv", langCode, page);
} }
/// <remarks> /// <remarks>
/// Maintains filter parity with <a href="https://developers.themoviedb.org/3/movies/get-top-rated-movies">/movie/top_rated</a>. /// Maintains filter parity with <a href="https://developers.themoviedb.org/3/movies/get-top-rated-movies">/movie/top_rated</a>.
/// </remarks> /// </remarks>
public async Task<List<MovieSearchResult>> TopRated(string langCode, int? page = null) private async Task<List<MovieDbSearchResult>> TopRated(string type, string langCode, int? page = null)
{ {
var request = new Request($"discover/movie", BaseUri, HttpMethod.Get); var request = new Request($"discover/{type}", BaseUri, HttpMethod.Get);
request.AddQueryString("api_key", ApiToken); request.AddQueryString("api_key", ApiToken);
request.AddQueryString("language", langCode); request.AddQueryString("language", langCode);
request.AddQueryString("sort_by", "vote_average.desc"); request.AddQueryString("sort_by", "vote_average.desc");
@ -212,18 +232,27 @@ namespace Ombi.Api.TheMovieDb
// to filter out extremely high-rated movies due to very little votes // to filter out extremely high-rated movies due to very little votes
request.AddQueryString("vote_count.gte", "250"); request.AddQueryString("vote_count.gte", "250");
await AddDiscoverMovieSettings(request); await AddDiscoverSettings(request);
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<MovieDbSearchResult>>(result.results);
}
public Task<List<MovieDbSearchResult>> Upcoming(string langCode, int? page = null)
{
return Upcoming("movie", langCode, page);
}
public Task<List<MovieDbSearchResult>> UpcomingTv(string langCode, int? page = null)
{
return Upcoming("tv", langCode, page);
} }
/// <remarks> /// <remarks>
/// Maintains filter parity with <a href="https://developers.themoviedb.org/3/movies/get-upcoming">/movie/upcoming</a>. /// Maintains filter parity with <a href="https://developers.themoviedb.org/3/movies/get-upcoming">/movie/upcoming</a>.
/// </remarks> /// </remarks>
public async Task<List<MovieSearchResult>> Upcoming(string langCode, int? page = null) private async Task<List<MovieDbSearchResult>> Upcoming(string type, string langCode, int? page = null)
{ {
var request = new Request($"discover/movie", BaseUri, HttpMethod.Get); var request = new Request($"discover/{type}", BaseUri, HttpMethod.Get);
request.AddQueryString("api_key", ApiToken); request.AddQueryString("api_key", ApiToken);
request.AddQueryString("language", langCode); request.AddQueryString("language", langCode);
@ -239,16 +268,16 @@ namespace Ombi.Api.TheMovieDb
{ {
request.AddQueryString("page", page.ToString()); request.AddQueryString("page", page.ToString());
} }
await AddDiscoverMovieSettings(request); await AddDiscoverSettings(request);
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<MovieDbSearchResult>>(result.results);
} }
/// <remarks> /// <remarks>
/// Maintains filter parity with <a href="https://developers.themoviedb.org/3/movies/get-now-playing">/movie/now_playing</a>. /// Maintains filter parity with <a href="https://developers.themoviedb.org/3/movies/get-now-playing">/movie/now_playing</a>.
/// </remarks> /// </remarks>
public async Task<List<MovieSearchResult>> NowPlaying(string langCode, int? page = null) public async Task<List<MovieDbSearchResult>> NowPlaying(string langCode, int? page = null)
{ {
var request = new Request($"discover/movie", BaseUri, HttpMethod.Get); var request = new Request($"discover/movie", BaseUri, HttpMethod.Get);
request.AddQueryString("api_key", ApiToken); request.AddQueryString("api_key", ApiToken);
@ -267,10 +296,10 @@ namespace Ombi.Api.TheMovieDb
request.AddQueryString("page", page.ToString()); request.AddQueryString("page", page.ToString());
} }
await AddDiscoverMovieSettings(request); await AddDiscoverSettings(request);
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<MovieDbSearchResult>>(result.results);
} }
public async Task<TvInfo> GetTVInfo(string themoviedbid) public async Task<TvInfo> GetTVInfo(string themoviedbid)
@ -330,7 +359,7 @@ namespace Ombi.Api.TheMovieDb
return Api.Request<WatchProviders>(request, token); return Api.Request<WatchProviders>(request, token);
} }
private async Task AddDiscoverMovieSettings(Request request) private async Task AddDiscoverSettings(Request request)
{ {
var settings = await Settings; var settings = await Settings;
request.AddQueryString("include_adult", settings.ShowAdultMovies.ToString().ToLower()); request.AddQueryString("include_adult", settings.ShowAdultMovies.ToString().ToLower());

@ -7,6 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi", "Ombi\Ombi.csproj",
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9D30CCF8-A115-4EB7-A34D-07780D752789}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9D30CCF8-A115-4EB7-A34D-07780D752789}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
..\.azuredevops\pipelines\templates\build-steps.yml = ..\.azuredevops\pipelines\templates\build-steps.yml ..\.azuredevops\pipelines\templates\build-steps.yml = ..\.azuredevops\pipelines\templates\build-steps.yml
..\build.cake = ..\build.cake ..\build.cake = ..\build.cake
..\CHANGELOG.md = ..\CHANGELOG.md ..\CHANGELOG.md = ..\CHANGELOG.md
@ -121,7 +122,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Api.Webhook", "Ombi.Ap
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Api.CloudService", "Ombi.Api.CloudService\Ombi.Api.CloudService.csproj", "{5DE40A66-B369-469E-8626-ECE23D9D8034}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Api.CloudService", "Ombi.Api.CloudService\Ombi.Api.CloudService.csproj", "{5DE40A66-B369-469E-8626-ECE23D9D8034}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api.RottenTomatoes", "Ombi.Api.RottenTomatoes\Ombi.Api.RottenTomatoes.csproj", "{8F19C701-7881-4BC7-8BBA-B068A6B954AD}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Api.RottenTomatoes", "Ombi.Api.RottenTomatoes\Ombi.Api.RottenTomatoes.csproj", "{8F19C701-7881-4BC7-8BBA-B068A6B954AD}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

@ -29,7 +29,8 @@ export class DiscoverCardComponent implements OnInit {
public ngOnInit() { public ngOnInit() {
if (this.result.type == RequestType.tvShow) { if (this.result.type == RequestType.tvShow) {
this.getExtraTvInfo(); this.fullyLoaded = true;
// this.getExtraTvInfo();
} }
if (this.result.type == RequestType.movie) { if (this.result.type == RequestType.movie) {
this.getExtraMovieInfo(); this.getExtraMovieInfo();
@ -44,15 +45,15 @@ export class DiscoverCardComponent implements OnInit {
} }
public async getExtraTvInfo() { public async getExtraTvInfo() {
if (this.result.tvMovieDb) { // if (this.result.tvMovieDb) {
this.tvSearchResult = await this.searchService.getTvInfoWithMovieDbId(+this.result.id); // this.tvSearchResult = await this.searchService.getTvInfoWithMovieDbId(+this.result.id);
} else { // } else {
this.tvSearchResult = await this.searchService.getTvInfo(+this.result.id); // this.tvSearchResult = await this.searchService.getTvInfo(+this.result.id);
} // }
if (!this.tvSearchResult || this.tvSearchResult?.status.length > 0 && this.tvSearchResult?.status === "404") { // if (!this.tvSearchResult || this.tvSearchResult?.status.length > 0 && this.tvSearchResult?.status === "404") {
this.hide = true; // this.hide = true;
return; // return;
} // }
this.setTvDefaults(this.tvSearchResult); this.setTvDefaults(this.tvSearchResult);
this.updateTvItem(this.tvSearchResult); this.updateTvItem(this.tvSearchResult);

@ -289,7 +289,7 @@ export class CarouselListComponent implements OnInit {
this.tvShows.forEach(m => { this.tvShows.forEach(m => {
tempResults.push({ tempResults.push({
available: m.available, available: m.available,
posterPath: "../../../images/default_tv_poster.png", posterPath: m.backdropPath ? `https://image.tmdb.org/t/p/w500/${m.backdropPath}` : "../../../images/default_tv_poster.png",
requested: m.requested, requested: m.requested,
title: m.title, title: m.title,
type: RequestType.tvShow, type: RequestType.tvShow,

@ -36,6 +36,7 @@ export interface ISearchTvResult {
subscribed: boolean; subscribed: boolean;
showSubscribe: boolean; showSubscribe: boolean;
fullyAvailable: boolean; fullyAvailable: boolean;
backdropPath: string;
partlyAvailable: boolean; partlyAvailable: boolean;
background: any; background: any;
open: boolean; // THIS IS FOR THE UI open: boolean; // THIS IS FOR THE UI

@ -14,7 +14,7 @@
"profiles": { "profiles": {
"IIS Express": { "IIS Express": {
"commandName": "IISExpress", "commandName": "IISExpress",
"commandLineArgs": "--host http://*:3577" , "commandLineArgs": "--host http://*:3577",
"launchBrowser": true, "launchBrowser": true,
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
@ -22,7 +22,7 @@
}, },
"Ombi": { "Ombi": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "--host http://localhost:3577 --baseUrl /ombi/", "commandLineArgs": "--host http://localhost:3577",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
}, },

Loading…
Cancel
Save