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 MediaBrowser.Naming.TV.EpisodeResolver(namingOptions, new NullLogger()); 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); }
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 namingOptions = ((LibraryManager)libraryManager).GetNamingOptions(); // In mixed folders we need to be conservative and avoid expressions that may result in false positives (e.g. movies with numbers in the title) if (!isTvContentType) { namingOptions.EpisodeExpressions = namingOptions.EpisodeExpressions .Where(i => i.IsNamed && !i.IsOptimistic) .ToList(); } var episodeResolver = new MediaBrowser.Naming.TV.EpisodeResolver(namingOptions, new NullLogger()); 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); }