diff --git a/src/Ombi.Core/Engine/Interfaces/ITvSearchEngine.cs b/src/Ombi.Core/Engine/Interfaces/ITvSearchEngine.cs index 06a419214..53721f792 100644 --- a/src/Ombi.Core/Engine/Interfaces/ITvSearchEngine.cs +++ b/src/Ombi.Core/Engine/Interfaces/ITvSearchEngine.cs @@ -10,9 +10,13 @@ namespace Ombi.Core.Engine.Interfaces Task>> SearchTreeNode(string searchTerm); Task> GetShowInformationTreeNode(int tvdbid); Task GetShowInformation(int tvdbid); - Task>> Popular(); - Task>> Anticipated(); - Task>> MostWatches(); - Task>> Trending(); + Task>> PopularTree(); + Task> Popular(); + Task>> AnticipatedTree(); + Task> Anticipated(); + Task>> MostWatchesTree(); + Task> MostWatches(); + Task>> TrendingTree(); + Task> Trending(); } } \ No newline at end of file diff --git a/src/Ombi.Core/Engine/TvSearchEngine.cs b/src/Ombi.Core/Engine/TvSearchEngine.cs index 2fc3e6c12..56000d00a 100644 --- a/src/Ombi.Core/Engine/TvSearchEngine.cs +++ b/src/Ombi.Core/Engine/TvSearchEngine.cs @@ -122,33 +122,60 @@ namespace Ombi.Core.Engine return ParseIntoTreeNode(result); } - public async Task>> Popular() + public async Task>> PopularTree() { var result = await MemCache.GetOrAdd(CacheKeys.PopularTv, async () => await TraktApi.GetPopularShows(), DateTime.Now.AddHours(12)); var processed = await ProcessResults(result); return processed.Select(ParseIntoTreeNode).ToList(); } - public async Task>> Anticipated() + public async Task> Popular() + { + var result = await MemCache.GetOrAdd(CacheKeys.PopularTv, async () => await TraktApi.GetPopularShows(), DateTime.Now.AddHours(12)); + var processed = await ProcessResults(result); + return processed; + } + + public async Task>> AnticipatedTree() { var result = await MemCache.GetOrAdd(CacheKeys.AnticipatedTv, async () => await TraktApi.GetAnticipatedShows(), DateTime.Now.AddHours(12)); - var processed= await ProcessResults(result); + var processed = await ProcessResults(result); return processed.Select(ParseIntoTreeNode).ToList(); } + public async Task> 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>> MostWatches() + public async Task>> MostWatchesTree() { var result = await MemCache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(), DateTime.Now.AddHours(12)); var processed = await ProcessResults(result); return processed.Select(ParseIntoTreeNode).ToList(); } + public async Task> 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>> Trending() + public async Task>> TrendingTree() { var result = await MemCache.GetOrAdd(CacheKeys.TrendingTv, async () => await TraktApi.GetTrendingShows(), DateTime.Now.AddHours(12)); var processed = await ProcessResults(result); return processed.Select(ParseIntoTreeNode).ToList(); } + + public async Task> 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 ParseIntoTreeNode(SearchTvShowViewModel result) { return new TreeNode diff --git a/src/Ombi/ClientApp/app/services/search.service.ts b/src/Ombi/ClientApp/app/services/search.service.ts index 859f01240..1cbe70233 100644 --- a/src/Ombi/ClientApp/app/services/search.service.ts +++ b/src/Ombi/ClientApp/app/services/search.service.ts @@ -54,15 +54,15 @@ export class SearchService extends ServiceHelpers { } public popularTv(): Observable { - return this.http.get(`${this.url}/Tv/popular`, {headers: this.headers}); + return this.http.get(`${this.url}/Tv/popular/tree`, {headers: this.headers}); } public mostWatchedTv(): Observable { - return this.http.get(`${this.url}/Tv/mostwatched`, {headers: this.headers}); + return this.http.get(`${this.url}/Tv/mostwatched/tree`, {headers: this.headers}); } public anticipatedTv(): Observable { - return this.http.get(`${this.url}/Tv/anticipated`, {headers: this.headers}); + return this.http.get(`${this.url}/Tv/anticipated/tree`, {headers: this.headers}); } public trendingTv(): Observable { - return this.http.get(`${this.url}/Tv/trending`, {headers: this.headers}); + return this.http.get(`${this.url}/Tv/trending/tree`, {headers: this.headers}); } } diff --git a/src/Ombi/Controllers/SearchController.cs b/src/Ombi/Controllers/SearchController.cs index 1a5d36b50..44a00a656 100644 --- a/src/Ombi/Controllers/SearchController.cs +++ b/src/Ombi/Controllers/SearchController.cs @@ -151,43 +151,91 @@ namespace Ombi.Controllers return await TvEngine.GetShowInformation(tvdbId); } + /// + /// Returns Popular Tv Shows + /// + /// We use Trakt.tv as the Provider + /// + [HttpGet("tv/popular/tree")] + public async Task>> PopularTvTree() + { + return await TvEngine.PopularTree(); + } + /// /// Returns Popular Tv Shows /// /// We use Trakt.tv as the Provider /// [HttpGet("tv/popular")] - public async Task>> PopularTv() + public async Task> PopularTv() { return await TvEngine.Popular(); } + + /// + /// Returns most Anticiplateds tv shows. + /// + /// We use Trakt.tv as the Provider + /// + [HttpGet("tv/anticipated/tree")] + public async Task>> AnticipatedTvTree() + { + return await TvEngine.AnticipatedTree(); + } + + /// /// Returns most Anticiplateds tv shows. /// /// We use Trakt.tv as the Provider /// [HttpGet("tv/anticipated")] - public async Task>> AnticiplatedTv() + public async Task> AnticipatedTv() { return await TvEngine.Anticipated(); } + + /// + /// Returns Most watched shows. + /// + /// We use Trakt.tv as the Provider + /// + [HttpGet("tv/mostwatched/tree")] + public async Task>> MostWatchedTree() + { + return await TvEngine.MostWatchesTree(); + } + /// /// Returns Most watched shows. /// /// We use Trakt.tv as the Provider /// [HttpGet("tv/mostwatched")] - public async Task>> MostWatched() + public async Task> MostWatched() { return await TvEngine.MostWatches(); } + + /// + /// Returns trending shows + /// + /// We use Trakt.tv as the Provider + /// + [HttpGet("tv/trending/tree")] + public async Task>> TrendingTree() + { + return await TvEngine.TrendingTree(); + } + /// /// Returns trending shows /// /// We use Trakt.tv as the Provider /// [HttpGet("tv/trending")] - public async Task>> Trending() + public async Task> Trending() { return await TvEngine.Trending(); }