mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 12:59:39 -07:00
Populate the TV APi with slightly more information
This commit is contained in:
parent
511f6ace77
commit
80595503c8
7 changed files with 47 additions and 17 deletions
|
@ -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<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<TraktShow>> GetPopularShows(int? page = default(int?), int? limitPerPage = default(int?));
|
||||||
Task<IEnumerable<TraktTrendingShow>> GetTrendingShows(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)
|
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;
|
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);
|
var anticipatedShows = await Client.Shows.GetMostWatchedShowsAsync(period ?? TraktTimePeriod.Monthly, new TraktExtendedInfo { Full = true, Images = true }, null, page ?? 1, limitPerPage ?? 10);
|
||||||
return anticipatedShows.Value;
|
return anticipatedShows.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<TraktShow> GetTvExtendedInfo(string imdbId)
|
||||||
|
{
|
||||||
|
return await Client.Shows.GetShowAsync(imdbId, new TraktExtendedInfo { Full = true });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,17 @@
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
|
||||||
|
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.Trakt;
|
||||||
using Ombi.Api.TvMaze;
|
using Ombi.Api.TvMaze;
|
||||||
using Ombi.Core.Models.Requests;
|
using Ombi.Core.Models.Requests;
|
||||||
|
@ -9,17 +21,6 @@ using Ombi.Core.Settings;
|
||||||
using Ombi.Core.Settings.Models.External;
|
using Ombi.Core.Settings.Models.External;
|
||||||
using Ombi.Store.Repository;
|
using Ombi.Store.Repository;
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Principal;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
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;
|
|
||||||
|
|
||||||
namespace Ombi.Core.Engine.V2
|
namespace Ombi.Core.Engine.V2
|
||||||
{
|
{
|
||||||
public class TvSearchEngineV2 : BaseMediaEngine, ITVSearchEngineV2
|
public class TvSearchEngineV2 : BaseMediaEngine, ITVSearchEngineV2
|
||||||
|
@ -57,6 +58,13 @@ namespace Ombi.Core.Engine.V2
|
||||||
return null;
|
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);
|
var mapped = Mapper.Map<SearchFullInfoTvShowViewModel>(show);
|
||||||
|
|
||||||
foreach (var e in show._embedded.episodes)
|
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)
|
private IEnumerable<SearchTvShowViewModel> ProcessResults<T>(IEnumerable<T> items)
|
||||||
|
@ -109,7 +117,7 @@ namespace Ombi.Core.Engine.V2
|
||||||
return Mapper.Map<SearchTvShowViewModel>(tvMazeSearch);
|
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();
|
item.TheTvDbId = item.Id.ToString();
|
||||||
|
|
||||||
|
@ -123,7 +131,22 @@ namespace Ombi.Core.Engine.V2
|
||||||
item.Available = oldModel.Available;
|
item.Available = oldModel.Available;
|
||||||
item.Approved = oldModel.Approved;
|
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 Images Images { get; set; }
|
||||||
public List<CastViewModel> Cast { get; set; }
|
public List<CastViewModel> Cast { get; set; }
|
||||||
public List<CrewViewModel> Crew { get; set; }
|
public List<CrewViewModel> Crew { get; set; }
|
||||||
|
public string Certification { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is used from the Trakt API
|
/// This is used from the Trakt API
|
||||||
|
|
|
@ -20,6 +20,7 @@ export interface ISearchTvResultV2 {
|
||||||
siteRating: number;
|
siteRating: number;
|
||||||
trailer: string;
|
trailer: string;
|
||||||
homepage: string;
|
homepage: string;
|
||||||
|
certifcation: string;
|
||||||
seasonRequests: INewSeasonRequests[];
|
seasonRequests: INewSeasonRequests[];
|
||||||
requestAll: boolean;
|
requestAll: boolean;
|
||||||
approved: boolean;
|
approved: boolean;
|
||||||
|
|
|
@ -44,10 +44,9 @@ namespace Ombi.Controllers.V2
|
||||||
return await _multiSearchEngine.MultiSearch(searchTerm);
|
return await _multiSearchEngine.MultiSearch(searchTerm);
|
||||||
}
|
}
|
||||||
|
|
||||||
// <summary>
|
/// <summary>
|
||||||
/// Returns details for a single movie
|
/// Returns details for a single movie
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("movie/{movieDbId}")]
|
[HttpGet("movie/{movieDbId}")]
|
||||||
public async Task<MovieFullInfoViewModel> GetMovieInfo(int movieDbId)
|
public async Task<MovieFullInfoViewModel> GetMovieInfo(int movieDbId)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue