diff --git a/AboutDialog.xaml b/AboutDialog.xaml index 1fe206b20..3c83a5940 100644 --- a/AboutDialog.xaml +++ b/AboutDialog.xaml @@ -13,7 +13,7 @@ - About - v0.5 Build 20200424 + About - v0.6 Build 20200510 Cube YouTube Downloader is a simple GUI wrapper for https://github.com/ytdl-org/youtube-dl For more information please visit https://github.com/database64128/youtube-dl-wpf + @@ -117,7 +127,8 @@ VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" materialDesign:HintAssist.Hint="Output from youtube-dl" - Text="{Binding Output}" /> + Text="{Binding Output}" + TextChanged="resultTextBox_TextChanged"/> diff --git a/Home.xaml.cs b/Home.xaml.cs index 2fa6caa52..9f4894337 100644 --- a/Home.xaml.cs +++ b/Home.xaml.cs @@ -12,5 +12,10 @@ public Home() InitializeComponent(); DataContext = new HomeViewModel(); } + + private void resultTextBox_TextChanged(object sender, TextChangedEventArgs e) + { + resultTextBox.ScrollToEnd(); + } } } diff --git a/HomeViewModel.cs b/HomeViewModel.cs index f4eba8e1f..d38a3c194 100644 --- a/HomeViewModel.cs +++ b/HomeViewModel.cs @@ -1,7 +1,9 @@ using System; using System.ComponentModel; using System.Diagnostics; +using System.IO; using System.Text; +using System.Windows; using System.Windows.Input; namespace youtube_dl_wpf @@ -11,14 +13,17 @@ public class HomeViewModel : ViewModelBase public HomeViewModel() { _browseFolder = new DelegateCommand(OnBrowseFolder, (object commandParameter) => true); + _openFolder = new DelegateCommand(OnOpenFolder, CanOpenFolder); _startDownload = new DelegateCommand(OnStartDownload, CanStartDownload); _listFormats = new DelegateCommand(OnListFormats, CanStartDownload); + _overrideFormats = AppSettings.settings.OverrideFormats; _videoFormat = AppSettings.settings.VideoFormat; _audioFormat = AppSettings.settings.AudioFormat; + _customPath = AppSettings.settings.CustomPath; _downloadPath = AppSettings.settings.DownloadPath; - if (!String.IsNullOrEmpty(AppSettings.settings.DlPath)) + if (!String.IsNullOrEmpty(AppSettings.settings.DlPath) && AppSettings.settings.AutoUpdateDl) UpdateDl(); } @@ -29,6 +34,7 @@ public HomeViewModel() private bool _metadata = true; private bool _thumbnail = true; private bool _subtitles = true; + private bool _playlist = false; private bool _customPath; private string _downloadPath; private string _output; @@ -39,6 +45,7 @@ public HomeViewModel() //private Thread t; private readonly DelegateCommand _browseFolder; + private readonly DelegateCommand _openFolder; private readonly DelegateCommand _startDownload; private readonly DelegateCommand _listFormats; @@ -66,6 +73,18 @@ private void OnBrowseFolder(object commandParameter) } } + private void OnOpenFolder(object commandParameter) + { + try + { + Process.Start("explorer.exe", _downloadPath); + } + catch (Exception e) + { + MessageBox.Show(e.Message); + } + } + private void OnStartDownload(object commandParameter) { /*t = new Thread(DoStartDownload); @@ -118,6 +137,10 @@ private void DoStartDownload(object sender, DoWorkEventArgs e) dlProcess.StartInfo.ArgumentList.Add("--write-sub"); dlProcess.StartInfo.ArgumentList.Add("--embed-subs"); } + if (_playlist) + { + dlProcess.StartInfo.ArgumentList.Add("--yes-playlist"); + } if (_customPath) { dlProcess.StartInfo.ArgumentList.Add("-o"); @@ -175,9 +198,14 @@ private void DoListFormats(object sender, DoWorkEventArgs e) } } + private bool CanOpenFolder(object commandParameter) + { + return !String.IsNullOrEmpty(_downloadPath) && Directory.Exists(_downloadPath); + } + private bool CanStartDownload(object commandParameter) { - return !(String.IsNullOrEmpty(Link) || String.IsNullOrEmpty(AppSettings.settings.DlPath) || _freezeButton); + return !String.IsNullOrEmpty(Link) && !String.IsNullOrEmpty(AppSettings.settings.DlPath) && !_freezeButton; } private void UpdateDl() @@ -233,6 +261,7 @@ private void DlOutputHandler(object sendingProcess, DataReceivedEventArgs outLin } public ICommand BrowseFolder => _browseFolder; + public ICommand OpenFolder => _openFolder; public ICommand StartDownload => _startDownload; public ICommand ListFormats => _listFormats; @@ -250,7 +279,12 @@ public string Link public bool OverrideFormats { get => _overrideFormats; - set => SetProperty(ref _overrideFormats, value); + set + { + SetProperty(ref _overrideFormats, value); + AppSettings.settings.OverrideFormats = _overrideFormats; + AppSettings.SaveSettings(); + } } public string VideoFormat @@ -293,10 +327,21 @@ public bool Subtitles set => SetProperty(ref _subtitles, value); } + public bool Playlist + { + get => _playlist; + set => SetProperty(ref _playlist, value); + } + public bool CustomPath { get => _customPath; - set => SetProperty(ref _customPath, value); + set + { + SetProperty(ref _customPath, value); + AppSettings.settings.CustomPath = _customPath; + AppSettings.SaveSettings(); + } } public string DownloadPath @@ -305,6 +350,7 @@ public string DownloadPath set { SetProperty(ref _downloadPath, value); + _openFolder.InvokeCanExecuteChanged(); AppSettings.settings.DownloadPath = _downloadPath; AppSettings.SaveSettings(); } diff --git a/Settings.xaml b/Settings.xaml index 83e4adece..8705855ee 100644 --- a/Settings.xaml +++ b/Settings.xaml @@ -14,6 +14,7 @@ + @@ -31,41 +32,49 @@ CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}"/> - youtube-dl Path - Update youtube-dl on Startup + + youtube-dl Path + - ffmpeg Path + ffmpeg Path - Proxy + Proxy _autoUpdateDl; + set + { + SetProperty(ref _autoUpdateDl, value); + AppSettings.settings.AutoUpdateDl = _autoUpdateDl; + AppSettings.SaveSettings(); + } + } + public string ColorMode { get => _colorMode; diff --git a/youtube-dl-wpf.csproj b/youtube-dl-wpf.csproj index e4e540317..57e38476d 100644 --- a/youtube-dl-wpf.csproj +++ b/youtube-dl-wpf.csproj @@ -9,7 +9,7 @@ Cube YouTube Downloader database64128 database64128 - 0.5.0 + 0.6.0 CubeYouTubeDownloader.ico