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); }
private int? GetEpisodeNumberFromFile(string path) { var options = new ExtendedNamingOptions(); var result = new EpisodeResolver(options, new NullLogger(), new RegexProvider()) .Resolve(path, false); return result.EpisodeNumber; }
private void Test(string path, string seriesName, int? seasonNumber, int? episodeNumber) { var options = new NamingOptions(); var result = new EpisodeResolver(options, new NullLogger(), new RegexProvider()) .Resolve(path, false); Assert.AreEqual(seasonNumber, result.SeasonNumber); Assert.AreEqual(episodeNumber, result.EpisodeNumber); Assert.AreEqual(seriesName, result.SeriesName, true, CultureInfo.InvariantCulture); }
private void Test(string path, string seriesName, int? year, int? month, int? day) { var options = new NamingOptions(); var result = new EpisodeResolver(options, new NullLogger(), new RegexProvider()) .Resolve(path, false); Assert.IsNull(result.SeasonNumber); Assert.IsNull(result.EpisodeNumber); Assert.AreEqual(year, result.Year); Assert.AreEqual(month, result.Month); Assert.AreEqual(day, result.Day); //Assert.AreEqual(seriesName, result.SeriesName, true, CultureInfo.InvariantCulture); }
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); }