public static bool IsSeriesFolder(string path, IEnumerable <FileSystemMetadata> fileSystemChildren, IDirectoryService directoryService, IFileSystem fileSystem, ILogger logger, ILibraryManager libraryManager, LibraryOptions libraryOptions, bool isTvContentType) { foreach (var child in fileSystemChildren) { //if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden) //{ // //logger.Debug("Igoring series file or folder marked hidden: {0}", child.FullName); // continue; //} // Can't enforce this because files saved by Bitcasa are always marked System //if ((attributes & FileAttributes.System) == FileAttributes.System) //{ // logger.Debug("Igoring series subfolder marked system: {0}", child.FullName); // continue; //} if (child.IsDirectory) { if (IsSeasonFolder(child.FullName, isTvContentType, libraryManager)) { //logger.Debug("{0} is a series because of season folder {1}.", path, child.FullName); return(true); } } else { string fullName = child.FullName; if (libraryManager.IsVideoFile(fullName, libraryOptions)) { if (isTvContentType) { return(true); } var allowOptimisticEpisodeDetection = isTvContentType; var namingOptions = ((LibraryManager)libraryManager).GetNamingOptions(allowOptimisticEpisodeDetection); var episodeResolver = new Emby.Naming.TV.EpisodeResolver(namingOptions); var episodeInfo = episodeResolver.Resolve(fullName, false, false); if (episodeInfo != null && episodeInfo.EpisodeNumber.HasValue) { return(true); } } } } //logger.Debug("{0} is not a series folder.", path); return(false); }
/// <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); }