From fc31db4c6ed0d3c8af7ba3dd11c64b1fd4e34a35 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Fri, 3 Nov 2017 21:46:17 +0000 Subject: [PATCH] Added some better handling when adding existing seasons to a tv show in the Plex cacher. Also fixed the errors on #1673 --- src/Ombi.Helpers/LoggingEvents.cs | 1 + .../Jobs/Plex/PlexContentCacher.cs | 43 +++++++++++-------- .../Jobs/Plex/PlexEpisodeCacher.cs | 1 + .../app/requests/movierequests.component.ts | 6 +-- .../usermanagement.component.html | 2 +- src/Ombi/ClientApp/styles/Themes/plex.scss | 2 +- 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/Ombi.Helpers/LoggingEvents.cs b/src/Ombi.Helpers/LoggingEvents.cs index 34b69864e..0a2311b80 100644 --- a/src/Ombi.Helpers/LoggingEvents.cs +++ b/src/Ombi.Helpers/LoggingEvents.cs @@ -18,6 +18,7 @@ namespace Ombi.Helpers public static EventId EmbyUserImporter => new EventId(2005); public static EventId SonarrCacher => new EventId(2006); public static EventId CouchPotatoCacher => new EventId(2007); + public static EventId PlexContentCacher => new EventId(2008); public static EventId MovieSender => new EventId(3000); diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexContentCacher.cs b/src/Ombi.Schedule/Jobs/Plex/PlexContentCacher.cs index 96829b7bb..4ffc6f30c 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexContentCacher.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexContentCacher.cs @@ -104,7 +104,7 @@ namespace Ombi.Schedule.Jobs.Plex { // Process Shows Logger.LogInformation("Processing TV Shows"); - foreach (var show in content.Metadata ?? new Metadata[]{}) + foreach (var show in content.Metadata ?? new Metadata[] { }) { var seasonList = await PlexApi.GetSeasons(servers.PlexAuthToken, servers.FullUri, show.ratingKey); @@ -124,24 +124,31 @@ namespace Ombi.Schedule.Jobs.Plex var existingContent = await Repo.GetByKey(show.ratingKey); if (existingContent != null) { - Logger.LogInformation("We already have show {0} checking for new seasons", existingContent.Title); - // Ok so we have it, let's check if there are any new seasons - var itemAdded = false; - foreach (var season in seasonsContent) + try { - var seasonExists = existingContent.Seasons.FirstOrDefault(x => x.SeasonKey == season.SeasonKey); - - if (seasonExists != null) + Logger.LogInformation("We already have show {0} checking for new seasons", existingContent.Title); + // Ok so we have it, let's check if there are any new seasons + var itemAdded = false; + foreach (var season in seasonsContent) { - // We already have this season - continue; + var seasonExists = existingContent.Seasons.FirstOrDefault(x => x.SeasonKey == season.SeasonKey); + + if (seasonExists != null) + { + // We already have this season + continue; + } + + existingContent.Seasons.Add(season); + itemAdded = true; } - - existingContent.Seasons.Add(season); - itemAdded = true; - } - if (itemAdded) await Repo.Update(existingContent); + if (itemAdded) await Repo.Update(existingContent); + } + catch (Exception e) + { + Logger.LogError(LoggingEvents.PlexContentCacher, e, "Exception when adding new seasons to title {0}", existingContent.Title); + } } else { @@ -153,7 +160,7 @@ namespace Ombi.Schedule.Jobs.Plex var showMetadata = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri, show.ratingKey); var providerIds = PlexHelper.GetProviderIdFromPlexGuid(showMetadata.MediaContainer.Metadata.FirstOrDefault().guid); - + var item = new PlexServerContent { AddedAt = DateTime.Now, @@ -186,11 +193,11 @@ namespace Ombi.Schedule.Jobs.Plex if (content.viewGroup.Equals(PlexMediaType.Movie.ToString(), StringComparison.CurrentCultureIgnoreCase)) { Logger.LogInformation("Processing Movies"); - foreach (var movie in content?.Metadata ?? new Metadata[]{}) + foreach (var movie in content?.Metadata ?? new Metadata[] { }) { // Let's check if we have this movie var existing = await Repo.GetByKey(movie.ratingKey); - if(existing != null) + if (existing != null) { continue; } diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeCacher.cs b/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeCacher.cs index 0b3137542..261d4328d 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeCacher.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeCacher.cs @@ -114,6 +114,7 @@ namespace Ombi.Schedule.Jobs.Plex } // we have now finished. + _log.LogInformation(LoggingEvents.PlexEpisodeCacher, "We have finished caching the episodes."); await _repo.SaveChangesAsync(); } diff --git a/src/Ombi/ClientApp/app/requests/movierequests.component.ts b/src/Ombi/ClientApp/app/requests/movierequests.component.ts index c4ae1e9de..ef5f9fa70 100644 --- a/src/Ombi/ClientApp/app/requests/movierequests.component.ts +++ b/src/Ombi/ClientApp/app/requests/movierequests.component.ts @@ -122,10 +122,10 @@ export class MovieRequestsComponent implements OnInit { private loadRequests(amountToLoad: number, currentlyLoaded: number) { this.requestService.getMovieRequests(amountToLoad, currentlyLoaded + 1) .subscribe(x => { - // x.background = this.sanitizer. - // bypassSecurityTrustStyle - // ("linear-gradient(to bottom, rgba(0,0,0,0.6) 0%,rgba(0,0,0,0.6) 100%),url(" + "https://image.tmdb.org/t/p/w1280" + x.backdropPath + ")"); this.setOverrides(x); + if(!this.movieRequests) { + this.movieRequests = []; + } this.movieRequests.push.apply(this.movieRequests, x); this.currentlyLoaded = currentlyLoaded + amountToLoad; }); diff --git a/src/Ombi/ClientApp/app/settings/usermanagement/usermanagement.component.html b/src/Ombi/ClientApp/app/settings/usermanagement/usermanagement.component.html index e71d2b35d..9b8cef406 100644 --- a/src/Ombi/ClientApp/app/settings/usermanagement/usermanagement.component.html +++ b/src/Ombi/ClientApp/app/settings/usermanagement/usermanagement.component.html @@ -1,7 +1,7 @@  -
+
User Management Settings
diff --git a/src/Ombi/ClientApp/styles/Themes/plex.scss b/src/Ombi/ClientApp/styles/Themes/plex.scss index 0eef3d041..347a38278 100644 --- a/src/Ombi/ClientApp/styles/Themes/plex.scss +++ b/src/Ombi/ClientApp/styles/Themes/plex.scss @@ -316,7 +316,7 @@ button.list-group-item:focus { color:$primary-colour $i; } -.ui-state-default { +.ui-radiobutton-box .ui-widget .ui-state-default { border-width: 2px; border-style: solid; border-color: $primary-colour-outline;