public void Confirm()
        {
            // Prompt for output directory path
            var dirPath = _dialogManager.PromptDirectoryPath();

            if (string.IsNullOrWhiteSpace(dirPath))
            {
                return;
            }

            _settingsService.LastFormat = SelectedFormat;
            _settingsService.LastVideoQualityPreference = SelectedVideoQualityPreference;

            // Make sure selected videos are ordered in the same way as available videos
            var orderedSelectedVideos = AvailableVideos.Where(v => SelectedVideos.Contains(v)).ToArray();

            var downloads = new List <DownloadViewModel>();

            for (var i = 0; i < orderedSelectedVideos.Length; i++)
            {
                var video = orderedSelectedVideos[i];

                var fileName = FileNameGenerator.GenerateFileName(
                    _settingsService.FileNameTemplate,
                    video,
                    SelectedFormat !,
                    (i + 1).ToString().PadLeft(orderedSelectedVideos.Length.ToString().Length, '0')
                    );

                var filePath = Path.Combine(dirPath, fileName);

                // If file exists - either skip it or generate a unique file path, depending on user settings
                if (File.Exists(filePath))
                {
                    if (_settingsService.ShouldSkipExistingFiles)
                    {
                        continue;
                    }

                    filePath = PathEx.MakeUniqueFilePath(filePath);
                }

                // Create empty file to "lock in" the file path.
                // This is necessary as there may be other downloads with the same file name
                // which would otherwise overwrite the file.
                PathEx.CreateDirectoryForFile(filePath);
                PathEx.CreateEmptyFile(filePath);

                var download = _viewModelFactory.CreateDownloadViewModel(
                    video,
                    filePath,
                    SelectedFormat !,
                    SelectedVideoQualityPreference
                    );

                downloads.Add(download);
            }

            Close(downloads);
        }
        public void Confirm()
        {
            // Prompt user for output directory path
            var dirPath = _dialogManager.PromptDirectoryPath();

            // If canceled - return
            if (string.IsNullOrWhiteSpace(dirPath))
            {
                return;
            }

            // Save last used format
            _settingsService.LastFormat = SelectedFormat;

            // Split quality and format
            var(quality, format) = ParseToQualityAndFormat(SelectedFormat);

            // Make sure selected videos are ordered in the same way as available videos
            var orderedSelectedVideos = AvailableVideos.Where(v => SelectedVideos.Contains(v)).ToArray();

            // Create download view models
            var downloads = new List <DownloadViewModel>();

            for (var i = 0; i < orderedSelectedVideos.Length; i++)
            {
                var video = orderedSelectedVideos[i];

                // Generate file path
                var number   = (i + 1).ToString().PadLeft(orderedSelectedVideos.Length.ToString().Length, '0');
                var fileName = FileNameGenerator.GenerateFileName(_settingsService.FileNameTemplate, video, format, number);
                var filePath = Path.Combine(dirPath, fileName);

                // If file exists - either skip it or generate a unique file path, depending on user settings
                if (File.Exists(filePath))
                {
                    if (_settingsService.ShouldSkipExistingFiles)
                    {
                        continue;
                    }

                    filePath = PathEx.MakeUniqueFilePath(filePath);
                }

                // Create empty file to "lock in" the file path
                PathEx.CreateDirectoryForFile(filePath);
                PathEx.CreateEmptyFile(filePath);

                // Create download view model
                var download = _viewModelFactory.CreateDownloadViewModel(video, filePath, format, quality);

                // Add to list
                downloads.Add(download);
            }

            // Close dialog
            Close(downloads);
        }
Beispiel #3
0
        private async void SelectedReleasesChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (SelectedVideos.Count == 1)
            {
                var video = SelectedVideos.First();
                await Launcher.LaunchUriAsync(video.VideoUrl);

                RefreshSelectedVideos();
            }
        }
Beispiel #4
0
        public void Confirm()
        {
            var dirPath = _dialogManager.PromptDirectoryPath();


            if (string.IsNullOrWhiteSpace(dirPath))
            {
                return;
            }

            // Save last used format
            _settingsService.LastFormat = SelectedFormat;


            var orderedSelectedVideos = AvailableVideos.Where(v => SelectedVideos.Contains(v)).ToArray();

            // Create download view models
            var downloads = new List <DownloadViewModel>();

            for (var i = 0; i < orderedSelectedVideos.Length; i++)
            {
                var video = orderedSelectedVideos[i];

                // Generate file path
                var number   = (i + 1).ToString().PadLeft(orderedSelectedVideos.Length.ToString().Length, '0');
                var fileName = FileNameGenerator.GenerateFileName(_settingsService.FileNameTemplate, video, SelectedFormat, number);
                var filePath = Path.Combine(dirPath, fileName);


                if (File.Exists(filePath))
                {
                    if (_settingsService.ShouldSkipExistingFiles && new FileInfo(filePath).Length > 0)
                    {
                        continue;
                    }

                    filePath = FileEx.MakeUniqueFilePath(filePath);
                }


                FileEx.CreateDirectoriesForFile(filePath);
                FileEx.CreateEmptyFile(filePath);

                // Create dwnloda view model
                var download = _viewModelFactory.CreateDownloadViewModel(video, filePath, SelectedFormat);

                // adaugare la lista
                downloads.Add(download);
            }

            // Close dialog
            Close(downloads);
        }
Beispiel #5
0
        public void Confirm()
        {
            // Prompt user for output directory path
            var dirPath = _dialogManager.PromptDirectoryPath();

            // If canceled - return
            if (dirPath.IsNullOrWhiteSpace())
            {
                return;
            }

            // Save last used format
            _settingsService.LastFormat = SelectedFormat;

            // Make sure selected videos are ordered in the same way as available videos
            var orderedSelectedVideos = AvailableVideos.Where(v => SelectedVideos.Contains(v)).ToArray();

            // Create download view models
            var downloads = new List <DownloadViewModel>();

            for (var i = 0; i < orderedSelectedVideos.Length; i++)
            {
                var video = orderedSelectedVideos[i];

                // Generate file path
                var number   = (i + 1).ToString().PadLeft(orderedSelectedVideos.Length.ToString().Length, '0');
                var fileName = FileNameGenerator.GenerateFileName(_settingsService.FileNameTemplate, video, SelectedFormat, number);
                var filePath = Path.Combine(dirPath, fileName);

                // Ensure file paths are unique because user will not be able to confirm overwrites
                filePath = FileEx.MakeUniqueFilePath(filePath);

                // Create empty file to "lock in" the file path
                FileEx.CreateDirectoriesForFile(filePath);
                FileEx.CreateEmptyFile(filePath);

                // Create download view model
                var download = _viewModelFactory.CreateDownloadViewModel(video, filePath, SelectedFormat);

                // Add to list
                downloads.Add(download);
            }

            // Close dialog
            Close(downloads);
        }