Fixed collection issues in Emby #2366

pull/2372/head
Jamie Rees 7 years ago
parent 075b336430
commit fe590004d2

@ -91,12 +91,16 @@ namespace Ombi.Api.Emby
request.AddContentHeader("Content-Type", "application/json"); request.AddContentHeader("Content-Type", "application/json");
} }
public async Task<EmbyItemContainer<MovieInformation>> GetCollection(string mediaId, string apiKey, string userId, string baseUrl) public async Task<EmbyItemContainer<EmbyMovie>> GetCollection(string mediaId, string apiKey, string userId, string baseUrl)
{ {
var request = new Request($"emby/users/{userId}/items?parentId={mediaId}", baseUrl, HttpMethod.Get); var request = new Request($"emby/users/{userId}/items?parentId={mediaId}", baseUrl, HttpMethod.Get);
AddHeaders(request, apiKey); AddHeaders(request, apiKey);
return await Api.Request<EmbyItemContainer<MovieInformation>>(request); request.AddQueryString("Fields", "ProviderIds,Overview");
request.AddQueryString("VirtualItem", "False");
return await Api.Request<EmbyItemContainer<EmbyMovie>>(request);
} }
public async Task<EmbyItemContainer<EmbyMovie>> GetAllMovies(string apiKey, int startIndex, int count, string userId, string baseUri) public async Task<EmbyItemContainer<EmbyMovie>> GetAllMovies(string apiKey, int startIndex, int count, string userId, string baseUri)

@ -23,8 +23,8 @@ namespace Ombi.Api.Emby
Task<EmbyItemContainer<EmbySeries>> GetAllShows(string apiKey, int startIndex, int count, string userId, Task<EmbyItemContainer<EmbySeries>> GetAllShows(string apiKey, int startIndex, int count, string userId,
string baseUri); string baseUri);
Task<EmbyItemContainer<MovieInformation>> GetCollection(string mediaId, string apiKey, string userId, Task<EmbyItemContainer<EmbyMovie>> GetCollection(string mediaId,
string baseUrl); string apiKey, string userId, string baseUrl);
Task<SeriesInformation> GetSeriesInformation(string mediaId, string apiKey, string userId, string baseUrl); Task<SeriesInformation> GetSeriesInformation(string mediaId, string apiKey, string userId, string baseUrl);
Task<MovieInformation> GetMovieInformation(string mediaId, string apiKey, string userId, string baseUrl); Task<MovieInformation> GetMovieInformation(string mediaId, string apiKey, string userId, string baseUrl);

@ -79,27 +79,30 @@ namespace Ombi.Schedule.Jobs.Emby
while (processed < totalCount) while (processed < totalCount)
{ {
try foreach (var movie in movies.Items)
{ {
foreach (var movie in movies.Items) if (movie.Type.Equals("boxset", StringComparison.CurrentCultureIgnoreCase) && mediaToAdd.All(x => x.EmbyId != movie.Id))
{ {
processed++; var movieInfo =
// Regular movie await _api.GetCollection(movie.Id, server.ApiKey, server.AdministratorId, server.FullUri);
await ProcessMovies(movie, mediaToAdd); foreach (var item in movieInfo.Items)
{
await ProcessMovies(item, mediaToAdd);
}
} }
processed++;
// Get the next batch // Regular movie
movies = await _api.GetAllMovies(server.ApiKey, processed, 200, server.AdministratorId, server.FullUri); await ProcessMovies(movie, mediaToAdd);
await _repo.AddRange(mediaToAdd);
mediaToAdd.Clear();
} }
catch (Exception)
{
throw; // Get the next batch
} movies = await _api.GetAllMovies(server.ApiKey, processed, 200, server.AdministratorId, server.FullUri);
await _repo.AddRange(mediaToAdd);
mediaToAdd.Clear();
} }
// TV Time // TV Time
var tv = await _api.GetAllShows(server.ApiKey, 0, 200, server.AdministratorId, server.FullUri); var tv = await _api.GetAllShows(server.ApiKey, 0, 200, server.AdministratorId, server.FullUri);
var totalTv = tv.TotalRecordCount; var totalTv = tv.TotalRecordCount;

@ -5,6 +5,7 @@ using AutoMapper.EquivalencyExpression;
using Hangfire; using Hangfire;
using Hangfire.Dashboard; using Hangfire.Dashboard;
using Hangfire.SQLite; using Hangfire.SQLite;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.HttpOverrides;
@ -78,6 +79,7 @@ namespace Ombi
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public IServiceProvider ConfigureServices(IServiceCollection services) public IServiceProvider ConfigureServices(IServiceCollection services)
{ {
TelemetryConfiguration.Active.DisableTelemetry = true;
// Add framework services. // Add framework services.
services.AddDbContext<OmbiContext>(); services.AddDbContext<OmbiContext>();

Loading…
Cancel
Save