Populate the TV APi with slightly more information

pull/3895/head
TidusJar 6 years ago
parent 511f6ace77
commit 80595503c8

@ -12,5 +12,6 @@ namespace Ombi.Api.Trakt
Task<IEnumerable<TraktMostWatchedShow>> GetMostWatchesShows(TraktTimePeriod period = null, int? page = default(int?), int? limitPerPage = default(int?));
Task<IEnumerable<TraktShow>> GetPopularShows(int? page = default(int?), int? limitPerPage = default(int?));
Task<IEnumerable<TraktTrendingShow>> GetTrendingShows(int? page = default(int?), int? limitPerPage = default(int?));
Task<TraktShow> GetTvExtendedInfo(string imdbId);
}
}

@ -23,7 +23,7 @@ namespace Ombi.Api.Trakt
public async Task<IEnumerable<TraktShow>> GetPopularShows(int? page = null, int? limitPerPage = null)
{
var popular = await Client.Shows.GetPopularShowsAsync(new TraktExtendedInfo { Full = true, Images = true}, null, page ?? 1, limitPerPage ?? 10);
var popular = await Client.Shows.GetPopularShowsAsync(new TraktExtendedInfo { Full = true, Images = true }, null, page ?? 1, limitPerPage ?? 10);
return popular.Value;
}
@ -44,6 +44,11 @@ namespace Ombi.Api.Trakt
var anticipatedShows = await Client.Shows.GetMostWatchedShowsAsync(period ?? TraktTimePeriod.Monthly, new TraktExtendedInfo { Full = true, Images = true }, null, page ?? 1, limitPerPage ?? 10);
return anticipatedShows.Value;
}
public async Task<TraktShow> GetTvExtendedInfo(string imdbId)
{
return await Client.Shows.GetShowAsync(imdbId, new TraktExtendedInfo { Full = true });
}
}
}

@ -1,24 +1,25 @@
using AutoMapper;
using Ombi.Api.Trakt;
using Ombi.Api.TvMaze;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Search;
using Ombi.Core.Models.Search.V2;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
using Ombi.Store.Repository;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Threading.Tasks;
using TraktApiSharp.Objects.Get.Shows;
using Ombi.Core.Rule.Interfaces;
using Ombi.Store.Repository.Requests;
using Ombi.Core.Authentication;
using Ombi.Helpers;
using Ombi.Settings.Settings.Models;
using Ombi.Store.Entities;
using Ombi.Api.Trakt;
using Ombi.Api.TvMaze;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Search;
using Ombi.Core.Models.Search.V2;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
using Ombi.Store.Repository;
namespace Ombi.Core.Engine.V2
{
@ -57,6 +58,13 @@ namespace Ombi.Core.Engine.V2
return null;
}
// Setup the task so we can get the data later on if we have a IMDBID
Task<TraktShow> traktInfoTask = new Task<TraktShow>(() => null);
if (show.externals?.imdb.HasValue() ?? false)
{
traktInfoTask = TraktApi.GetTvExtendedInfo(show.externals?.imdb);
}
var mapped = Mapper.Map<SearchFullInfoTvShowViewModel>(show);
foreach (var e in show._embedded.episodes)
@ -91,7 +99,7 @@ namespace Ombi.Core.Engine.V2
});
}
}
return await ProcessResult(mapped);
return await ProcessResult(mapped, traktInfoTask);
}
private IEnumerable<SearchTvShowViewModel> ProcessResults<T>(IEnumerable<T> items)
@ -109,7 +117,7 @@ namespace Ombi.Core.Engine.V2
return Mapper.Map<SearchTvShowViewModel>(tvMazeSearch);
}
private async Task<SearchFullInfoTvShowViewModel> ProcessResult(SearchFullInfoTvShowViewModel item)
private async Task<SearchFullInfoTvShowViewModel> ProcessResult(SearchFullInfoTvShowViewModel item, Task<TraktShow> showInfoTask)
{
item.TheTvDbId = item.Id.ToString();
@ -123,7 +131,22 @@ namespace Ombi.Core.Engine.V2
item.Available = oldModel.Available;
item.Approved = oldModel.Approved;
return item;
return await GetExtraInfo(showInfoTask, item);
}
private async Task<SearchFullInfoTvShowViewModel> GetExtraInfo(Task<TraktShow> showInfoTask, SearchFullInfoTvShowViewModel model)
{
var result = await showInfoTask;
if(result == null)
{
return model;
}
model.Trailer = result.Trailer;
model.Certification = result.Certification;
model.Homepage = result.Homepage;
return model;
}
}
}

@ -25,6 +25,7 @@ namespace Ombi.Core.Models.Search.V2
public Images Images { get; set; }
public List<CastViewModel> Cast { get; set; }
public List<CrewViewModel> Crew { get; set; }
public string Certification { get; set; }
/// <summary>
/// This is used from the Trakt API

@ -20,6 +20,7 @@ export interface ISearchTvResultV2 {
siteRating: number;
trailer: string;
homepage: string;
certifcation: string;
seasonRequests: INewSeasonRequests[];
requestAll: boolean;
approved: boolean;

@ -44,10 +44,9 @@ namespace Ombi.Controllers.V2
return await _multiSearchEngine.MultiSearch(searchTerm);
}
// <summary>
/// <summary>
/// Returns details for a single movie
/// </summary>
/// <returns></returns>
[HttpGet("movie/{movieDbId}")]
public async Task<MovieFullInfoViewModel> GetMovieInfo(int movieDbId)
{

Loading…
Cancel
Save