/// <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 series && args.IsDirectory) { var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions(); var path = args.Path; var seasonParserResult = SeasonPathParser.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 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( CultureInfo.InvariantCulture, _localization.GetLocalizedString("NameSeasonNumber"), seasonNumber, args.GetLibraryOptions().PreferredMetadataLanguage); } return(season); } return(null); }
public void GetSeasonNumberFromPathTest(string path, int?seasonNumber, bool isSeasonDirectory) { var result = SeasonPathParser.Parse(path, true, true); Assert.Equal(result.SeasonNumber != null, result.Success); Assert.Equal(result.SeasonNumber, seasonNumber); Assert.Equal(isSeasonDirectory, result.IsSeasonFolder); }
public void GetSeasonNumberFromPathTest(string path, int?seasonNumber) { var result = SeasonPathParser.Parse(path, true, true); Assert.Equal(result.SeasonNumber, seasonNumber); }
/// <summary> /// Determines whether [is season folder] [the specified path]. /// </summary> /// <param name="path">The path.</param> /// <param name="isTvContentType">if set to <c>true</c> [is tv content type].</param> /// <param name="libraryManager">The library manager.</param> /// <returns><c>true</c> if [is season folder] [the specified path]; otherwise, <c>false</c>.</returns> private static bool IsSeasonFolder(string path, bool isTvContentType, ILibraryManager libraryManager) { var seasonNumber = SeasonPathParser.Parse(path, isTvContentType, isTvContentType).SeasonNumber; return(seasonNumber.HasValue); }
private int?GetSeasonNumberFromPath(string path) { var result = SeasonPathParser.Parse(path, true, true); return(result.SeasonNumber); }