mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 11:34:57 +02:00
fixes #1225 - Emby creates bogus seasons from subfolderss
This commit is contained in:
parent
d52b0de146
commit
47d7eaeedb
2 changed files with 25 additions and 19 deletions
|
@ -5,6 +5,7 @@ using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Globalization;
|
using MediaBrowser.Model.Globalization;
|
||||||
using Emby.Naming.Common;
|
using Emby.Naming.Common;
|
||||||
using Emby.Naming.TV;
|
using Emby.Naming.TV;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.Library.Resolvers.TV
|
namespace Emby.Server.Implementations.Library.Resolvers.TV
|
||||||
{
|
{
|
||||||
|
@ -21,16 +22,18 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||||
private readonly ILocalizationManager _localization;
|
private readonly ILocalizationManager _localization;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="SeasonResolver"/> class.
|
/// Initializes a new instance of the <see cref="SeasonResolver"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config">The config.</param>
|
/// <param name="config">The config.</param>
|
||||||
public SeasonResolver(IServerConfigurationManager config, ILibraryManager libraryManager, ILocalizationManager localization)
|
public SeasonResolver(IServerConfigurationManager config, ILibraryManager libraryManager, ILocalizationManager localization, ILogger logger)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_localization = localization;
|
_localization = localization;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -45,20 +48,40 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
|
||||||
var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();
|
var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();
|
||||||
var series = ((Series)args.Parent);
|
var series = ((Series)args.Parent);
|
||||||
|
|
||||||
|
var path = args.Path;
|
||||||
|
|
||||||
var season = new Season
|
var season = new Season
|
||||||
{
|
{
|
||||||
IndexNumber = new SeasonPathParser(namingOptions, new RegexProvider()).Parse(args.Path, true, true).SeasonNumber,
|
IndexNumber = new SeasonPathParser(namingOptions, new RegexProvider()).Parse(path, true, true).SeasonNumber,
|
||||||
SeriesId = series.Id,
|
SeriesId = series.Id,
|
||||||
SeriesName = series.Name
|
SeriesName = series.Name
|
||||||
};
|
};
|
||||||
|
|
||||||
if (season.IndexNumber.HasValue)
|
if (season.IndexNumber.HasValue)
|
||||||
{
|
{
|
||||||
|
var resolver = new Emby.Naming.TV.EpisodeResolver(namingOptions);
|
||||||
|
|
||||||
|
var episodeInfo = resolver.Resolve(path, true);
|
||||||
|
|
||||||
|
if (episodeInfo != null)
|
||||||
|
{
|
||||||
|
if (episodeInfo.EpisodeNumber.HasValue && episodeInfo.SeasonNumber.HasValue)
|
||||||
|
{
|
||||||
|
_logger.Info("Found folder underneath series with episode number: {0}. Season {1}. Episode {2}",
|
||||||
|
path,
|
||||||
|
episodeInfo.SeasonNumber.Value,
|
||||||
|
episodeInfo.EpisodeNumber.Value);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var seasonNumber = season.IndexNumber.Value;
|
var seasonNumber = season.IndexNumber.Value;
|
||||||
|
|
||||||
season.Name = seasonNumber == 0 ?
|
season.Name = seasonNumber == 0 ?
|
||||||
args.LibraryOptions.SeasonZeroDisplayName :
|
args.LibraryOptions.SeasonZeroDisplayName :
|
||||||
string.Format(_localization.GetLocalizedString("NameSeasonNumber"), seasonNumber.ToString(UsCulture), args.GetLibraryOptions().PreferredMetadataLanguage);
|
string.Format(_localization.GetLocalizedString("NameSeasonNumber"), seasonNumber.ToString(UsCulture), args.GetLibraryOptions().PreferredMetadataLanguage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return season;
|
return season;
|
||||||
|
|
|
@ -215,23 +215,6 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
[IgnoreDataMember]
|
|
||||||
public bool ContainsEpisodesWithoutSeasonFolders
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var children = Children;
|
|
||||||
foreach (var child in children)
|
|
||||||
{
|
|
||||||
if (child is Video)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren)
|
public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren)
|
||||||
{
|
{
|
||||||
return GetSeasons(user, new DtoOptions(true));
|
return GetSeasons(user, new DtoOptions(true));
|
||||||
|
|
Loading…
Reference in a new issue