mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
TV Request stuff
This commit is contained in:
parent
e0d5b03c7a
commit
e24d305c85
25 changed files with 215 additions and 190 deletions
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;
|
||||||
|
@ -13,7 +14,9 @@ namespace Ombi.Core.Models.Requests
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +37,9 @@ namespace Ombi.Core.Models.Requests
|
||||||
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);
|
||||||
|
|
||||||
|
if (blob == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -46,33 +51,7 @@ namespace Ombi.Core.Models.Requests
|
||||||
public async Task<T> CheckRequestAsync(int providerId)
|
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.ProviderId == providerId); if (blob == null)
|
var blob = blobs.FirstOrDefault(x => x.ProviderId == providerId && x.Type == RequestType); 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;
|
|
||||||
}
|
|
||||||
var model = ByteConverterHelper.ReturnObject<T>(blob.Content);
|
|
||||||
model.Id = blob.Id;
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<T> CheckRequestAsync(string musicId)
|
|
||||||
{
|
|
||||||
var blobs = await Repo.GetAllAsync().ConfigureAwait(false);
|
|
||||||
var blob = blobs.FirstOrDefault(x => x.MusicId == musicId);
|
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
9
Ombi/Ombi.Helpers/LoggingEvents.cs
Normal file
9
Ombi/Ombi.Helpers/LoggingEvents.cs
Normal file
|
@ -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">
|
||||||
|
|
|
@ -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">
|
||||||
|
@ -39,9 +44,11 @@
|
||||||
<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><span *ngIf="result.status" class="label label-primary" style="font-size:60%" target="_blank">{{result.status}}</span>
|
</a>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
|
@ -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…
Add table
Add a link
Reference in a new issue