update season creator

release-10.1.0
Luke Pulverenti 8 years ago
parent 1cb7a1b49c
commit 7a77aa42c5

@ -66,29 +66,39 @@ namespace MediaBrowser.Providers.TV
.Distinct() .Distinct()
.ToList()) .ToList())
{ {
var hasSeason = series.Children.OfType<Season>() var existingSeason = series.Children.OfType<Season>()
.Any(i => i.IndexNumber.HasValue && i.IndexNumber.Value == seasonNumber); .FirstOrDefault(i => i.IndexNumber.HasValue && i.IndexNumber.Value == seasonNumber);
if (!hasSeason) if (existingSeason == null)
{ {
await AddSeason(series, seasonNumber, false, cancellationToken).ConfigureAwait(false); await AddSeason(series, seasonNumber, false, cancellationToken).ConfigureAwait(false);
hasChanges = true; hasChanges = true;
} }
else if (existingSeason.IsVirtualItem)
{
existingSeason.IsVirtualItem = false;
await existingSeason.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
}
} }
// Unknown season - create a dummy season to put these under // Unknown season - create a dummy season to put these under
if (episodesInSeriesFolder.Any(i => !i.ParentIndexNumber.HasValue)) if (episodesInSeriesFolder.Any(i => !i.ParentIndexNumber.HasValue))
{ {
var hasSeason = series.Children.OfType<Season>() var existingSeason = series.Children.OfType<Season>()
.Any(i => !i.IndexNumber.HasValue); .FirstOrDefault(i => !i.IndexNumber.HasValue);
if (!hasSeason) if (existingSeason == null)
{ {
await AddSeason(series, null, false, cancellationToken).ConfigureAwait(false); await AddSeason(series, null, false, cancellationToken).ConfigureAwait(false);
hasChanges = true; hasChanges = true;
} }
else if (existingSeason.IsVirtualItem)
{
existingSeason.IsVirtualItem = false;
await existingSeason.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
}
} }
return hasChanges; return hasChanges;

Loading…
Cancel
Save