public void BuildFromDirectory(string Directory)
        {
            // Get list of files
            string[] Files = System.IO.Directory.GetFiles(Directory).OrderBy(x => x).ToArray();

            List <TeslaCamFile> CurrentTeslaCams = new List <TeslaCamFile>();

            foreach (var File in Files)
            {
                try
                {
                    TeslaCamFile f = new TeslaCamFile(File);
                    CurrentTeslaCams.Add(f);
                }
                catch
                {
                }
            }
            List <string> DistinctEvents = CurrentTeslaCams.Select(e => e.Date.UTCDateString).Distinct().ToList();

            foreach (var CurrentEvent in DistinctEvents)
            {
                List <TeslaCamFile> MatchedFiles   = CurrentTeslaCams.Where(e => e.Date.UTCDateString == CurrentEvent).ToList();
                TeslaCamFileSet     CurrentFileSet = new TeslaCamFileSet();

                CurrentFileSet.SetCollection(MatchedFiles);
                this.Recordings.Add(CurrentFileSet);
            }
            this.Recordings = Recordings.OrderBy(e => e.Date.UTCDateString).ToList();
            this.StartDate  = Recordings.First().Date;
            this.EndDate    = Recordings.Last().Date;
        }
        public bool BuildFromDirectory(string Directory)
        {
            // Get list of raw files
            string[] Files = System.IO.Directory.GetFiles(Directory, "*.mp4").OrderBy(x => x).ToArray();

            // Make sure there's at least one valid file
            if (Files.Length < 1)
            {
                return(false);
            }

            // Create a list of cam files
            List <TeslaCamFile> CurrentTeslaCams = new List <TeslaCamFile>(Files.Length);

            // Convert raw file to cam file
            foreach (var File in Files)
            {
                TeslaCamFile f = TeslaCamFile.TryParse(File);
                if (f != null)
                {
                    CurrentTeslaCams.Add(f);
                }
            }

            if (CurrentTeslaCams.Count == 0)
            {
                return(false);
            }

            // Now get list of only distinct events
            List <string> DistinctEvents = CurrentTeslaCams.Select(e => e.Date.UTCDateString).Distinct().ToList();

            // Find the files that match the distinct event
            foreach (var CurrentEvent in DistinctEvents)
            {
                List <TeslaCamFile> MatchedFiles   = CurrentTeslaCams.Where(e => e.Date.UTCDateString == CurrentEvent).ToList();
                TeslaCamFileSet     CurrentFileSet = new TeslaCamFileSet();

                CurrentFileSet.SetCollection(MatchedFiles);
                this.Recordings.Add(CurrentFileSet);
            }

            // Set metadata
            this.Recordings = Recordings.OrderBy(e => e.Date.UTCDateString).ToList();
            this.StartDate  = Recordings.First().Date;
            this.EndDate    = Recordings.Last().Date;

            // Success
            return(true);
        }
        public bool BuildFromDirectory(string directory)
        {
            // Get list of raw files
            var files = System.IO.Directory.GetFiles(directory, "*.mp4").OrderBy(x => x).ToArray();

            // Make sure there's at least one valid file
            if (files.Length < 1)
            {
                return(false);
            }

            // Create a list of cam files
            var currentTeslaCams = new List <TeslaCamFile>(files.Length);

            // Convert raw file to cam file
            foreach (var file in files)
            {
                var teslaCamFile = new TeslaCamFile(file);
                currentTeslaCams.Add(teslaCamFile);
            }

            // Now get list of only distinct events
            var distinctEvents = currentTeslaCams.Select(e => e.Date.UTCDateString).Distinct().ToList();

            // Find the files that match the distinct event
            foreach (var currentEvent in distinctEvents)
            {
                var matchedFiles   = currentTeslaCams.Where(e => e.Date.UTCDateString == currentEvent).ToList();
                var currentFileSet = new TeslaCamFileSet();

                currentFileSet.SetCollection(matchedFiles);
                Recordings.Add(currentFileSet);
            }

            // Set metadata
            Recordings = Recordings.OrderBy(e => e.Date.UTCDateString).ToList();
            StartDate  = Recordings.First().Date;
            EndDate    = Recordings.Last().Date;

            // Success
            return(true);
        }