/// <summary> /// Gets the multi disc movie. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="multiDiscFolders">The folders.</param> /// <param name="directoryService">The directory service.</param> /// <returns>``0.</returns> private T GetMultiDiscMovie <T>(List <FileSystemInfo> multiDiscFolders, IDirectoryService directoryService) where T : Video, new() { var videoTypes = new List <VideoType>(); var folderPaths = multiDiscFolders.Select(i => i.FullName).Where(i => { var subfolders = directoryService.GetDirectories(i) .Select(d => d.Name) .ToList(); if (subfolders.Any(IsDvdDirectory)) { videoTypes.Add(VideoType.Dvd); return(true); } if (subfolders.Any(IsBluRayDirectory)) { videoTypes.Add(VideoType.BluRay); return(true); } return(false); }).OrderBy(i => i).ToList(); // If different video types were found, don't allow this if (videoTypes.Distinct().Count() > 1) { return(null); } if (folderPaths.Count == 0) { return(null); } var resolver = new StackResolver(new ExtendedNamingOptions(), new Naming.Logging.NullLogger()); var result = resolver.ResolveDirectories(folderPaths); if (result.Stacks.Count != 1) { return(null); } return(new T { Path = folderPaths[0], IsMultiPart = true, VideoType = videoTypes[0], Name = result.Stacks[0].Name }); }
public void TestDirectories() { var files = new[] { "blah blah - cd 1", "blah blah - cd 2" }; var result = StackResolver.ResolveDirectories(files, _namingOptions).ToList(); Assert.Single(result); TestStackInfo(result[0], "blah blah", 2); }
public void TestMultiDiscs() { // No stacking here because there is no part/disc/etc var files = new[] { @"M:/Movies (DVD)/Movies (Musical)/The Sound of Music/The Sound of Music (1965) (Disc 01)", @"M:/Movies (DVD)/Movies (Musical)/The Sound of Music/The Sound of Music (1965) (Disc 02)" }; var result = StackResolver.ResolveDirectories(files, _namingOptions).ToList(); Assert.Single(result); Assert.Equal(2, result[0].Files.Count); }
/// <summary> /// Gets the multi disc movie. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="multiDiscFolders">The folders.</param> /// <param name="directoryService">The directory service.</param> /// <returns>``0.</returns> private T GetMultiDiscMovie <T>(List <FileSystemMetadata> multiDiscFolders, IDirectoryService directoryService) where T : Video, new() { var videoTypes = new List <VideoType>(); var folderPaths = multiDiscFolders.Select(i => i.FullName).Where(i => { var subFileEntries = directoryService.GetFileSystemEntries(i); var subfolders = subFileEntries .Where(e => e.IsDirectory) .ToList(); if (subfolders.Any(s => IsDvdDirectory(s.FullName, s.Name, directoryService))) { videoTypes.Add(VideoType.Dvd); return(true); } if (subfolders.Any(s => IsBluRayDirectory(s.FullName, s.Name, directoryService))) { videoTypes.Add(VideoType.BluRay); return(true); } var subFiles = subFileEntries .Where(e => !e.IsDirectory) .Select(d => d.Name); if (subFiles.Any(IsDvdFile)) { videoTypes.Add(VideoType.Dvd); return(true); } return(false); }).OrderBy(i => i).ToList(); // If different video types were found, don't allow this if (videoTypes.Distinct().Count() > 1) { return(null); } if (folderPaths.Count == 0) { return(null); } var namingOptions = ((LibraryManager)LibraryManager).GetNamingOptions(); var resolver = new StackResolver(namingOptions); var result = resolver.ResolveDirectories(folderPaths); if (result.Stacks.Count != 1) { return(null); } var returnVideo = new T { Path = folderPaths[0], AdditionalParts = folderPaths.Skip(1).ToArray(), VideoType = videoTypes[0], Name = result.Stacks[0].Name }; SetIsoType(returnVideo); return(returnVideo); }