public void OnViewLoaded()
        {
            // Select first download option matching last used format or first non-audio-only download option
            SelectedDownloadOption =
                AvailableDownloadOptions.FirstOrDefault(o => o.Format == _settingsService.LastFormat) ??
                AvailableDownloadOptions.OrderByDescending(o => !string.IsNullOrWhiteSpace(o.Label)).FirstOrDefault();

            SelectedSubtitleOption =
                AvailableSubtitleOptions.FirstOrDefault(o => o.Language.Code == _settingsService.LastSubtitleLanguageCode) ??
                AvailableSubtitleOptions.OrderByDescending(o => !string.IsNullOrWhiteSpace(o.Language.Name)).FirstOrDefault();
        }
Exemplo n.º 2
0
 public async Task DownloadSubtitleAsync(SubtitleOption subtitleOption, string filePath)
 {
     await _youtube.Videos.ClosedCaptions.DownloadAsync(subtitleOption.ClosedCaptionTrackInfos.FirstOrDefault(),
                                                        $"{Path.GetDirectoryName(filePath)}{Path.DirectorySeparatorChar}{Path.GetFileNameWithoutExtension(filePath)}.srt");
 }
Exemplo n.º 3
0
        public static DownloadViewModel CreateDownloadViewModel(this IViewModelFactory factory, Video video,
                                                                string filePath, string format, DownloadOption downloadOption, SubtitleOption subtitleOption)
        {
            var viewModel = factory.CreateDownloadViewModel();

            viewModel.Video          = video;
            viewModel.FilePath       = filePath;
            viewModel.Format         = format;
            viewModel.DownloadOption = downloadOption;
            viewModel.SubtitleOption = subtitleOption;

            return(viewModel);
        }