Added some better handling when adding existing seasons to a tv show in the Plex cacher.

Also fixed the errors on #1673
pull/1676/head
tidusjar 7 years ago
parent dd306aae5a
commit fc31db4c6e

@ -18,6 +18,7 @@ namespace Ombi.Helpers
public static EventId EmbyUserImporter => new EventId(2005); public static EventId EmbyUserImporter => new EventId(2005);
public static EventId SonarrCacher => new EventId(2006); public static EventId SonarrCacher => new EventId(2006);
public static EventId CouchPotatoCacher => new EventId(2007); public static EventId CouchPotatoCacher => new EventId(2007);
public static EventId PlexContentCacher => new EventId(2008);
public static EventId MovieSender => new EventId(3000); public static EventId MovieSender => new EventId(3000);

@ -104,7 +104,7 @@ namespace Ombi.Schedule.Jobs.Plex
{ {
// Process Shows // Process Shows
Logger.LogInformation("Processing TV 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, var seasonList = await PlexApi.GetSeasons(servers.PlexAuthToken, servers.FullUri,
show.ratingKey); show.ratingKey);
@ -124,24 +124,31 @@ namespace Ombi.Schedule.Jobs.Plex
var existingContent = await Repo.GetByKey(show.ratingKey); var existingContent = await Repo.GetByKey(show.ratingKey);
if (existingContent != null) if (existingContent != null)
{ {
Logger.LogInformation("We already have show {0} checking for new seasons", existingContent.Title); try
// Ok so we have it, let's check if there are any new seasons
var itemAdded = false;
foreach (var season in seasonsContent)
{ {
var seasonExists = existingContent.Seasons.FirstOrDefault(x => x.SeasonKey == season.SeasonKey); 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
if (seasonExists != null) var itemAdded = false;
foreach (var season in seasonsContent)
{ {
// We already have this season var seasonExists = existingContent.Seasons.FirstOrDefault(x => x.SeasonKey == season.SeasonKey);
continue;
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 else
{ {
@ -153,7 +160,7 @@ namespace Ombi.Schedule.Jobs.Plex
var showMetadata = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri, var showMetadata = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri,
show.ratingKey); show.ratingKey);
var providerIds = PlexHelper.GetProviderIdFromPlexGuid(showMetadata.MediaContainer.Metadata.FirstOrDefault().guid); var providerIds = PlexHelper.GetProviderIdFromPlexGuid(showMetadata.MediaContainer.Metadata.FirstOrDefault().guid);
var item = new PlexServerContent var item = new PlexServerContent
{ {
AddedAt = DateTime.Now, AddedAt = DateTime.Now,
@ -186,11 +193,11 @@ namespace Ombi.Schedule.Jobs.Plex
if (content.viewGroup.Equals(PlexMediaType.Movie.ToString(), StringComparison.CurrentCultureIgnoreCase)) if (content.viewGroup.Equals(PlexMediaType.Movie.ToString(), StringComparison.CurrentCultureIgnoreCase))
{ {
Logger.LogInformation("Processing Movies"); 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 // Let's check if we have this movie
var existing = await Repo.GetByKey(movie.ratingKey); var existing = await Repo.GetByKey(movie.ratingKey);
if(existing != null) if (existing != null)
{ {
continue; continue;
} }

@ -114,6 +114,7 @@ namespace Ombi.Schedule.Jobs.Plex
} }
// we have now finished. // we have now finished.
_log.LogInformation(LoggingEvents.PlexEpisodeCacher, "We have finished caching the episodes.");
await _repo.SaveChangesAsync(); await _repo.SaveChangesAsync();
} }

@ -122,10 +122,10 @@ export class MovieRequestsComponent implements OnInit {
private loadRequests(amountToLoad: number, currentlyLoaded: number) { private loadRequests(amountToLoad: number, currentlyLoaded: number) {
this.requestService.getMovieRequests(amountToLoad, currentlyLoaded + 1) this.requestService.getMovieRequests(amountToLoad, currentlyLoaded + 1)
.subscribe(x => { .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); this.setOverrides(x);
if(!this.movieRequests) {
this.movieRequests = [];
}
this.movieRequests.push.apply(this.movieRequests, x); this.movieRequests.push.apply(this.movieRequests, x);
this.currentlyLoaded = currentlyLoaded + amountToLoad; this.currentlyLoaded = currentlyLoaded + amountToLoad;
}); });

@ -1,7 +1,7 @@
<settings-menu></settings-menu> <settings-menu></settings-menu>
<wiki [url]="'https://github.com/tidusjar/Ombi/wiki/User-Management-Settings'"></wiki> <wiki [url]="'https://github.com/tidusjar/Ombi/wiki/User-Management-Settings'"></wiki>
<fieldset> <fieldset *ngIf="settings">
<legend>User Management Settings</legend> <legend>User Management Settings</legend>
<div class="col-md-6"> <div class="col-md-6">

@ -316,7 +316,7 @@ button.list-group-item:focus {
color:$primary-colour $i; color:$primary-colour $i;
} }
.ui-state-default { .ui-radiobutton-box .ui-widget .ui-state-default {
border-width: 2px; border-width: 2px;
border-style: solid; border-style: solid;
border-color: $primary-colour-outline; border-color: $primary-colour-outline;

Loading…
Cancel
Save