From fe590004d281f9c6e5ee9cd79abc1e295ff14c54 Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Sun, 1 Jul 2018 20:44:51 +0100 Subject: [PATCH] Fixed collection issues in Emby #2366 --- src/Ombi.Api.Emby/EmbyApi.cs | 8 +++-- src/Ombi.Api.Emby/IEmbyApi.cs | 4 +-- .../Jobs/Emby/EmbyContentSync.cs | 31 ++++++++++--------- src/Ombi/Startup.cs | 2 ++ 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/Ombi.Api.Emby/EmbyApi.cs b/src/Ombi.Api.Emby/EmbyApi.cs index d94a42f90..fcb989094 100644 --- a/src/Ombi.Api.Emby/EmbyApi.cs +++ b/src/Ombi.Api.Emby/EmbyApi.cs @@ -91,12 +91,16 @@ namespace Ombi.Api.Emby request.AddContentHeader("Content-Type", "application/json"); } - public async Task> GetCollection(string mediaId, string apiKey, string userId, string baseUrl) + public async Task> GetCollection(string mediaId, string apiKey, string userId, string baseUrl) { var request = new Request($"emby/users/{userId}/items?parentId={mediaId}", baseUrl, HttpMethod.Get); AddHeaders(request, apiKey); - return await Api.Request>(request); + request.AddQueryString("Fields", "ProviderIds,Overview"); + + request.AddQueryString("VirtualItem", "False"); + + return await Api.Request>(request); } public async Task> GetAllMovies(string apiKey, int startIndex, int count, string userId, string baseUri) diff --git a/src/Ombi.Api.Emby/IEmbyApi.cs b/src/Ombi.Api.Emby/IEmbyApi.cs index 88f14f24f..b4641ea5f 100644 --- a/src/Ombi.Api.Emby/IEmbyApi.cs +++ b/src/Ombi.Api.Emby/IEmbyApi.cs @@ -23,8 +23,8 @@ namespace Ombi.Api.Emby Task> GetAllShows(string apiKey, int startIndex, int count, string userId, string baseUri); - Task> GetCollection(string mediaId, string apiKey, string userId, - string baseUrl); + Task> GetCollection(string mediaId, + string apiKey, string userId, string baseUrl); Task GetSeriesInformation(string mediaId, string apiKey, string userId, string baseUrl); Task GetMovieInformation(string mediaId, string apiKey, string userId, string baseUrl); diff --git a/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs b/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs index 03f61f4e4..3e2e1a2e1 100644 --- a/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs +++ b/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs @@ -79,27 +79,30 @@ namespace Ombi.Schedule.Jobs.Emby 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++; - // Regular movie - await ProcessMovies(movie, mediaToAdd); + var movieInfo = + await _api.GetCollection(movie.Id, server.ApiKey, server.AdministratorId, server.FullUri); + foreach (var item in movieInfo.Items) + { + await ProcessMovies(item, mediaToAdd); + } } - - // Get the next batch - movies = await _api.GetAllMovies(server.ApiKey, processed, 200, server.AdministratorId, server.FullUri); - await _repo.AddRange(mediaToAdd); - mediaToAdd.Clear(); + processed++; + // Regular movie + await ProcessMovies(movie, mediaToAdd); } - 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 var tv = await _api.GetAllShows(server.ApiKey, 0, 200, server.AdministratorId, server.FullUri); var totalTv = tv.TotalRecordCount; diff --git a/src/Ombi/Startup.cs b/src/Ombi/Startup.cs index 7e11cfe0e..9e7b1b290 100644 --- a/src/Ombi/Startup.cs +++ b/src/Ombi/Startup.cs @@ -5,6 +5,7 @@ using AutoMapper.EquivalencyExpression; using Hangfire; using Hangfire.Dashboard; using Hangfire.SQLite; +using Microsoft.ApplicationInsights.Extensibility; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; 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. public IServiceProvider ConfigureServices(IServiceCollection services) { + TelemetryConfiguration.Active.DisableTelemetry = true; // Add framework services. services.AddDbContext();