diff --git a/src/Ombi.Api.Emby/EmbyApi.cs b/src/Ombi.Api.Emby/EmbyApi.cs index 3af6d0dd5..3ac70c844 100644 --- a/src/Ombi.Api.Emby/EmbyApi.cs +++ b/src/Ombi.Api.Emby/EmbyApi.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.Internal; using Newtonsoft.Json; using Ombi.Api.Emby.Models; using Ombi.Api.Emby.Models.Media.Tv; @@ -100,7 +101,7 @@ namespace Ombi.Api.Emby public async Task> GetAllMovies(string apiKey, string userId, string baseUri) { - return await GetAll("Movie", apiKey, userId, baseUri); + return await GetAll("Movie", apiKey, userId, baseUri, true); } public async Task> GetAllEpisodes(string apiKey, string userId, string baseUri) @@ -129,20 +130,22 @@ namespace Ombi.Api.Emby private async Task GetInformation(string mediaId, string apiKey, string userId, string baseUrl) { var request = new Request($"emby/users/{userId}/items/{mediaId}", baseUrl, HttpMethod.Get); + AddHeaders(request, apiKey); var response = await Api.RequestContent(request); return JsonConvert.DeserializeObject(response); } - - - private async Task> GetAll(string type, string apiKey, string userId, string baseUri) + private async Task> GetAll(string type, string apiKey, string userId, string baseUri, bool includeOverview = false) { var request = new Request($"emby/users/{userId}/items", baseUri, HttpMethod.Get); request.AddQueryString("Recursive", true.ToString()); request.AddQueryString("IncludeItemTypes", type); + request.AddQueryString("Fields", includeOverview ? "ProviderIds,Overview" : "ProviderIds"); + + request.AddQueryString("VirtualItem","False"); AddHeaders(request, apiKey); diff --git a/src/Ombi.Api.Emby/Models/Media/Movie/EmbyMovie.cs b/src/Ombi.Api.Emby/Models/Media/Movie/EmbyMovie.cs index 34038edd8..a10ddaae6 100644 --- a/src/Ombi.Api.Emby/Models/Media/Movie/EmbyMovie.cs +++ b/src/Ombi.Api.Emby/Models/Media/Movie/EmbyMovie.cs @@ -28,5 +28,7 @@ namespace Ombi.Api.Emby.Models.Movie public string MediaType { get; set; } public bool HasSubtitles { get; set; } public int CriticRating { get; set; } + public string Overview { get; set; } + public EmbyProviderids ProviderIds { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Api.Emby/Models/Media/Tv/EmbyEpisodes.cs b/src/Ombi.Api.Emby/Models/Media/Tv/EmbyEpisodes.cs index d02c99e41..d76915923 100644 --- a/src/Ombi.Api.Emby/Models/Media/Tv/EmbyEpisodes.cs +++ b/src/Ombi.Api.Emby/Models/Media/Tv/EmbyEpisodes.cs @@ -39,5 +39,6 @@ namespace Ombi.Api.Emby.Models.Media.Tv public string LocationType { get; set; } public string MediaType { get; set; } public bool HasSubtitles { get; set; } + public EmbyProviderids ProviderIds { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Api.Emby/Models/Media/Tv/EmbySeries.cs b/src/Ombi.Api.Emby/Models/Media/Tv/EmbySeries.cs index 853c64d10..2aaf8d492 100644 --- a/src/Ombi.Api.Emby/Models/Media/Tv/EmbySeries.cs +++ b/src/Ombi.Api.Emby/Models/Media/Tv/EmbySeries.cs @@ -26,5 +26,7 @@ namespace Ombi.Api.Emby.Models.Media.Tv public string[] BackdropImageTags { get; set; } public string LocationType { get; set; } public DateTime EndDate { get; set; } + + public EmbyProviderids ProviderIds { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs b/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs index acea1535e..af8125ab2 100644 --- a/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs +++ b/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs @@ -75,34 +75,15 @@ namespace Ombi.Schedule.Jobs.Emby var mediaToAdd = new HashSet(); foreach (var movie in movies.Items) { - if (movie.Type.Equals("boxset", StringComparison.CurrentCultureIgnoreCase)) - { - var movieInfo = - await _api.GetCollection(movie.Id, server.ApiKey, server.AdministratorId, server.FullUri); - foreach (var item in movieInfo.Items) - { - var info = await _api.GetMovieInformation(item.Id, server.ApiKey, - server.AdministratorId, server.FullUri); - await ProcessMovies(info, mediaToAdd); - } - } - else - { - // Regular movie - var movieInfo = await _api.GetMovieInformation(movie.Id, server.ApiKey, - server.AdministratorId, server.FullUri); - - await ProcessMovies(movieInfo, mediaToAdd); - } + // Regular movie + await ProcessMovies(movie, mediaToAdd); } // TV Time var tv = await _api.GetAllShows(server.ApiKey, server.AdministratorId, server.FullUri); foreach (var tvShow in tv.Items) - { - var tvInfo = await _api.GetSeriesInformation(tvShow.Id, server.ApiKey, server.AdministratorId, - server.FullUri); - if (string.IsNullOrEmpty(tvInfo.ProviderIds?.Tvdb)) + { + if (string.IsNullOrEmpty(tvShow.ProviderIds?.Tvdb)) { Log.Error("Provider Id on tv {0} is null", tvShow.Name); continue; @@ -112,10 +93,10 @@ namespace Ombi.Schedule.Jobs.Emby if (existingTv == null) mediaToAdd.Add(new EmbyContent { - TvDbId = tvInfo.ProviderIds?.Tvdb, - ImdbId = tvInfo.ProviderIds?.Imdb, - TheMovieDbId = tvInfo.ProviderIds?.Tmdb, - Title = tvInfo.Name, + TvDbId = tvShow.ProviderIds?.Tvdb, + ImdbId = tvShow.ProviderIds?.Imdb, + TheMovieDbId = tvShow.ProviderIds?.Tmdb, + Title = tvShow.Name, Type = EmbyMediaType.Series, EmbyId = tvShow.Id, Url = EmbyHelper.GetEmbyMediaUrl(tvShow.Id), @@ -127,7 +108,7 @@ namespace Ombi.Schedule.Jobs.Emby await _repo.AddRange(mediaToAdd); } - private async Task ProcessMovies(MovieInformation movieInfo, ICollection content) + private async Task ProcessMovies(EmbyMovie movieInfo, ICollection content) { // Check if it exists var existingMovie = await _repo.GetByEmbyId(movieInfo.Id); diff --git a/src/Ombi.Schedule/Jobs/Emby/EmbyEpisodeSync.cs b/src/Ombi.Schedule/Jobs/Emby/EmbyEpisodeSync.cs index df00a37e6..b5ed6d443 100644 --- a/src/Ombi.Schedule/Jobs/Emby/EmbyEpisodeSync.cs +++ b/src/Ombi.Schedule/Jobs/Emby/EmbyEpisodeSync.cs @@ -78,21 +78,9 @@ namespace Ombi.Schedule.Jobs.Emby foreach (var ep in allEpisodes.Items) { - if (ep.LocationType.Equals("Virtual", StringComparison.CurrentCultureIgnoreCase)) - { - // This means that we don't actully have the file, it's just Emby being nice and showing future stuff - continue; - } - - var epInfo = await _api.GetEpisodeInformation(ep.Id, server.ApiKey, server.AdministratorId, server.FullUri); - //if (epInfo?.ProviderIds?.Tvdb == null) - //{ - // continue; - //} - // Let's make sure we have the parent request, stop those pesky forign key errors, // Damn me having data integrity - var parent = await _repo.GetByEmbyId(epInfo.SeriesId); + var parent = await _repo.GetByEmbyId(ep.SeriesId); if (parent == null) { _logger.LogInformation("The episode {0} does not relate to a series, so we cannot save this", ep.Name); @@ -109,9 +97,9 @@ namespace Ombi.Schedule.Jobs.Emby EpisodeNumber = ep.IndexNumber, SeasonNumber = ep.ParentIndexNumber, ParentId = ep.SeriesId, - TvDbId = epInfo.ProviderIds.Tvdb, - TheMovieDbId = epInfo.ProviderIds.Tmdb, - ImdbId = epInfo.ProviderIds.Imdb, + TvDbId = ep.ProviderIds.Tvdb, + TheMovieDbId = ep.ProviderIds.Tmdb, + ImdbId = ep.ProviderIds.Imdb, Title = ep.Name, AddedAt = DateTime.UtcNow });