|
@@ -1,5 +1,6 @@
|
|
using MediaBrowser.Common.Extensions;
|
|
using MediaBrowser.Common.Extensions;
|
|
using MediaBrowser.Controller.Configuration;
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
+using MediaBrowser.Controller.Entities;
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
using MediaBrowser.Controller.Library;
|
|
using MediaBrowser.Controller.Library;
|
|
using MediaBrowser.Model.Entities;
|
|
using MediaBrowser.Model.Entities;
|
|
@@ -150,6 +151,12 @@ namespace MediaBrowser.Providers.TV
|
|
.ConfigureAwait(false);
|
|
.ConfigureAwait(false);
|
|
|
|
|
|
var hasNewEpisodes = false;
|
|
var hasNewEpisodes = false;
|
|
|
|
+ var hasNewSeasons = false;
|
|
|
|
+
|
|
|
|
+ if (series.ContainsEpisodesWithoutSeasonFolders)
|
|
|
|
+ {
|
|
|
|
+ hasNewSeasons = await AddDummySeasonFolders(series, cancellationToken).ConfigureAwait(false);
|
|
|
|
+ }
|
|
|
|
|
|
if (_config.Configuration.EnableInternetProviders)
|
|
if (_config.Configuration.EnableInternetProviders)
|
|
{
|
|
{
|
|
@@ -157,7 +164,7 @@ namespace MediaBrowser.Providers.TV
|
|
.ConfigureAwait(false);
|
|
.ConfigureAwait(false);
|
|
}
|
|
}
|
|
|
|
|
|
- if (hasNewEpisodes || anySeasonsRemoved || anyEpisodesRemoved)
|
|
|
|
|
|
+ if (hasNewSeasons || hasNewEpisodes || anySeasonsRemoved || anyEpisodesRemoved)
|
|
{
|
|
{
|
|
await series.RefreshMetadata(cancellationToken, true)
|
|
await series.RefreshMetadata(cancellationToken, true)
|
|
.ConfigureAwait(false);
|
|
.ConfigureAwait(false);
|
|
@@ -167,6 +174,40 @@ namespace MediaBrowser.Providers.TV
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// For series with episodes directly under the series folder, this adds dummy seasons to enable regular browsing and metadata
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="series"></param>
|
|
|
|
+ /// <param name="cancellationToken"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ private async Task<bool> AddDummySeasonFolders(Series series, CancellationToken cancellationToken)
|
|
|
|
+ {
|
|
|
|
+ var existingEpisodes = series.RecursiveChildren
|
|
|
|
+ .OfType<Episode>()
|
|
|
|
+ .ToList();
|
|
|
|
+
|
|
|
|
+ var hasChanges = false;
|
|
|
|
+
|
|
|
|
+ // Loop through the unique season numbers
|
|
|
|
+ foreach (var seasonNumber in existingEpisodes.Select(i => i.ParentIndexNumber ?? -1)
|
|
|
|
+ .Where(i => i >= 0)
|
|
|
|
+ .Distinct()
|
|
|
|
+ .ToList())
|
|
|
|
+ {
|
|
|
|
+ var hasSeason = series.Children.OfType<Season>()
|
|
|
|
+ .Any(i => i.IndexNumber.HasValue && i.IndexNumber.Value == seasonNumber);
|
|
|
|
+
|
|
|
|
+ if (!hasSeason)
|
|
|
|
+ {
|
|
|
|
+ await AddSeason(series, seasonNumber, cancellationToken).ConfigureAwait(false);
|
|
|
|
+
|
|
|
|
+ hasChanges = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return hasChanges;
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Adds the missing episodes.
|
|
/// Adds the missing episodes.
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -355,7 +396,7 @@ namespace MediaBrowser.Providers.TV
|
|
|
|
|
|
return hasChanges;
|
|
return hasChanges;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Adds the episode.
|
|
/// Adds the episode.
|
|
/// </summary>
|
|
/// </summary>
|