コード例 #1
0
ファイル: MovieFinder.cs プロジェクト: cocytus/epidaurus
        public static IEnumerable<MovieScanResult> FindMovies(DirResult dir)
        {
            if (!dir.Files.Any(f => f.Name == "ignore"))
            {
                var movies = (from fn in dir.Files where fn.Size > MinimumMovieSize && IsValidMovieFileName(fn.Name, false) orderby fn.Name select fn).ToList();

                if (movies.Count > 0)
                {
                    var singleMovie = (movies.Count == 1) || movies.Select(m => m.Name).All(m => _numbers.Replace(m, "") == _numbers.Replace(movies[0].Name, ""));

                    if (singleMovie)
                    {
                        FileResult sampleFile;
                        if (dir.SubDirs.Count == 1 && dir.SubDirs[0].Name.ToLowerInvariant().Contains("sample"))
                            sampleFile = dir.SubDirs[0].Files.Where(f => IsValidMovieFileName(f.Name, null)).FirstOrDefault();
                        else
                            sampleFile = dir.Files.FirstOrDefault(file => IsValidMovieFileName(file.Name, true));

                        yield return MakeMovieResult(movies[0], true, sampleFile, true);
                    }
                    else
                    {
                        foreach (var movie in movies)
                            yield return MakeMovieResult(movie, false, null, false);
                    }
                }

                foreach (var subDir in dir.SubDirs.Where(sd => !sd.Name.ToLowerInvariant().Contains("sample")))
                    foreach (var result in FindMovies(subDir))
                        yield return result;
            }
        }
コード例 #2
0
ファイル: ScanResult.cs プロジェクト: cocytus/epidaurus
 public DirResult(DirResult parent, string name, string pathElementSeparator, string locallyAccessiblePath=null)
 {
     Parent = parent;
     PathElementSeparator = pathElementSeparator;
     Name = name;
     Files = new List<FileResult>();
     SubDirs = new List<DirResult>();
     _locallyAccessiblePath = locallyAccessiblePath;
 }
コード例 #3
0
ファイル: FolderScanner.cs プロジェクト: cocytus/epidaurus
 private static DirResult Scan(DirResult parent, DirectoryInfo di)
 {
     try
     {
         var dirResult = new DirResult(parent, di.Name, @"\", di.FullName);
         dirResult.Files.AddRange(from fi in di.GetFiles() select new FileResult(dirResult, fi.Name, fi.Length, @"\"));
         dirResult.SubDirs.AddRange(from subDir in di.GetDirectories() let scanRes = Scan(dirResult, subDir) where scanRes != null select scanRes);
         return dirResult;
     }
     catch
     {
         return null;
     }
 }
コード例 #4
0
ファイル: ScanResult.cs プロジェクト: cocytus/epidaurus
 public FileResult(DirResult parent, string name, long size, string pathElementSeparator)
 {
     Parent = parent;
     Name = name;
     Size = size;
     _pathElementSeparator = pathElementSeparator;
 }