TV Request stuff

pull/1425/head
Jamie.Rees 8 years ago
parent e0d5b03c7a
commit e24d305c85

Binary file not shown.

@ -1,16 +1,16 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using TraktApiSharp.Enums; //using TraktApiSharp.Enums;
using TraktApiSharp.Objects.Get.Shows; //using TraktApiSharp.Objects.Get.Shows;
using TraktApiSharp.Objects.Get.Shows.Common; //using TraktApiSharp.Objects.Get.Shows.Common;
namespace Ombi.Api.Trakt namespace Ombi.Api.Trakt
{ {
public interface ITraktApi public interface ITraktApi
{ {
Task<IEnumerable<TraktMostAnticipatedShow>> GetAnticipatedShows(int? page = default(int?), int? limitPerPage = default(int?)); //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<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?));
} }
} }

@ -9,10 +9,4 @@
<ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" /> <ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="TraktApiSharp">
<HintPath>..\Assemblies\TraktApiSharp.dll</HintPath>
</Reference>
</ItemGroup>
</Project> </Project>

@ -1,49 +1,49 @@
using System; //using System;
using System.Collections.Generic; //using System.Collections.Generic;
using System.Threading.Tasks; //using System.Threading.Tasks;
using Ombi.Helpers; //using Ombi.Helpers;
using TraktApiSharp; //using TraktApiSharp;
using TraktApiSharp.Enums; //using TraktApiSharp.Enums;
using TraktApiSharp.Objects.Get.Shows; //using TraktApiSharp.Objects.Get.Shows;
using TraktApiSharp.Objects.Get.Shows.Common; //using TraktApiSharp.Objects.Get.Shows.Common;
using TraktApiSharp.Requests.Parameters; //using TraktApiSharp.Requests.Parameters;
namespace Ombi.Api.Trakt //namespace Ombi.Api.Trakt
{ //{
public class TraktApi : ITraktApi // public class TraktApi : ITraktApi
{ // {
private TraktClient Client { get; } // private TraktClient Client { get; }
private static readonly string Encrypted = "MTM0ZTU2ODM1MGY3NDI3NTExZTI1N2E2NTM0MDI2NjYwNDgwY2Y5YjkzYzc3ZjczNzhmMzQwNjAzYjY3MzgxZA=="; // private static readonly string Encrypted = "MTM0ZTU2ODM1MGY3NDI3NTExZTI1N2E2NTM0MDI2NjYwNDgwY2Y5YjkzYzc3ZjczNzhmMzQwNjAzYjY3MzgxZA==";
private readonly string _apiKey = StringCipher.DecryptString(Encrypted, "ApiKey"); // private readonly string _apiKey = StringCipher.DecryptString(Encrypted, "ApiKey");
public TraktApi() // public TraktApi()
{ // {
Client = new TraktClient(_apiKey); // Client = new TraktClient(_apiKey);
} // }
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 }, null, page ?? 1, limitPerPage ?? 10); // var popular = await Client.Shows.GetPopularShowsAsync(new TraktExtendedInfo { Full = true }, null, page ?? 1, limitPerPage ?? 10);
return popular.Value; // return popular.Value;
} // }
public async Task<IEnumerable<TraktTrendingShow>> GetTrendingShows(int? page = null, int? limitPerPage = null) // 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); // var trendingShowsTop10 = await Client.Shows.GetTrendingShowsAsync(new TraktExtendedInfo { Full = true }, null, page ?? 1, limitPerPage ?? 10);
return trendingShowsTop10.Value; // return trendingShowsTop10.Value;
} // }
public async Task<IEnumerable<TraktMostAnticipatedShow>> GetAnticipatedShows(int? page = null, int? limitPerPage = null) // 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); // var anticipatedShows = await Client.Shows.GetMostAnticipatedShowsAsync(new TraktExtendedInfo { Full = true }, null, page ?? 1, limitPerPage ?? 10);
return anticipatedShows.Value; // return anticipatedShows.Value;
} // }
public async Task<IEnumerable<TraktMostWatchedShow>> GetMostWatchesShows(TraktTimePeriod period = null, int? page = null, int? limitPerPage = null) // 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); // var anticipatedShows = await Client.Shows.GetMostWatchedShowsAsync(period ?? TraktTimePeriod.Monthly, new TraktExtendedInfo { Full = true }, null, page ?? 1, limitPerPage ?? 10);
return anticipatedShows.Value; // return anticipatedShows.Value;
} // }
} // }
} //}

@ -6,6 +6,13 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" /> <ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
<ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
<HintPath>..\..\..\..\..\.nuget\packages\microsoft.extensions.logging.abstractions\1.1.1\lib\netstandard1.1\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -2,19 +2,24 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Ombi.Api.TvMaze.Models; using Ombi.Api.TvMaze.Models;
using Ombi.Helpers;
namespace Ombi.Api.TvMaze namespace Ombi.Api.TvMaze
{ {
public class TvMazeApi : ITvMazeApi public class TvMazeApi : ITvMazeApi
{ {
public TvMazeApi() public TvMazeApi(ILogger<TvMazeApi> logger)
{ {
Api = new Ombi.Api.Api(); Api = new Ombi.Api.Api();
Logger = logger;
//Mapper = mapper; //Mapper = mapper;
} }
private string Uri = "http://api.tvmaze.com"; private string Uri = "http://api.tvmaze.com";
private Api Api { get; } private Api Api { get; }
private ILogger<TvMazeApi> Logger { get; }
public async Task<List<TvMazeSearch>> Search(string searchTerm) public async Task<List<TvMazeSearch>> Search(string searchTerm)
{ {
var request = new Request("search/shows", Uri, HttpMethod.Get); var request = new Request("search/shows", Uri, HttpMethod.Get);
@ -28,7 +33,7 @@ namespace Ombi.Api.TvMaze
public async Task<TvMazeShow> ShowLookup(int showId) public async Task<TvMazeShow> ShowLookup(int showId)
{ {
var request = new Request($"shows/{showId}", Uri, HttpMethod.Get); var request = new Request($"shows/{showId}", Uri, HttpMethod.Get);
request.AddHeader("Content-Type", "application/json"); request.AddContentHeader("Content-Type", "application/json");
return await Api.Request<TvMazeShow>(request); return await Api.Request<TvMazeShow>(request);
} }
@ -38,7 +43,7 @@ namespace Ombi.Api.TvMaze
var request = new Request($"shows/{showId}/episodes", Uri, HttpMethod.Get); var request = new Request($"shows/{showId}/episodes", Uri, HttpMethod.Get);
request.AddHeader("Content-Type", "application/json"); request.AddContentHeader("Content-Type", "application/json");
return await Api.Request<List<TvMazeEpisodes>>(request); return await Api.Request<List<TvMazeEpisodes>>(request);
} }
@ -46,7 +51,7 @@ namespace Ombi.Api.TvMaze
public async Task<TvMazeShow> ShowLookupByTheTvDbId(int theTvDbId) public async Task<TvMazeShow> ShowLookupByTheTvDbId(int theTvDbId)
{ {
var request = new Request($"lookup/shows?thetvdb={theTvDbId}", Uri, HttpMethod.Get); var request = new Request($"lookup/shows?thetvdb={theTvDbId}", Uri, HttpMethod.Get);
request.AddHeader("Content-Type", "application/json"); request.AddContentHeader("Content-Type", "application/json");
try try
{ {
var obj = await Api.Request<TvMazeShow>(request); var obj = await Api.Request<TvMazeShow>(request);
@ -66,7 +71,7 @@ namespace Ombi.Api.TvMaze
} }
catch (Exception e) catch (Exception e)
{ {
// TODO Logger.LogError(LoggingEvents.ApiException, e, "Exception when calling ShowLookupByTheTvDbId with id:{0}",theTvDbId);
return null; return null;
} }
} }
@ -75,7 +80,7 @@ namespace Ombi.Api.TvMaze
{ {
var request = new Request($"shows/{id}/seasons", Uri, HttpMethod.Get); var request = new Request($"shows/{id}/seasons", Uri, HttpMethod.Get);
request.AddHeader("Content-Type", "application/json"); request.AddContentHeader("Content-Type", "application/json");
return await Api.Request<List<TvMazeSeasons>>(request); return await Api.Request<List<TvMazeSeasons>>(request);
} }

@ -7,9 +7,9 @@ namespace Ombi.Core.Engine
public interface ITvSearchEngine public interface ITvSearchEngine
{ {
Task<IEnumerable<SearchTvShowViewModel>> Search(string searchTerm); Task<IEnumerable<SearchTvShowViewModel>> Search(string searchTerm);
Task<IEnumerable<SearchTvShowViewModel>> Popular(); //Task<IEnumerable<SearchTvShowViewModel>> Popular();
Task<IEnumerable<SearchTvShowViewModel>> Anticipated(); //Task<IEnumerable<SearchTvShowViewModel>> Anticipated();
Task<IEnumerable<SearchTvShowViewModel>> MostWatches(); //Task<IEnumerable<SearchTvShowViewModel>> MostWatches();
Task<IEnumerable<SearchTvShowViewModel>> Trending(); //Task<IEnumerable<SearchTvShowViewModel>> Trending();
} }
} }

@ -35,6 +35,7 @@ namespace Ombi.Core.Engine
var posterPath = showInfo.image?.medium.Replace("http:", "https:"); var posterPath = showInfo.image?.medium.Replace("http:", "https:");
var model = new TvRequestModel var model = new TvRequestModel
{ {
Id = tv.Id,
Type = RequestType.TvShow, Type = RequestType.TvShow,
Overview = showInfo.summary.RemoveHtml(), Overview = showInfo.summary.RemoveHtml(),
PosterPath = posterPath, PosterPath = posterPath,

@ -18,21 +18,21 @@ namespace Ombi.Core.Engine
{ {
public TvSearchEngine(IPrincipal identity, IRequestServiceMain service, ITvMazeApi tvMaze, IMapper mapper, ISettingsService<PlexSettings> plexSettings, public TvSearchEngine(IPrincipal identity, IRequestServiceMain service, ITvMazeApi tvMaze, IMapper mapper, ISettingsService<PlexSettings> plexSettings,
ISettingsService<EmbySettings> embySettings, ITraktApi trakt) ISettingsService<EmbySettings> embySettings)
: base(identity, service) : base(identity, service)
{ {
TvMazeApi = tvMaze; TvMazeApi = tvMaze;
Mapper = mapper; Mapper = mapper;
PlexSettings = plexSettings; PlexSettings = plexSettings;
EmbySettings = embySettings; EmbySettings = embySettings;
TraktApi = trakt; //TraktApi = trakt;
} }
private ITvMazeApi TvMazeApi { get; } private ITvMazeApi TvMazeApi { get; }
private IMapper Mapper { get; } private IMapper Mapper { get; }
private ISettingsService<PlexSettings> PlexSettings { get; } private ISettingsService<PlexSettings> PlexSettings { get; }
private ISettingsService<EmbySettings> EmbySettings { get; } private ISettingsService<EmbySettings> EmbySettings { get; }
private ITraktApi TraktApi { get; } //private ITraktApi TraktApi { get; }
public async Task<IEnumerable<SearchTvShowViewModel>> Search(string searchTerm) public async Task<IEnumerable<SearchTvShowViewModel>> Search(string searchTerm)
@ -46,27 +46,27 @@ namespace Ombi.Core.Engine
return null; return null;
} }
public async Task<IEnumerable<SearchTvShowViewModel>> Popular() //public async Task<IEnumerable<SearchTvShowViewModel>> Popular()
{ //{
var result = await TraktApi.GetPopularShows(); // var result = await TraktApi.GetPopularShows();
return await ProcessResults(result); // return await ProcessResults(result);
} //}
public async Task<IEnumerable<SearchTvShowViewModel>> Anticipated() //public async Task<IEnumerable<SearchTvShowViewModel>> Anticipated()
{ //{
var result = await TraktApi.GetAnticipatedShows(); // var result = await TraktApi.GetAnticipatedShows();
return await ProcessResults(result); // return await ProcessResults(result);
} //}
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatches() //public async Task<IEnumerable<SearchTvShowViewModel>> MostWatches()
{ //{
var result = await TraktApi.GetMostWatchesShows(); // var result = await TraktApi.GetMostWatchesShows();
return await ProcessResults(result); // return await ProcessResults(result);
} //}
public async Task<IEnumerable<SearchTvShowViewModel>> Trending() //public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
{ //{
var result = await TraktApi.GetTrendingShows(); // var result = await TraktApi.GetTrendingShows();
return await ProcessResults(result); // return await ProcessResults(result);
} //}
private async Task<IEnumerable<SearchTvShowViewModel>> ProcessResults<T>(IEnumerable<T> items) private async Task<IEnumerable<SearchTvShowViewModel>> ProcessResults<T>(IEnumerable<T> items)
{ {

@ -12,9 +12,7 @@ namespace Ombi.Core.Requests.Models
void BatchDelete(IEnumerable<T> model); void BatchDelete(IEnumerable<T> model);
void BatchUpdate(IEnumerable<T> model); void BatchUpdate(IEnumerable<T> model);
T CheckRequest(int providerId); T CheckRequest(int providerId);
T CheckRequest(string musicId);
Task<T> CheckRequestAsync(int providerId); Task<T> CheckRequestAsync(int providerId);
Task<T> CheckRequestAsync(string musicId);
void DeleteRequest(T request); void DeleteRequest(T request);
Task DeleteRequestAsync(int request); Task DeleteRequestAsync(int request);
Task DeleteRequestAsync(T request); Task DeleteRequestAsync(T request);

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks; using System.Threading.Tasks;
using Ombi.Core.Requests.Models; using Ombi.Core.Requests.Models;
using Ombi.Helpers; using Ombi.Helpers;
@ -8,12 +9,14 @@ using Ombi.Store.Repository;
namespace Ombi.Core.Models.Requests namespace Ombi.Core.Models.Requests
{ {
public class JsonRequestService<T> : IRequestService<T> where T:BaseRequestModel public class JsonRequestService<T> : IRequestService<T> where T : BaseRequestModel
{ {
public JsonRequestService(IRequestRepository repo) public JsonRequestService(IRequestRepository repo)
{ {
Repo = repo; Repo = repo;
RequestType = typeof(T) == typeof(TvRequestModel) ? RequestType.TvShow : RequestType.Movie;
} }
private RequestType RequestType { get; }
private IRequestRepository Repo { get; } private IRequestRepository Repo { get; }
public int AddRequest(T model) public int AddRequest(T model)
{ {
@ -28,37 +31,15 @@ namespace Ombi.Core.Models.Requests
var entity = new RequestBlobs { Type = model.Type, Content = ByteConverterHelper.ReturnBytes(model), ProviderId = model.ProviderId }; var entity = new RequestBlobs { Type = model.Type, Content = ByteConverterHelper.ReturnBytes(model), ProviderId = model.ProviderId };
var id = await Repo.InsertAsync(entity).ConfigureAwait(false); var id = await Repo.InsertAsync(entity).ConfigureAwait(false);
return id.Id; return id.Id;
} }
public T CheckRequest(int providerId) public T CheckRequest(int providerId)
{ {
var blobs = Repo.GetAll(); var blobs = Repo.GetAll();
var blob = blobs.FirstOrDefault(x => x.ProviderId == providerId); if (blob == null) var blob = blobs.FirstOrDefault(x => x.ProviderId == providerId && x.Type == RequestType);
{
return null;
}
var model = ByteConverterHelper.ReturnObject<T>(blob.Content);
model.Id = blob.Id;
return model;
}
public async Task<T> CheckRequestAsync(int providerId) if (blob == null)
{
var blobs = await Repo.GetAllAsync().ConfigureAwait(false);
var blob = blobs.FirstOrDefault(x => x.ProviderId == providerId); if (blob == null)
{
return null;
}
var model = ByteConverterHelper.ReturnObject<T>(blob.Content);
model.Id = blob.Id;
return model;
}
public T CheckRequest(string musicId)
{
var blobs = Repo.GetAll();
var blob = blobs.FirstOrDefault(x => x.MusicId == musicId); if (blob == null)
{ {
return null; return null;
} }
@ -67,12 +48,10 @@ namespace Ombi.Core.Models.Requests
return model; return model;
} }
public async Task<T> CheckRequestAsync(string musicId) public async Task<T> CheckRequestAsync(int providerId)
{ {
var blobs = await Repo.GetAllAsync().ConfigureAwait(false); var blobs = await Repo.GetAllAsync().ConfigureAwait(false);
var blob = blobs.FirstOrDefault(x => x.MusicId == musicId); var blob = blobs.FirstOrDefault(x => x.ProviderId == providerId && x.Type == RequestType); if (blob == null)
if (blob == null)
{ {
return null; return null;
} }
@ -133,7 +112,7 @@ namespace Ombi.Core.Models.Requests
public IEnumerable<T> GetAll() public IEnumerable<T> GetAll()
{ {
var blobs = Repo.GetAll().ToList(); var blobs = Repo.GetAll().Where(x => x.Type == RequestType).ToList();
var retVal = new List<T>(); var retVal = new List<T>();
foreach (var b in blobs) foreach (var b in blobs)
@ -154,7 +133,7 @@ namespace Ombi.Core.Models.Requests
var blobs = await Repo.GetAllAsync().ConfigureAwait(false); var blobs = await Repo.GetAllAsync().ConfigureAwait(false);
var retVal = new List<T>(); var retVal = new List<T>();
foreach (var b in blobs) foreach (var b in blobs.Where(x => x.Type == RequestType))
{ {
if (b == null) if (b == null)
{ {
@ -172,7 +151,7 @@ namespace Ombi.Core.Models.Requests
var blobs = await Repo.GetAllAsync(count, position).ConfigureAwait(false); var blobs = await Repo.GetAllAsync(count, position).ConfigureAwait(false);
var retVal = new List<T>(); var retVal = new List<T>();
foreach (var b in blobs) foreach (var b in blobs.Where(x => x.Type == RequestType))
{ {
if (b == null) if (b == null)
{ {

@ -26,10 +26,4 @@
<ProjectReference Include="..\Ombi.TheMovieDbApi\Ombi.Api.TheMovieDb.csproj" /> <ProjectReference Include="..\Ombi.TheMovieDbApi\Ombi.Api.TheMovieDb.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="TraktApiSharp">
<HintPath>..\Assemblies\TraktApiSharp.dll</HintPath>
</Reference>
</ItemGroup>
</Project> </Project>

@ -10,7 +10,6 @@ using Ombi.Api.Emby;
using Ombi.Api.Plex; using Ombi.Api.Plex;
using Ombi.Api.Sonarr; using Ombi.Api.Sonarr;
using Ombi.Api.TheMovieDb; using Ombi.Api.TheMovieDb;
//using Ombi.Api.Trakt;
using Ombi.Api.TvMaze; using Ombi.Api.TvMaze;
using Ombi.Core; using Ombi.Core;
using Ombi.Core.Engine; using Ombi.Core.Engine;
@ -59,7 +58,6 @@ namespace Ombi.DependencyInjection
services.AddTransient<IEmbyApi, EmbyApi>(); services.AddTransient<IEmbyApi, EmbyApi>();
services.AddTransient<ISonarrApi, SonarrApi>(); services.AddTransient<ISonarrApi, SonarrApi>();
services.AddTransient<ITvMazeApi, TvMazeApi>(); services.AddTransient<ITvMazeApi, TvMazeApi>();
//services.AddTransient<ITraktApi, TraktApi>();
return services; return services;
} }

@ -0,0 +1,9 @@
using Microsoft.Extensions.Logging;
namespace Ombi.Helpers
{
public class LoggingEvents
{
public static EventId ApiException => new EventId(1000);
}
}

@ -10,4 +10,10 @@
<PackageReference Include="System.Security.Claims" Version="4.3.0" /> <PackageReference Include="System.Security.Claims" Version="4.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
<HintPath>..\..\..\..\..\.nuget\packages\microsoft.extensions.logging.abstractions\1.1.1\lib\netstandard1.1\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
</ItemGroup>
</Project> </Project>

@ -65,25 +65,25 @@ namespace Ombi.Controllers
return await TvEngine.Search(searchTerm); return await TvEngine.Search(searchTerm);
} }
[HttpGet("tv/popular")] //[HttpGet("tv/popular")]
public async Task<IEnumerable<SearchTvShowViewModel>> PopularTv() //public async Task<IEnumerable<SearchTvShowViewModel>> PopularTv()
{ //{
return await TvEngine.Popular(); // return await TvEngine.Popular();
} //}
[HttpGet("tv/anticiplated")] //[HttpGet("tv/anticiplated")]
public async Task<IEnumerable<SearchTvShowViewModel>> AnticiplatedTv() //public async Task<IEnumerable<SearchTvShowViewModel>> AnticiplatedTv()
{ //{
return await TvEngine.Anticipated(); // return await TvEngine.Anticipated();
} //}
[HttpGet("tv/mostwatched")] //[HttpGet("tv/mostwatched")]
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatched() //public async Task<IEnumerable<SearchTvShowViewModel>> MostWatched()
{ //{
return await TvEngine.MostWatches(); // return await TvEngine.MostWatches();
} //}
[HttpGet("tv/trending")] //[HttpGet("tv/trending")]
public async Task<IEnumerable<SearchTvShowViewModel>> Trending() //public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
{ //{
return await TvEngine.Trending(); // return await TvEngine.Trending();
} //}
} }
} }

@ -48,12 +48,6 @@
<ProjectReference Include="..\Ombi.TheMovieDbApi\Ombi.Api.TheMovieDb.csproj" /> <ProjectReference Include="..\Ombi.TheMovieDbApi\Ombi.Api.TheMovieDb.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="TraktApiSharp">
<HintPath>..\Assemblies\TraktApiSharp.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup> <ItemGroup>
<Content Update="wwwroot\app\interfaces\ISearchMovieResult - Copy.js"> <Content Update="wwwroot\app\interfaces\ISearchMovieResult - Copy.js">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>

@ -6,7 +6,7 @@ enum envs {
live = 2 live = 2
} }
var envVar = '0'; var envVar = '{something}';
var env = envs.local; var env = envs.local;
if (envs[envVar]) { if (envs[envVar]) {
env = envs[envVar]; env = envs[envVar];

@ -17,8 +17,7 @@
<div class="row"> <div class="row">
<div class="col-sm-2"> <div class="col-sm-2">
<img *ngIf="request.type == 1" class="img-responsive" src="https://image.tmdb.org/t/p/w150/{{request.posterPath}}" alt="poster"> <img class="img-responsive" src="https://image.tmdb.org/t/p/w150/{{request.posterPath}}" alt="poster">
<img *ngIf="request.type == 2" class="img-responsive" src="https://image.tmdb.org/t/p/w150/{{request.posterPath}}" alt="poster">
</div> </div>

@ -17,8 +17,7 @@
<div class="row"> <div class="row">
<div class="col-sm-2"> <div class="col-sm-2">
<img *ngIf="request.type == 1" class="img-responsive" src="https://image.tmdb.org/t/p/w150/{{request.posterPath}}" alt="poster"> <img class="img-responsive" src="{{request.posterPath}}" alt="poster">
<img *ngIf="request.type == 2" class="img-responsive" src="https://image.tmdb.org/t/p/w150/{{request.posterPath}}" alt="poster">
</div> </div>
@ -75,6 +74,30 @@
@UI.Issues_Issue: <a href="@formAction/issues/{{issueId}}"><i class="fa fa-check"></i></a> @UI.Issues_Issue: <a href="@formAction/issues/{{issueId}}"><i class="fa fa-check"></i></a>
{{/if_eq}} {{/if_eq}}
</div>--> </div>-->
<!--Child Requests-->
<div *ngIf="request.hasChildRequests">
<button type="button" class="btn btn-info" data-toggle="collapse" [attr.data-target]="'#' + request.id +'childRequests'">Children</button>
<div id="{{request.id}}childRequests" class="collapse">
<div *ngFor="let child of request.childRequests">
<hr/>
<div *ngIf="request.requestedUsers">Requested By: <span *ngFor="let user of request.requestedUsers">{{user}} </span></div>
<div>
<span>Request status: </span>
<span *ngIf="request.available" class="label label-success">Available</span>
<span *ngIf="request.approved && !request.available" class="label label-info">Processing Request</span>
<span *ngIf="request.denied" class="label label-danger">Request Denied</span>
<span *ngIf="request.deniedReason" title="{{request.deniedReason}}"><i class="fa fa-info-circle"></i></span>
<span *ngIf="!request.approved && !request.availble && !request.denied" class="label label-warning">Pending Approval</span>
</div>
</div>
</div>
</div>
</div> </div>
<div class="col-sm-3 col-sm-push-3"> <div class="col-sm-3 col-sm-push-3">
<div *ngIf="isAdmin"> <div *ngIf="isAdmin">

@ -91,7 +91,9 @@ export class TvRequestsComponent implements OnInit {
} }
private loadInit() { private loadInit() {
this.requestService.getTvRequests(this.amountToLoad, 0).subscribe(x => this.tvRequests = x); this.requestService.getTvRequests(this.amountToLoad, 0).subscribe(x => {
this.tvRequests = x;
});
this.isAdmin = this.identityService.hasRole("Admin"); this.isAdmin = this.identityService.hasRole("Admin");
} }

@ -22,6 +22,10 @@
<br /> <br />
<!-- Movie content --> <!-- Movie content -->
<div id="movieList"> <div id="movieList">
<div *ngIf="searchApplied && movieResults?.length <= 0" class='no-search-results'>
<i class='fa fa-film no-search-results-icon'></i><div class='no-search-results-text'>Sorry, we didn't find any results!</div>
</div>
<div *ngFor="let result of movieResults"> <div *ngFor="let result of movieResults">
<div class="row"> <div class="row">
<div id="{{id}}imgDiv" class="col-sm-2"> <div id="{{id}}imgDiv" class="col-sm-2">
@ -61,22 +65,22 @@
<a *ngIf="result.trailer" href="{{result.trailer}}" target="_blank"><span class="label label-info">Trailer</span></a> <a *ngIf="result.trailer" href="{{result.trailer}}" target="_blank"><span class="label label-info">Trailer</span></a>
<br /> <br/>
<br /> <br/>
</div> </div>
<p style="font-size:0.9rem !important">{{result.overview}}</p> <p style="font-size: 0.9rem !important">{{result.overview}}</p>
</div> </div>
<div class="col-sm-2"> <div class="col-sm-2">
<input name="{{type}}Id" type="text" value="{{result.id}}" hidden="hidden" /> <input name="{{type}}Id" type="text" value="{{result.id}}" hidden="hidden"/>
<div *ngIf="result.available"> <div *ngIf="result.available">
<button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> Available</button> <button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> Available</button>
<div *ngIf="result.url"> <div *ngIf="result.url">
<br /> <br/>
<br /> <br/>
<a style="text-align: right" class="btn btn-sm btn-primary-outline" href="{{result.url}}" target="_blank"><i class="fa fa-eye"></i> View In Plex</a> <a style="text-align: right" class="btn btn-sm btn-primary-outline" href="{{result.url}}" target="_blank"><i class="fa fa-eye"></i> View In Plex</a>
</div> </div>
@ -92,7 +96,7 @@
<!--{{#if_eq type "tv"}} <!--{{#if_eq type "tv"}}
{{#if_eq tvFullyAvailable true}} {{#if_eq tvFullyAvailable true}}
@*//TODO Not used yet*@ @*//TODO Not used yet*@
<button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> @UI.Search_Available</button><br /> <button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> @UI.Search_Available</button><br/>
{{else}} {{else}}
{{#if_eq enableTvRequestsForOnlySeries true}} {{#if_eq enableTvRequestsForOnlySeries true}}
<button id="{{id}}" style="text-align: right" class="btn {{#if available}}btn-success-outline{{else}}btn-primary-outline dropdownTv{{/if}} btn-primary-outline" season-select="0" type="button" {{#if available}} disabled{{/if}}><i class="fa fa-plus"></i> {{#if available}}@UI.Search_Available{{else}}@UI.Search_Request{{/if}}</button> <button id="{{id}}" style="text-align: right" class="btn {{#if available}}btn-success-outline{{else}}btn-primary-outline dropdownTv{{/if}} btn-primary-outline" season-select="0" type="button" {{#if available}} disabled{{/if}}><i class="fa fa-plus"></i> {{#if available}}@UI.Search_Available{{else}}@UI.Search_Request{{/if}}</button>
@ -117,7 +121,7 @@
{{/if_eq}} {{/if_eq}}
{{#if available}} {{#if available}}
{{#if url}} {{#if url}}
<br /> <br/>
<a style="text-align: right" class="btn btn-sm btn-primary-outline" href="{{url}}" target="_blank"><i class="fa fa-eye"></i> @UI.Search_ViewInPlex</a> <a style="text-align: right" class="btn btn-sm btn-primary-outline" href="{{url}}" target="_blank"><i class="fa fa-eye"></i> @UI.Search_ViewInPlex</a>
{{/if}} {{/if}}
{{/if}} {{/if}}
@ -125,10 +129,10 @@
{{/if_eq}}--> {{/if_eq}}-->
<br /> <br/>
<div *ngIf="result.available"> <div *ngIf="result.available">
<input name="providerId" type="text" value="{{id}}" hidden="hidden" /> <input name="providerId" type="text" value="{{id}}" hidden="hidden"/>
<input name="type" type="text" value="{{type}}" hidden="hidden" /> <input name="type" type="text" value="{{type}}" hidden="hidden"/>
<div class="dropdown"> <div class="dropdown">
<button class="btn btn-sm btn-danger-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> <button class="btn btn-sm btn-danger-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="fa fa-exclamation"></i> @UI.Search_ReportIssue <i class="fa fa-exclamation"></i> @UI.Search_ReportIssue
@ -147,7 +151,7 @@
</div> </div>
</div> </div>
<hr /> <hr/>
</div> </div>
</div> </div>

@ -22,6 +22,7 @@ export class MovieSearchComponent implements OnInit {
searchChanged: Subject<string> = new Subject<string>(); searchChanged: Subject<string> = new Subject<string>();
movieResults: ISearchMovieResult[]; movieResults: ISearchMovieResult[];
result: IRequestEngineResult; result: IRequestEngineResult;
searchApplied = false;
constructor(private searchService: SearchService, private requestService: RequestService, private notificationService: NotificationService) { constructor(private searchService: SearchService, private requestService: RequestService, private notificationService: NotificationService) {
this.searchChanged this.searchChanged
@ -35,7 +36,7 @@ export class MovieSearchComponent implements OnInit {
} }
this.searchService.searchMovie(this.searchText).subscribe(x => { this.searchService.searchMovie(this.searchText).subscribe(x => {
this.movieResults = x; this.movieResults = x;
this.searchApplied = true;
// Now let's load some exta info including IMDBId // Now let's load some exta info including IMDBId
// This way the search is fast at displaying results. // This way the search is fast at displaying results.
this.getExtaInfo(); this.getExtaInfo();
@ -105,6 +106,7 @@ export class MovieSearchComponent implements OnInit {
private clearResults() { private clearResults() {
this.movieResults = []; this.movieResults = [];
this.searchApplied = false;
} }
} }

@ -28,6 +28,11 @@
<br /> <br />
<!-- TV content --> <!-- TV content -->
<div id="tvList"> <div id="tvList">
<div *ngIf="searchApplied && tvResults?.length <= 0" class='no-search-results'>
<i class='fa fa-film no-search-results-icon'></i><div class='no-search-results-text'>Sorry, we didn't find any results!</div>
</div>
<div *ngFor="let result of tvResults"> <div *ngFor="let result of tvResults">
<div class="row"> <div class="row">
<div class="col-sm-2"> <div class="col-sm-2">
@ -37,11 +42,13 @@
</div> </div>
<div class="col-sm-8"> <div class="col-sm-8">
<div> <div>
<a href="http://www.imdb.com/title/{{result.imdbId}}/" target="_blank"> <a href="http://www.imdb.com/title/{{result.imdbId}}/" target="_blank">
{{result.seriesName}} ({{result.firstAired}}) <h4>{{result.seriesName}} ({{result.firstAired}})</h4>
</a>
</a><span *ngIf="result.status" class="label label-primary" style="font-size:60%" target="_blank">{{result.status}}</span> <span *ngIf="result.status" class="label label-primary" style="font-size: 60%" target="_blank">{{result.status}}</span>
<span *ngIf="result.firstAired" class="label label-info" target="_blank">Air Date: {{result.firstAired}}</span> <span *ngIf="result.firstAired" class="label label-info" target="_blank">Air Date: {{result.firstAired}}</span>
@ -71,19 +78,19 @@
<br/> <br/>
<br/> <br/>
</div> </div>
<p style="font-size:0.9rem !important">{{result.overview}}</p> <p style="font-size: 0.9rem !important">{{result.overview}}</p>
</div> </div>
<div class="col-sm-2"> <div class="col-sm-2">
<input name="{{type}}Id" type="text" value="{{result.id}}" hidden="hidden" /> <input name="{{type}}Id" type="text" value="{{result.id}}" hidden="hidden"/>
<div *ngIf="result.available"> <div *ngIf="result.available">
<button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> Available</button> <button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> Available</button>
<div *ngIf="result.url"> <div *ngIf="result.url">
<br /> <br/>
<br /> <br/>
<a style="text-align: right" class="btn btn-sm btn-primary-outline" href="{{result.url}}" target="_blank"><i class="fa fa-eye"></i> View In Plex</a> <a style="text-align: right" class="btn btn-sm btn-primary-outline" href="{{result.url}}" target="_blank"><i class="fa fa-eye"></i> View In Plex</a>
</div> </div>
@ -99,7 +106,7 @@
<!--{{#if_eq type "tv"}} <!--{{#if_eq type "tv"}}
{{#if_eq tvFullyAvailable true}} {{#if_eq tvFullyAvailable true}}
@*//TODO Not used yet*@ @*//TODO Not used yet*@
<button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> @UI.Search_Available</button><br /> <button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> @UI.Search_Available</button><br/>
{{else}} {{else}}
{{#if_eq enableTvRequestsForOnlySeries true}} {{#if_eq enableTvRequestsForOnlySeries true}}
<button id="{{id}}" style="text-align: right" class="btn {{#if available}}btn-success-outline{{else}}btn-primary-outline dropdownTv{{/if}} btn-primary-outline" season-select="0" type="button" {{#if available}} disabled{{/if}}><i class="fa fa-plus"></i> {{#if available}}@UI.Search_Available{{else}}@UI.Search_Request{{/if}}</button> <button id="{{id}}" style="text-align: right" class="btn {{#if available}}btn-success-outline{{else}}btn-primary-outline dropdownTv{{/if}} btn-primary-outline" season-select="0" type="button" {{#if available}} disabled{{/if}}><i class="fa fa-plus"></i> {{#if available}}@UI.Search_Available{{else}}@UI.Search_Request{{/if}}</button>
@ -124,7 +131,7 @@
{{/if_eq}} {{/if_eq}}
{{#if available}} {{#if available}}
{{#if url}} {{#if url}}
<br /> <br/>
<a style="text-align: right" class="btn btn-sm btn-primary-outline" href="{{url}}" target="_blank"><i class="fa fa-eye"></i> @UI.Search_ViewInPlex</a> <a style="text-align: right" class="btn btn-sm btn-primary-outline" href="{{url}}" target="_blank"><i class="fa fa-eye"></i> @UI.Search_ViewInPlex</a>
{{/if}} {{/if}}
{{/if}} {{/if}}
@ -132,10 +139,10 @@
{{/if_eq}}--> {{/if_eq}}-->
<br /> <br/>
<div *ngIf="result.available"> <div *ngIf="result.available">
<input name="providerId" type="text" value="{{id}}" hidden="hidden" /> <input name="providerId" type="text" value="{{id}}" hidden="hidden"/>
<input name="type" type="text" value="{{type}}" hidden="hidden" /> <input name="type" type="text" value="{{type}}" hidden="hidden"/>
<div class="dropdown"> <div class="dropdown">
<button class="btn btn-sm btn-danger-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> <button class="btn btn-sm btn-danger-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="fa fa-exclamation"></i> @UI.Search_ReportIssue <i class="fa fa-exclamation"></i> @UI.Search_ReportIssue
@ -154,7 +161,7 @@
</div> </div>
</div> </div>
<hr /> <hr/>
</div> </div>
</div> </div>

@ -22,6 +22,7 @@ export class TvSearchComponent implements OnInit {
searchChanged = new Subject<string>(); searchChanged = new Subject<string>();
tvResults: ISearchTvResult[]; tvResults: ISearchTvResult[];
result: IRequestEngineResult; result: IRequestEngineResult;
searchApplied = false;
constructor(private searchService: SearchService, private requestService: RequestService, private notificationService: NotificationService) { constructor(private searchService: SearchService, private requestService: RequestService, private notificationService: NotificationService) {
this.searchChanged this.searchChanged
@ -35,6 +36,7 @@ export class TvSearchComponent implements OnInit {
} }
this.searchService.searchTv(this.searchText).subscribe(x => { this.searchService.searchTv(this.searchText).subscribe(x => {
this.tvResults = x; this.tvResults = x;
this.searchApplied = true;
}); });
}); });
} }
@ -98,6 +100,7 @@ export class TvSearchComponent implements OnInit {
private clearResults() { private clearResults() {
this.tvResults = []; this.tvResults = [];
this.searchApplied = false;
} }
} }
Loading…
Cancel
Save