mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-11 15:56:05 -07:00
API improvements
This commit is contained in:
parent
410228935a
commit
90052d38ac
4 changed files with 98 additions and 19 deletions
|
@ -10,9 +10,13 @@ namespace Ombi.Core.Engine.Interfaces
|
||||||
Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> SearchTreeNode(string searchTerm);
|
Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> SearchTreeNode(string searchTerm);
|
||||||
Task<TreeNode<SearchTvShowViewModel>> GetShowInformationTreeNode(int tvdbid);
|
Task<TreeNode<SearchTvShowViewModel>> GetShowInformationTreeNode(int tvdbid);
|
||||||
Task<SearchTvShowViewModel> GetShowInformation(int tvdbid);
|
Task<SearchTvShowViewModel> GetShowInformation(int tvdbid);
|
||||||
Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> Popular();
|
Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> PopularTree();
|
||||||
Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> Anticipated();
|
Task<IEnumerable<SearchTvShowViewModel>> Popular();
|
||||||
Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> MostWatches();
|
Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> AnticipatedTree();
|
||||||
Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> Trending();
|
Task<IEnumerable<SearchTvShowViewModel>> Anticipated();
|
||||||
|
Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> MostWatchesTree();
|
||||||
|
Task<IEnumerable<SearchTvShowViewModel>> MostWatches();
|
||||||
|
Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> TrendingTree();
|
||||||
|
Task<IEnumerable<SearchTvShowViewModel>> Trending();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -122,33 +122,60 @@ namespace Ombi.Core.Engine
|
||||||
return ParseIntoTreeNode(result);
|
return ParseIntoTreeNode(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> Popular()
|
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> PopularTree()
|
||||||
{
|
{
|
||||||
var result = await MemCache.GetOrAdd(CacheKeys.PopularTv, async () => await TraktApi.GetPopularShows(), DateTime.Now.AddHours(12));
|
var result = await MemCache.GetOrAdd(CacheKeys.PopularTv, async () => await TraktApi.GetPopularShows(), DateTime.Now.AddHours(12));
|
||||||
var processed = await ProcessResults(result);
|
var processed = await ProcessResults(result);
|
||||||
return processed.Select(ParseIntoTreeNode).ToList();
|
return processed.Select(ParseIntoTreeNode).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> Anticipated()
|
public async Task<IEnumerable<SearchTvShowViewModel>> Popular()
|
||||||
{
|
{
|
||||||
var result = await MemCache.GetOrAdd(CacheKeys.AnticipatedTv, async () => await TraktApi.GetAnticipatedShows(), DateTime.Now.AddHours(12));
|
var result = await MemCache.GetOrAdd(CacheKeys.PopularTv, async () => await TraktApi.GetPopularShows(), DateTime.Now.AddHours(12));
|
||||||
var processed= await ProcessResults(result);
|
var processed = await ProcessResults(result);
|
||||||
return processed.Select(ParseIntoTreeNode).ToList();
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> MostWatches()
|
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> AnticipatedTree()
|
||||||
|
{
|
||||||
|
var result = await MemCache.GetOrAdd(CacheKeys.AnticipatedTv, async () => await TraktApi.GetAnticipatedShows(), DateTime.Now.AddHours(12));
|
||||||
|
var processed = await ProcessResults(result);
|
||||||
|
return processed.Select(ParseIntoTreeNode).ToList();
|
||||||
|
}
|
||||||
|
public async Task<IEnumerable<SearchTvShowViewModel>> Anticipated()
|
||||||
|
{
|
||||||
|
var result = await MemCache.GetOrAdd(CacheKeys.AnticipatedTv, async () => await TraktApi.GetAnticipatedShows(), DateTime.Now.AddHours(12));
|
||||||
|
var processed = await ProcessResults(result);
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> MostWatchesTree()
|
||||||
{
|
{
|
||||||
var result = await MemCache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(), DateTime.Now.AddHours(12));
|
var result = await MemCache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(), DateTime.Now.AddHours(12));
|
||||||
var processed = await ProcessResults(result);
|
var processed = await ProcessResults(result);
|
||||||
return processed.Select(ParseIntoTreeNode).ToList();
|
return processed.Select(ParseIntoTreeNode).ToList();
|
||||||
}
|
}
|
||||||
|
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatches()
|
||||||
|
{
|
||||||
|
var result = await MemCache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(), DateTime.Now.AddHours(12));
|
||||||
|
var processed = await ProcessResults(result);
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> Trending()
|
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> TrendingTree()
|
||||||
{
|
{
|
||||||
var result = await MemCache.GetOrAdd(CacheKeys.TrendingTv, async () => await TraktApi.GetTrendingShows(), DateTime.Now.AddHours(12));
|
var result = await MemCache.GetOrAdd(CacheKeys.TrendingTv, async () => await TraktApi.GetTrendingShows(), DateTime.Now.AddHours(12));
|
||||||
var processed = await ProcessResults(result);
|
var processed = await ProcessResults(result);
|
||||||
return processed.Select(ParseIntoTreeNode).ToList();
|
return processed.Select(ParseIntoTreeNode).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
|
||||||
|
{
|
||||||
|
var result = await MemCache.GetOrAdd(CacheKeys.TrendingTv, async () => await TraktApi.GetTrendingShows(), DateTime.Now.AddHours(12));
|
||||||
|
var processed = await ProcessResults(result);
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
private static TreeNode<SearchTvShowViewModel> ParseIntoTreeNode(SearchTvShowViewModel result)
|
private static TreeNode<SearchTvShowViewModel> ParseIntoTreeNode(SearchTvShowViewModel result)
|
||||||
{
|
{
|
||||||
return new TreeNode<SearchTvShowViewModel>
|
return new TreeNode<SearchTvShowViewModel>
|
||||||
|
|
|
@ -54,15 +54,15 @@ export class SearchService extends ServiceHelpers {
|
||||||
}
|
}
|
||||||
|
|
||||||
public popularTv(): Observable<TreeNode[]> {
|
public popularTv(): Observable<TreeNode[]> {
|
||||||
return this.http.get<TreeNode[]>(`${this.url}/Tv/popular`, {headers: this.headers});
|
return this.http.get<TreeNode[]>(`${this.url}/Tv/popular/tree`, {headers: this.headers});
|
||||||
}
|
}
|
||||||
public mostWatchedTv(): Observable<TreeNode[]> {
|
public mostWatchedTv(): Observable<TreeNode[]> {
|
||||||
return this.http.get<TreeNode[]>(`${this.url}/Tv/mostwatched`, {headers: this.headers});
|
return this.http.get<TreeNode[]>(`${this.url}/Tv/mostwatched/tree`, {headers: this.headers});
|
||||||
}
|
}
|
||||||
public anticipatedTv(): Observable<TreeNode[]> {
|
public anticipatedTv(): Observable<TreeNode[]> {
|
||||||
return this.http.get<TreeNode[]>(`${this.url}/Tv/anticipated`, {headers: this.headers});
|
return this.http.get<TreeNode[]>(`${this.url}/Tv/anticipated/tree`, {headers: this.headers});
|
||||||
}
|
}
|
||||||
public trendingTv(): Observable<TreeNode[]> {
|
public trendingTv(): Observable<TreeNode[]> {
|
||||||
return this.http.get<TreeNode[]>(`${this.url}/Tv/trending`, {headers: this.headers});
|
return this.http.get<TreeNode[]>(`${this.url}/Tv/trending/tree`, {headers: this.headers});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,43 +151,91 @@ namespace Ombi.Controllers
|
||||||
return await TvEngine.GetShowInformation(tvdbId);
|
return await TvEngine.GetShowInformation(tvdbId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns Popular Tv Shows
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("tv/popular/tree")]
|
||||||
|
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> PopularTvTree()
|
||||||
|
{
|
||||||
|
return await TvEngine.PopularTree();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns Popular Tv Shows
|
/// Returns Popular 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>
|
||||||
[HttpGet("tv/popular")]
|
[HttpGet("tv/popular")]
|
||||||
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> PopularTv()
|
public async Task<IEnumerable<SearchTvShowViewModel>> PopularTv()
|
||||||
{
|
{
|
||||||
return await TvEngine.Popular();
|
return await TvEngine.Popular();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns most Anticiplateds tv shows.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("tv/anticipated/tree")]
|
||||||
|
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> AnticipatedTvTree()
|
||||||
|
{
|
||||||
|
return await TvEngine.AnticipatedTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns most Anticiplateds tv shows.
|
/// Returns most Anticiplateds 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>
|
||||||
[HttpGet("tv/anticipated")]
|
[HttpGet("tv/anticipated")]
|
||||||
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> AnticiplatedTv()
|
public async Task<IEnumerable<SearchTvShowViewModel>> AnticipatedTv()
|
||||||
{
|
{
|
||||||
return await TvEngine.Anticipated();
|
return await TvEngine.Anticipated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns Most watched shows.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("tv/mostwatched/tree")]
|
||||||
|
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> MostWatchedTree()
|
||||||
|
{
|
||||||
|
return await TvEngine.MostWatchesTree();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns Most watched shows.
|
/// Returns Most watched 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>
|
||||||
[HttpGet("tv/mostwatched")]
|
[HttpGet("tv/mostwatched")]
|
||||||
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> MostWatched()
|
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatched()
|
||||||
{
|
{
|
||||||
return await TvEngine.MostWatches();
|
return await TvEngine.MostWatches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns trending shows
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("tv/trending/tree")]
|
||||||
|
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> TrendingTree()
|
||||||
|
{
|
||||||
|
return await TvEngine.TrendingTree();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns trending shows
|
/// Returns trending 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>
|
||||||
[HttpGet("tv/trending")]
|
[HttpGet("tv/trending")]
|
||||||
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> Trending()
|
public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
|
||||||
{
|
{
|
||||||
return await TvEngine.Trending();
|
return await TvEngine.Trending();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue