Skip to content

Commit

Permalink
📃 Playlist update. Bump version to v0.6.
Browse files Browse the repository at this point in the history
- Added toggle for downloading the whole playlist instead of only the video in the link.
- Added button to open custom download path.
- The scrollbar in the result TextBox now always scrolls to end on text change.
- Added toggle for automatically update youtube-dl on startup.
- The toggle status of OverrideFormats and CustomPath now persists after restart.
  • Loading branch information
database64128 committed May 10, 2020
1 parent 00d1e88 commit e9c956f
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 18 deletions.
2 changes: 1 addition & 1 deletion AboutDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Margin="8 8 8 8" Style="{StaticResource MaterialDesignHeadline5TextBlock}" TextWrapping="Wrap">About - v0.5 Build 20200424</TextBlock>
<TextBlock Grid.Row="0" Margin="8 8 8 8" Style="{StaticResource MaterialDesignHeadline5TextBlock}" TextWrapping="Wrap">About - v0.6 Build 20200510</TextBlock>
<TextBlock Grid.Row="1" Margin="8 8 8 8" Style="{StaticResource MaterialDesignSubtitle1TextBlock}" TextWrapping="Wrap">Cube YouTube Downloader is a simple GUI wrapper for <Hyperlink RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="https://github.com/ytdl-org/youtube-dl">https://github.com/ytdl-org/youtube-dl</Hyperlink></TextBlock>
<TextBlock Grid.Row="2" Margin="8 8 8 8" Style="{StaticResource MaterialDesignSubtitle1TextBlock}" TextWrapping="Wrap">For more information please visit <Hyperlink RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="https://github.com/database64128/youtube-dl-wpf">https://github.com/database64128/youtube-dl-wpf</Hyperlink></TextBlock>
<Button Grid.Row="3"
Expand Down
19 changes: 15 additions & 4 deletions Home.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Margin="8,8,8,8" Style="{StaticResource MaterialDesignHeadline5TextBlock}">Start your download</TextBlock>
<TextBlock Grid.Row="0" Margin="8,8,8,8" Style="{StaticResource MaterialDesignHeadline5TextBlock}">Start your download</TextBlock>
<StackPanel Grid.Row="1">
<StackPanel Orientation="Horizontal" >
<TextBlock Style="{StaticResource MaterialDesignSubtitle1TextBlock}" VerticalAlignment="Center" Margin="8,8,8,8">Video Link</TextBlock>
Expand Down Expand Up @@ -77,10 +77,15 @@
IsChecked="{Binding Thumbnail}"/>
<TextBlock VerticalAlignment="Center" Margin="0,8,8,8">Download Thumbnail</TextBlock>
<ToggleButton
x:Name="SubtitlesToggle"
x:Name="subtitlesToggle"
Margin="8,8,8,8"
IsChecked="{Binding Subtitles}"/>
<TextBlock VerticalAlignment="Center" Margin="0,8,8,8">Download Subtitles</TextBlock>
<ToggleButton
x:Name="playlistToggle"
Margin="8"
IsChecked="{Binding Playlist}"/>
<TextBlock VerticalAlignment="Center" Margin="0,8,8,8">Download the whole Playlist</TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2">
<ToggleButton
Expand All @@ -93,14 +98,19 @@
Margin="8,8,2,8"
Width="384"
IsEnabled="{Binding Path=IsChecked, ElementName=pathToggle}"
Text="{Binding DownloadPath}"/>
Text="{Binding DownloadPath, UpdateSourceTrigger=PropertyChanged}"/>
<Button
x:Name="browseButton"
Margin="2,0,8,0"
Style="{StaticResource MaterialDesignOutlinedButton}"
IsEnabled="{Binding Path=IsChecked, ElementName=pathToggle}"
Command="{Binding BrowseFolder}"
CommandParameter="DownloadPath">Browse</Button>
<Button
x:Name="openFolderButton"
Margin="2,0,8,0"
Style="{StaticResource MaterialDesignOutlinedButton}"
Command="{Binding OpenFolder}">Open Folder</Button>
</StackPanel>
</Grid>
</StackPanel>
Expand All @@ -117,7 +127,8 @@
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"
materialDesign:HintAssist.Hint="Output from youtube-dl"
Text="{Binding Output}" />
Text="{Binding Output}"
TextChanged="resultTextBox_TextChanged"/>
</StackPanel>
</Grid>
</UserControl>
5 changes: 5 additions & 0 deletions Home.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ public Home()
InitializeComponent();
DataContext = new HomeViewModel();
}

private void resultTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
resultTextBox.ScrollToEnd();
}
}
}
54 changes: 50 additions & 4 deletions HomeViewModel.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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();
}

Expand All @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -305,6 +350,7 @@ public string DownloadPath
set
{
SetProperty(ref _downloadPath, value);
_openFolder.InvokeCanExecuteChanged();
AppSettings.settings.DownloadPath = _downloadPath;
AppSettings.SaveSettings();
}
Expand Down
25 changes: 17 additions & 8 deletions Settings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand All @@ -31,41 +32,49 @@
CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}"/>
<TextBlock VerticalAlignment="Center" Margin="0,8,8,8" Text="{Binding ColorMode}" />
</StackPanel>
<TextBlock Grid.Row="2" Grid.Column="0" Style="{StaticResource MaterialDesignSubtitle1TextBlock}" VerticalAlignment="Center" Margin="8,8,8,8"><Italic>youtube-dl</Italic> Path</TextBlock>
<TextBox
<TextBlock Grid.Row="2" Grid.Column="0" Style="{StaticResource MaterialDesignSubtitle1TextBlock}" VerticalAlignment="Center" Margin="8,8,8,8">Update <Italic>youtube-dl</Italic> on Startup</TextBlock>
<ToggleButton
Grid.Row="2"
Grid.Column="1"
x:Name="autoUpdateDlToggle"
Margin="8"
IsChecked="{Binding AutoUpdateDl}"
HorizontalAlignment="Left"/>
<TextBlock Grid.Row="3" Grid.Column="0" Style="{StaticResource MaterialDesignSubtitle1TextBlock}" VerticalAlignment="Center" Margin="8,8,8,8"><Italic>youtube-dl</Italic> Path</TextBlock>
<TextBox
Grid.Row="3"
Grid.Column="1"
x:Name="dlPathTextBox"
Margin="2,8,2,8"
Width="384"
Text="{Binding DlPath}"/>
<Button
Grid.Row="2"
Grid.Row="3"
Grid.Column="2"
x:Name="dlPathBrowseButton"
Margin="2,0,8,0"
Style="{StaticResource MaterialDesignOutlinedButton}"
Command="{Binding BrowseExe}"
CommandParameter="youtube-dl">Browse</Button>
<TextBlock Grid.Row="3" Grid.Column="0" Style="{StaticResource MaterialDesignSubtitle1TextBlock}" VerticalAlignment="Center" Margin="8,8,8,8"><Italic>ffmpeg</Italic> Path</TextBlock>
<TextBlock Grid.Row="4" Grid.Column="0" Style="{StaticResource MaterialDesignSubtitle1TextBlock}" VerticalAlignment="Center" Margin="8,8,8,8"><Italic>ffmpeg</Italic> Path</TextBlock>
<TextBox
Grid.Row="3"
Grid.Row="4"
Grid.Column="1"
x:Name="ffmpegPathTextBox"
Margin="2,8,2,8"
Width="384"
Text="{Binding FfmpegPath}"/>
<Button
Grid.Row="3"
Grid.Row="4"
Grid.Column="2"
x:Name="ffmpegPathBrowseButton"
Margin="2,0,8,0"
Style="{StaticResource MaterialDesignOutlinedButton}"
Command="{Binding BrowseExe}"
CommandParameter="ffmpeg">Browse</Button>
<TextBlock Grid.Row="4" Grid.Column="0" Style="{StaticResource MaterialDesignSubtitle1TextBlock}" VerticalAlignment="Center" Margin="8,8,8,8">Proxy</TextBlock>
<TextBlock Grid.Row="5" Grid.Column="0" Style="{StaticResource MaterialDesignSubtitle1TextBlock}" VerticalAlignment="Center" Margin="8,8,8,8">Proxy</TextBlock>
<TextBox
Grid.Row="4"
Grid.Row="5"
Grid.Column="1"
x:Name="proxyTextBox"
Margin="2,8,2,8"
Expand Down
7 changes: 7 additions & 0 deletions SettingsJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ namespace youtube_dl_wpf
public class SettingsJson
{
public bool DarkMode { get; set; }
public bool AutoUpdateDl { get; set; }
public string DlPath { get; set; }
public string FfmpegPath { get; set; }
public string Proxy { get; set; }

public bool OverrideFormats { get; set; }
public string VideoFormat { get; set; }
public string AudioFormat { get; set; }
public bool CustomPath { get; set; }
public string DownloadPath { get; set; }
}

Expand All @@ -32,6 +35,8 @@ public static void LoadSettings()
if (!File.Exists("Settings.json"))
{
settings = new SettingsJson();
settings.AutoUpdateDl = true;
SaveSettings();
return;
}
using var _settingsJson = new FileStream("Settings.json", FileMode.OpenOrCreate);
Expand All @@ -43,6 +48,8 @@ public static async Task LoadSettingsAsync()
if (!File.Exists("Settings.json"))
{
settings = new SettingsJson();
settings.AutoUpdateDl = true;
SaveSettings();
return;
}
using var _settingsJson = new FileStream("Settings.json", FileMode.OpenOrCreate);
Expand Down
13 changes: 13 additions & 0 deletions SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public SettingsViewModel()
{
//appSettings = new AppSettings();
_darkMode = AppSettings.settings.DarkMode;
_autoUpdateDl = AppSettings.settings.AutoUpdateDl;
_dlPath = AppSettings.settings.DlPath;
_ffmpegPath = AppSettings.settings.FfmpegPath;
_proxy = AppSettings.settings.Proxy;
Expand All @@ -23,6 +24,7 @@ public SettingsViewModel()
}

private bool _darkMode; // default to light mode
private bool _autoUpdateDl; // auto update youtube-dl by default
private string _colorMode = "Light Mode"; // color mode text for TextBlock
private string _dlPath; // youtube-dl path
private string _ffmpegPath;
Expand Down Expand Up @@ -75,6 +77,17 @@ public bool DarkMode
}
}

public bool AutoUpdateDl
{
get => _autoUpdateDl;
set
{
SetProperty(ref _autoUpdateDl, value);
AppSettings.settings.AutoUpdateDl = _autoUpdateDl;
AppSettings.SaveSettings();
}
}

public string ColorMode
{
get => _colorMode;
Expand Down
2 changes: 1 addition & 1 deletion youtube-dl-wpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Product>Cube YouTube Downloader</Product>
<Company>database64128</Company>
<Authors>database64128</Authors>
<Version>0.5.0</Version>
<Version>0.6.0</Version>
<ApplicationIcon>CubeYouTubeDownloader.ico</ApplicationIcon>
</PropertyGroup>

Expand Down

0 comments on commit e9c956f

Please sign in to comment.