コード例 #1
0
        public IActionResult Index(string id = null)
        {
            var       nodes  = new List <VideoNode>();
            VideoNode parent = null;

            if (id != null)
            {
                parent = videoIndex.FindNode(id);
            }

            if (parent == null)
            {
                nodes = videoIndex.RootNodes;
            }
            else
            {
                if (parent.Children.Any())
                {
                    nodes = parent.Children;
                }
                else
                {
                    var path = Path.Combine(options.RootDirectory, videoIndex.FindNode(id).GetFullPath());
                    if (System.IO.File.Exists(path))
                    {
                        return(View("Play", parent));
                    }
                }
            }

            return(View(nodes));
        }
コード例 #2
0
ファイル: VideoIndex.cs プロジェクト: Al-khwarizmi1/SimpleVOD
        private void PopulateVideoNodes()
        {
            var root     = options.RootDirectory;
            var rootDirs = Directory.GetDirectories(root);

            foreach (var dir in rootDirs)
            {
                var node = new VideoNode()
                {
                    Title = dir.Split('\\').Last()
                };
                TraverseChildren(node);
                RootNodes.Add(node);
                flatList.Add(node);
            }
        }
コード例 #3
0
ファイル: VideoIndex.cs プロジェクト: Al-khwarizmi1/SimpleVOD
        private void AddFiles(VideoNode node)
        {
            var dir = Path.Combine(options.RootDirectory, node.GetFullPath());

            var files = Directory.GetFiles(dir);

            foreach (var file in files.Where(f => ValidFileExtension(f)))
            {
                var video = new VideoNode()
                {
                    Title  = file.Split('\\').Last(),
                    Parent = node,
                };

                node.Children.Add(video);
                flatList.Add(video);
            }
        }
コード例 #4
0
ファイル: VideoIndex.cs プロジェクト: Al-khwarizmi1/SimpleVOD
        private void TraverseChildren(VideoNode parent)
        {
            var dirs = Directory.GetDirectories(Path.Combine(options.RootDirectory, parent.GetFullPath()));

            AddFiles(parent);

            foreach (var dir in dirs)
            {
                var child = new VideoNode()
                {
                    Title = dir.Split('\\').Last()
                };

                parent.Children.Add(child);
                child.Parent = parent;
                flatList.Add(child);

                TraverseChildren(child);
            }
        }