-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
66 lines (51 loc) · 2.23 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System.Linq;
using System.Windows;
namespace YouTubeDownloader
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
bool hideTerminal;
public MainWindow()
{
InitializeComponent();
FFBox.Text = Properties.Settings.Default.FFPath;
string outputDir = System.IO.Directory.GetCurrentDirectory() + @"\Videos\%(title)s-%(id)s.%(ext)s";
}
private void DownloadButton_Click(object sender, RoutedEventArgs e)
{
string outputDir = System.IO.Directory.GetCurrentDirectory() + @"\Videos\%(title)s-%(id)s.%(ext)s";
if (hideTerminal == true)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = $"/C youtube-dl --no-mark-watched --geo-bypass --yes-playlist --format bestvideo+bestaudio --output {outputDir} --ffmpeg-location {this.FFBox.Text} {this.DownloadBox.Text}";
process.StartInfo = startInfo;
process.Start();
}
else
{
string strCmdText;
strCmdText = $"/C youtube-dl --no-mark-watched --geo-bypass --yes-playlist --format bestvideo+bestaudio --output {outputDir} --ffmpeg-location {this.FFBox.Text} {this.DownloadBox.Text}";
System.Diagnostics.Process.Start("CMD.exe", strCmdText);
}
}
private void FFBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
Properties.Settings.Default.FFPath = FFBox.Text;
Properties.Settings.Default.Save();
}
private void TerminalCheckBox_Checked(object sender, RoutedEventArgs e)
{
hideTerminal = true;
}
private void TerminalCheckBox_Unchecked(object sender, RoutedEventArgs e)
{
hideTerminal = false;
}
}
}