mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 10:36:54 -07:00
Added the TraktApi back
This commit is contained in:
parent
179280a282
commit
e0d5b03c7a
10 changed files with 127 additions and 109 deletions
BIN
Ombi/Assemblies/TraktApiSharp.dll
Normal file
BIN
Ombi/Assemblies/TraktApiSharp.dll
Normal file
Binary file not shown.
|
@ -1,16 +1,16 @@
|
|||
//using System.Collections.Generic;
|
||||
//using System.Threading.Tasks;
|
||||
//using TraktApiSharp.Enums;
|
||||
//using TraktApiSharp.Objects.Get.Shows;
|
||||
//using TraktApiSharp.Objects.Get.Shows.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TraktApiSharp.Enums;
|
||||
using TraktApiSharp.Objects.Get.Shows;
|
||||
using TraktApiSharp.Objects.Get.Shows.Common;
|
||||
|
||||
//namespace Ombi.Api.Trakt
|
||||
//{
|
||||
// public interface ITraktApi
|
||||
// {
|
||||
// Task<IEnumerable<TraktMostAnticipatedShow>> GetAnticipatedShows(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<TraktTrendingShow>> GetTrendingShows(int? page = default(int?), int? limitPerPage = default(int?));
|
||||
// }
|
||||
//}
|
||||
namespace Ombi.Api.Trakt
|
||||
{
|
||||
public interface ITraktApi
|
||||
{
|
||||
Task<IEnumerable<TraktMostAnticipatedShow>> GetAnticipatedShows(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<TraktTrendingShow>> GetTrendingShows(int? page = default(int?), int? limitPerPage = default(int?));
|
||||
}
|
||||
}
|
|
@ -9,4 +9,10 @@
|
|||
<ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="TraktApiSharp">
|
||||
<HintPath>..\Assemblies\TraktApiSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,49 +1,49 @@
|
|||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Threading.Tasks;
|
||||
//using Ombi.Helpers;
|
||||
//using TraktApiSharp;
|
||||
//using TraktApiSharp.Enums;
|
||||
//using TraktApiSharp.Objects.Get.Shows;
|
||||
//using TraktApiSharp.Objects.Get.Shows.Common;
|
||||
//using TraktApiSharp.Requests.Parameters;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Helpers;
|
||||
using TraktApiSharp;
|
||||
using TraktApiSharp.Enums;
|
||||
using TraktApiSharp.Objects.Get.Shows;
|
||||
using TraktApiSharp.Objects.Get.Shows.Common;
|
||||
using TraktApiSharp.Requests.Parameters;
|
||||
|
||||
//namespace Ombi.Api.Trakt
|
||||
//{
|
||||
// public class TraktApi : ITraktApi
|
||||
// {
|
||||
// private TraktClient Client { get; }
|
||||
namespace Ombi.Api.Trakt
|
||||
{
|
||||
public class TraktApi : ITraktApi
|
||||
{
|
||||
private TraktClient Client { get; }
|
||||
|
||||
// private static readonly string Encrypted = "MTM0ZTU2ODM1MGY3NDI3NTExZTI1N2E2NTM0MDI2NjYwNDgwY2Y5YjkzYzc3ZjczNzhmMzQwNjAzYjY3MzgxZA==";
|
||||
// private readonly string _apiKey = StringCipher.DecryptString(Encrypted, "ApiKey");
|
||||
// public TraktApi()
|
||||
// {
|
||||
// Client = new TraktClient(_apiKey);
|
||||
// }
|
||||
private static readonly string Encrypted = "MTM0ZTU2ODM1MGY3NDI3NTExZTI1N2E2NTM0MDI2NjYwNDgwY2Y5YjkzYzc3ZjczNzhmMzQwNjAzYjY3MzgxZA==";
|
||||
private readonly string _apiKey = StringCipher.DecryptString(Encrypted, "ApiKey");
|
||||
public TraktApi()
|
||||
{
|
||||
Client = new TraktClient(_apiKey);
|
||||
}
|
||||
|
||||
// public async Task<IEnumerable<TraktShow>> GetPopularShows(int? page = null, int? limitPerPage = null)
|
||||
// {
|
||||
// var popular = await Client.Shows.GetPopularShowsAsync(new TraktExtendedInfo { Full = true }, null, page ?? 1, limitPerPage ?? 10);
|
||||
// return popular.Value;
|
||||
// }
|
||||
public async Task<IEnumerable<TraktShow>> GetPopularShows(int? page = null, int? limitPerPage = null)
|
||||
{
|
||||
var popular = await Client.Shows.GetPopularShowsAsync(new TraktExtendedInfo { Full = true }, null, page ?? 1, limitPerPage ?? 10);
|
||||
return popular.Value;
|
||||
}
|
||||
|
||||
// public async Task<IEnumerable<TraktTrendingShow>> GetTrendingShows(int? page = null, int? limitPerPage = null)
|
||||
// {
|
||||
// var trendingShowsTop10 = await Client.Shows.GetTrendingShowsAsync(new TraktExtendedInfo { Full = true }, null, page ?? 1, limitPerPage ?? 10);
|
||||
// return trendingShowsTop10.Value;
|
||||
// }
|
||||
public async Task<IEnumerable<TraktTrendingShow>> GetTrendingShows(int? page = null, int? limitPerPage = null)
|
||||
{
|
||||
var trendingShowsTop10 = await Client.Shows.GetTrendingShowsAsync(new TraktExtendedInfo { Full = true }, null, page ?? 1, limitPerPage ?? 10);
|
||||
return trendingShowsTop10.Value;
|
||||
}
|
||||
|
||||
// public async Task<IEnumerable<TraktMostAnticipatedShow>> GetAnticipatedShows(int? page = null, int? limitPerPage = null)
|
||||
// {
|
||||
// var anticipatedShows = await Client.Shows.GetMostAnticipatedShowsAsync(new TraktExtendedInfo { Full = true }, null, page ?? 1, limitPerPage ?? 10);
|
||||
// return anticipatedShows.Value;
|
||||
// }
|
||||
public async Task<IEnumerable<TraktMostAnticipatedShow>> GetAnticipatedShows(int? page = null, int? limitPerPage = null)
|
||||
{
|
||||
var anticipatedShows = await Client.Shows.GetMostAnticipatedShowsAsync(new TraktExtendedInfo { Full = true }, null, page ?? 1, limitPerPage ?? 10);
|
||||
return anticipatedShows.Value;
|
||||
}
|
||||
|
||||
// public async Task<IEnumerable<TraktMostWatchedShow>> GetMostWatchesShows(TraktTimePeriod period = null, int? page = null, int? limitPerPage = null)
|
||||
// {
|
||||
// var anticipatedShows = await Client.Shows.GetMostWatchedShowsAsync(period ?? TraktTimePeriod.Monthly, new TraktExtendedInfo { Full = true }, null, page ?? 1, limitPerPage ?? 10);
|
||||
// return anticipatedShows.Value;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
public async Task<IEnumerable<TraktMostWatchedShow>> GetMostWatchesShows(TraktTimePeriod period = null, int? page = null, int? limitPerPage = null)
|
||||
{
|
||||
var anticipatedShows = await Client.Shows.GetMostWatchedShowsAsync(period ?? TraktTimePeriod.Monthly, new TraktExtendedInfo { Full = true }, null, page ?? 1, limitPerPage ?? 10);
|
||||
return anticipatedShows.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ namespace Ombi.Core.Engine
|
|||
public interface ITvSearchEngine
|
||||
{
|
||||
Task<IEnumerable<SearchTvShowViewModel>> Search(string searchTerm);
|
||||
//Task<IEnumerable<SearchTvShowViewModel>> Popular();
|
||||
//Task<IEnumerable<SearchTvShowViewModel>> Anticipated();
|
||||
//Task<IEnumerable<SearchTvShowViewModel>> MostWatches();
|
||||
//Task<IEnumerable<SearchTvShowViewModel>> Trending();
|
||||
Task<IEnumerable<SearchTvShowViewModel>> Popular();
|
||||
Task<IEnumerable<SearchTvShowViewModel>> Anticipated();
|
||||
Task<IEnumerable<SearchTvShowViewModel>> MostWatches();
|
||||
Task<IEnumerable<SearchTvShowViewModel>> Trending();
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ using System.Linq;
|
|||
using System.Security.Principal;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
//using Ombi.Api.Trakt;
|
||||
using Ombi.Api.Trakt;
|
||||
using Ombi.Api.TvMaze;
|
||||
using Ombi.Core.Models.Requests;
|
||||
using Ombi.Core.Models.Search;
|
||||
|
@ -18,21 +18,21 @@ namespace Ombi.Core.Engine
|
|||
{
|
||||
|
||||
public TvSearchEngine(IPrincipal identity, IRequestServiceMain service, ITvMazeApi tvMaze, IMapper mapper, ISettingsService<PlexSettings> plexSettings,
|
||||
ISettingsService<EmbySettings> embySettings/*, ITraktApi trakt*/)
|
||||
ISettingsService<EmbySettings> embySettings, ITraktApi trakt)
|
||||
: base(identity, service)
|
||||
{
|
||||
TvMazeApi = tvMaze;
|
||||
Mapper = mapper;
|
||||
PlexSettings = plexSettings;
|
||||
EmbySettings = embySettings;
|
||||
//TraktApi = trakt;
|
||||
TraktApi = trakt;
|
||||
}
|
||||
|
||||
private ITvMazeApi TvMazeApi { get; }
|
||||
private IMapper Mapper { get; }
|
||||
private ISettingsService<PlexSettings> PlexSettings { get; }
|
||||
private ISettingsService<EmbySettings> EmbySettings { get; }
|
||||
//private ITraktApi TraktApi { get; }
|
||||
private ITraktApi TraktApi { get; }
|
||||
|
||||
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> Search(string searchTerm)
|
||||
|
@ -46,27 +46,27 @@ namespace Ombi.Core.Engine
|
|||
return null;
|
||||
}
|
||||
|
||||
//public async Task<IEnumerable<SearchTvShowViewModel>> Popular()
|
||||
//{
|
||||
// var result = await TraktApi.GetPopularShows();
|
||||
// return await ProcessResults(result);
|
||||
//}
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> Popular()
|
||||
{
|
||||
var result = await TraktApi.GetPopularShows();
|
||||
return await ProcessResults(result);
|
||||
}
|
||||
|
||||
//public async Task<IEnumerable<SearchTvShowViewModel>> Anticipated()
|
||||
//{
|
||||
// var result = await TraktApi.GetAnticipatedShows();
|
||||
// return await ProcessResults(result);
|
||||
//}
|
||||
//public async Task<IEnumerable<SearchTvShowViewModel>> MostWatches()
|
||||
//{
|
||||
// var result = await TraktApi.GetMostWatchesShows();
|
||||
// return await ProcessResults(result);
|
||||
//}
|
||||
//public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
|
||||
//{
|
||||
// var result = await TraktApi.GetTrendingShows();
|
||||
// return await ProcessResults(result);
|
||||
//}
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> Anticipated()
|
||||
{
|
||||
var result = await TraktApi.GetAnticipatedShows();
|
||||
return await ProcessResults(result);
|
||||
}
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatches()
|
||||
{
|
||||
var result = await TraktApi.GetMostWatchesShows();
|
||||
return await ProcessResults(result);
|
||||
}
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
|
||||
{
|
||||
var result = await TraktApi.GetTrendingShows();
|
||||
return await ProcessResults(result);
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<SearchTvShowViewModel>> ProcessResults<T>(IEnumerable<T> items)
|
||||
{
|
||||
|
|
|
@ -26,4 +26,10 @@
|
|||
<ProjectReference Include="..\Ombi.TheMovieDbApi\Ombi.Api.TheMovieDb.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="TraktApiSharp">
|
||||
<HintPath>..\Assemblies\TraktApiSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -65,25 +65,25 @@ namespace Ombi.Controllers
|
|||
return await TvEngine.Search(searchTerm);
|
||||
}
|
||||
|
||||
//[HttpGet("tv/popular")]
|
||||
//public async Task<IEnumerable<SearchTvShowViewModel>> PopularTv()
|
||||
//{
|
||||
// return await TvEngine.Popular();
|
||||
//}
|
||||
//[HttpGet("tv/anticiplated")]
|
||||
//public async Task<IEnumerable<SearchTvShowViewModel>> AnticiplatedTv()
|
||||
//{
|
||||
// return await TvEngine.Anticipated();
|
||||
//}
|
||||
//[HttpGet("tv/mostwatched")]
|
||||
//public async Task<IEnumerable<SearchTvShowViewModel>> MostWatched()
|
||||
//{
|
||||
// return await TvEngine.MostWatches();
|
||||
//}
|
||||
//[HttpGet("tv/trending")]
|
||||
//public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
|
||||
//{
|
||||
// return await TvEngine.Trending();
|
||||
//}
|
||||
[HttpGet("tv/popular")]
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> PopularTv()
|
||||
{
|
||||
return await TvEngine.Popular();
|
||||
}
|
||||
[HttpGet("tv/anticiplated")]
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> AnticiplatedTv()
|
||||
{
|
||||
return await TvEngine.Anticipated();
|
||||
}
|
||||
[HttpGet("tv/mostwatched")]
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatched()
|
||||
{
|
||||
return await TvEngine.MostWatches();
|
||||
}
|
||||
[HttpGet("tv/trending")]
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
|
||||
{
|
||||
return await TvEngine.Trending();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,12 @@
|
|||
<ProjectReference Include="..\Ombi.TheMovieDbApi\Ombi.Api.TheMovieDb.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="TraktApiSharp">
|
||||
<HintPath>..\Assemblies\TraktApiSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="wwwroot\app\interfaces\ISearchMovieResult - Copy.js">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
|
|
|
@ -59,10 +59,10 @@ namespace Ombi
|
|||
// Add framework services.
|
||||
services.AddMvc();
|
||||
services.AddOmbiMappingProfile();
|
||||
services.AddAutoMapper(expression =>
|
||||
{
|
||||
expression.AddCollectionMappers();
|
||||
});
|
||||
//services.AddAutoMapper(expression =>
|
||||
//{
|
||||
// expression.AddCollectionMappers();
|
||||
//});
|
||||
services.RegisterDependencies(); // Ioc and EF
|
||||
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue