mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-09 12:58:37 +02:00
Add Argument*Exceptions now use proper nameof operators. Added exception messages to quite a few Argument*Exceptions. Fixed rethorwing to be proper syntax. Added a ton of null checkes. (This is only a start, there are about 500 places that need proper null handling) Added some TODOs to log certain exceptions. Fix sln again. Fixed all AssemblyInfo's and added proper copyright (where I could find them) We live in *current year*. Fixed the use of braces. Fixed a ton of properties, and made a fair amount of functions static that should be and can be static. Made more Methods that should be static static. You can now use static to find bad functions! Removed unused variable. And added one more proper XML comment.
104 lines
3.8 KiB
C#
104 lines
3.8 KiB
C#
using System.Globalization;
|
|
using MediaBrowser.Controller.Configuration;
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
using MediaBrowser.Controller.Library;
|
|
using MediaBrowser.Model.Globalization;
|
|
using Emby.Naming.Common;
|
|
using Emby.Naming.TV;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Emby.Server.Implementations.Library.Resolvers.TV
|
|
{
|
|
/// <summary>
|
|
/// Class SeasonResolver
|
|
/// </summary>
|
|
public class SeasonResolver : FolderResolver<Season>
|
|
{
|
|
/// <summary>
|
|
/// The _config
|
|
/// </summary>
|
|
private readonly IServerConfigurationManager _config;
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
|
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
|
private readonly ILocalizationManager _localization;
|
|
private readonly ILogger _logger;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="SeasonResolver"/> class.
|
|
/// </summary>
|
|
/// <param name="config">The config.</param>
|
|
/// <param name="libraryManager">The library manager.</param>
|
|
/// <param name="localization">The localization</param>
|
|
/// <param name="logger">The logger</param>
|
|
public SeasonResolver(IServerConfigurationManager config, ILibraryManager libraryManager, ILocalizationManager localization, ILogger logger)
|
|
{
|
|
_config = config;
|
|
_libraryManager = libraryManager;
|
|
_localization = localization;
|
|
_logger = logger;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resolves the specified args.
|
|
/// </summary>
|
|
/// <param name="args">The args.</param>
|
|
/// <returns>Season.</returns>
|
|
protected override Season Resolve(ItemResolveArgs args)
|
|
{
|
|
if (args.Parent is Series && args.IsDirectory)
|
|
{
|
|
var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();
|
|
var series = ((Series)args.Parent);
|
|
|
|
var path = args.Path;
|
|
|
|
var seasonParserResult = new SeasonPathParser(namingOptions).Parse(path, true, true);
|
|
|
|
var season = new Season
|
|
{
|
|
IndexNumber = seasonParserResult.SeasonNumber,
|
|
SeriesId = series.Id,
|
|
SeriesName = series.Name
|
|
};
|
|
|
|
if (!season.IndexNumber.HasValue || !seasonParserResult.IsSeasonFolder)
|
|
{
|
|
var resolver = new Emby.Naming.TV.EpisodeResolver(namingOptions);
|
|
|
|
var folderName = System.IO.Path.GetFileName(path);
|
|
var testPath = "\\\\test\\" + folderName;
|
|
|
|
var episodeInfo = resolver.Resolve(testPath, true);
|
|
|
|
if (episodeInfo != null)
|
|
{
|
|
if (episodeInfo.EpisodeNumber.HasValue && episodeInfo.SeasonNumber.HasValue)
|
|
{
|
|
_logger.LogDebug("Found folder underneath series with episode number: {0}. Season {1}. Episode {2}",
|
|
path,
|
|
episodeInfo.SeasonNumber.Value,
|
|
episodeInfo.EpisodeNumber.Value);
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (season.IndexNumber.HasValue)
|
|
{
|
|
var seasonNumber = season.IndexNumber.Value;
|
|
|
|
season.Name = seasonNumber == 0 ?
|
|
args.LibraryOptions.SeasonZeroDisplayName :
|
|
string.Format(_localization.GetLocalizedString("NameSeasonNumber"), seasonNumber.ToString(UsCulture), args.GetLibraryOptions().PreferredMetadataLanguage);
|
|
|
|
}
|
|
|
|
return season;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|