diff --git a/App.config b/App.config index 4ee8770d..c7b7e67b 100644 --- a/App.config +++ b/App.config @@ -88,6 +88,9 @@ 18 + + 0 + @@ -174,7 +177,7 @@ - 1.6 + 1.61 diff --git a/Classes/Download.cs b/Classes/Download.cs index 0422ca76..e207d087 100644 --- a/Classes/Download.cs +++ b/Classes/Download.cs @@ -23,8 +23,8 @@ class Download { /// /// Argument for best Audio quality downloads /// - public static string bestAudio = " -x --audio-format best --audio-quality best"; - public static string myAudio = " -x --audio-format mp3 --audio-quality best"; + public static string bestAudio = " -x --audio-format best --audio-quality 320K"; + public static string myAudio = " -x --audio-format mp3 --audio-quality 256K"; /// /// Tooltip @@ -56,11 +56,11 @@ public static bool downloadBest(string URL, string downloadDir, int downloadType if (downloadType == 0 && Settings.Default.sortDownloads) { // Video - setArgs = URL + " -f \"bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best\" " + outputFolder; + setArgs = URL + " -f \"bestvideo[ext=mp4]/best\" " + outputFolder; } else if (downloadType == 1 && Settings.Default.sortDownloads) { // Audio - setArgs = URL + " -x --audio-format best --audio-quality best " + outputFolder; + setArgs = URL + " -x --audio-format mp3 --audio-quality 256K " + outputFolder; } else if (downloadType == 2 && Settings.Default.sortDownloads) { // Custom @@ -88,32 +88,53 @@ public static bool downloadBest(string URL, string downloadDir, int downloadType } } + /// + /// Downloads with custom formatting & quality options. Must be specified. + /// + /// The URL of the video to download. + /// The directory where it'll be saved to. + /// The download type (0 = Video, 1 = Audio) + /// Custom arguments to pass. + /// The format you want the download to be. + /// The quality you want the download to be. + /// public static bool downloadCustom(string URL, string downloadDir, int downloadType, string args = null, string format = "best", string quality = "best") { - if (downloadType != 1) { - MessageBox.Show("Custom downloads are only limited to audio formats for the time being."); - return false; + //if (downloadType != 1) { + // MessageBox.Show("Custom downloads are only limited to audio formats for the time being."); + // return false; + //} + Process Downloader = new Process(); + Downloader.StartInfo.FileName = Settings.Default.youtubedlDir; + string dl = Settings.Default.youtubedlDir; + + switch (downloadType) { + case 0: + if (format != "best") { + args = URL + "bestVideo,bestAudio -f " + format + " -o \"" + downloadDir + "/%(title)s-%(id)s.%(ext)s\""; + } + else { + args = URL + bestVideo + " -o \"" + downloadDir + "/%(title)s-%(id)s.%(ext)s\""; + } + break; + case 1: + if (quality != "best") + quality += "K"; + else + quality = "320K"; + + args = URL + " -x --audio-format " + format + " --audio-quality " + quality + " -o \"" + downloadDir + "/%(title)s-%(id)s.%(ext)s\""; + break; + case 2: + break; } - try { - Process Downloader = new Process(); - Downloader.StartInfo.FileName = Settings.Default.youtubedlDir; - - switch (downloadType) { - case 0: - args = bestVideo; - break; - case 1: - args = " -x --audio-format " + format + " --audio-quality " + quality + "K"; - break; - case 2: - break; - } - - Downloader.StartInfo.Arguments = args; - Downloader.Start(); + Downloader.StartInfo.Arguments = args; + Downloader.Start(); - GC.Collect(); - return true; + GC.Collect(); + return true; + try { + } catch (Exception ex) { if (Settings.Default.logErrorFiles) diff --git a/Classes/ErrorLog.cs b/Classes/ErrorLog.cs index 9c610854..58e07b1a 100644 --- a/Classes/ErrorLog.cs +++ b/Classes/ErrorLog.cs @@ -31,13 +31,13 @@ public static bool logError(string errMessage, string filename) { try { if (filename.EndsWith(".log")) { filename = filename.Replace(".log", ""); } if (Settings.Default.logErrorFiles) { - if (File.Exists(Application.StartupPath + @"\YChanEx Errors\" + filename + ".log")) - File.Delete(Application.StartupPath + @"\YChanEx Errors\" + filename + ".log"); + if (File.Exists(Application.StartupPath + @"\youtube-dl-gui Errors\" + filename + ".log")) + File.Delete(Application.StartupPath + @"\youtube-dl-gui Errors\" + filename + ".log"); - File.Create(Application.StartupPath + @"\YChanEx Errors\" + filename + ".log").Dispose(); - File.WriteAllText(Application.StartupPath + @"\YChanEx Errors\" + filename + ".log", errMessage); + File.Create(Application.StartupPath + @"\youtube-dl-gui Errors\" + filename + ".log").Dispose(); + File.WriteAllText(Application.StartupPath + @"\youtube-dl-gui Errors\" + filename + ".log", errMessage); - MessageBox.Show("An error has occured and has been logged. Check \"\\YChanEx Errors\\\"" + filename + ".log for information."); + MessageBox.Show("An error has occured and has been logged. Check \"\\youtube-dl-gui Errors\\\"" + filename + ".log for information."); } else { MessageBox.Show("An error has occured.\n\n" + errMessage.ToString(), filename); } return true; diff --git a/Forms/frmMain.Designer.cs b/Forms/frmMain.Designer.cs index 1ffe4a0a..d8c4c060 100644 --- a/Forms/frmMain.Designer.cs +++ b/Forms/frmMain.Designer.cs @@ -247,7 +247,6 @@ private void InitializeComponent() // cbFormat // this.cbFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cbFormat.Enabled = false; this.cbFormat.FormattingEnabled = true; this.cbFormat.Location = new System.Drawing.Point(104, 92); this.cbFormat.Name = "cbFormat"; diff --git a/Forms/frmMain.cs b/Forms/frmMain.cs index e241a9d6..94431e75 100644 --- a/Forms/frmMain.cs +++ b/Forms/frmMain.cs @@ -122,6 +122,13 @@ private void frmMain_Shown(object sender, EventArgs e) { cbBit.SelectedIndex = 18; + if (Settings.Default.dlType == 0) + rbVideo.Checked = true; + else if (Settings.Default.dlType == 1) + rbAudio.Checked = true; + else + rbCustom.Checked = true; + txtArgs.Text = Settings.Default.savedArgs; } private void frmMain_SizeChanged(object sender, EventArgs e) { @@ -182,11 +189,10 @@ private void reloadVideoParams() { cbFormat.Items.Clear(); cbFormat.Items.Add("best"); - //cbFormat.Items.Add("avi"); - //cbFormat.Items.Add("flv"); - //cbFormat.Items.Add("mp4"); - //cbFormat.Items.Add("mkv"); - //cbFormat.Items.Add("webm"); + cbFormat.Items.Add("3gp"); + cbFormat.Items.Add("flv"); + cbFormat.Items.Add("mp4"); + cbFormat.Items.Add("webm"); } private void reloadConvAudio() { @@ -249,7 +255,7 @@ private void txtURL_TextChanged(object sender, EventArgs e) { } private void rbVideo_CheckedChanged(object sender, EventArgs e) { if (rbVideo.Checked) { cbQuality.Enabled = false; - cbFormat.Enabled = false; + cbFormat.Enabled = true; txtArgs.ReadOnly = true; reloadVideoParams(); txtArgs.Clear(); @@ -307,23 +313,31 @@ private void btnDownload_Click(object sender, EventArgs e) { else if (rbCustom.Checked) dlType = 2; - if (Download.downloadCustom("\"" + txtURL.Text + "\"", Settings.Default.DownloadDir, dlType, null, cbFormat.Text, cbQuality.Text)) + if (Download.downloadCustom(txtURL.Text, Settings.Default.DownloadDir, dlType, null, cbFormat.Text, cbQuality.Text)) if (Settings.Default.ClearURL == true) { txtURL.Clear(); Clipboard.Clear(); } - if (Settings.Default.saveDlParams) - if (rbVideo.Checked) { + + if (rbVideo.Checked) { + if (Settings.Default.saveDlParams) { Settings.Default.vidFormat = cbFormat.SelectedIndex; Settings.Default.vidQuality = cbQuality.SelectedIndex; } - else if (rbAudio.Checked) { + Settings.Default.dlType = 0; + } + else if (rbAudio.Checked) { + if (Settings.Default.saveDlParams) { Settings.Default.audFormat = cbFormat.SelectedIndex; Settings.Default.audQuality = cbQuality.SelectedIndex; } - - if (Settings.Default.saveArgs) - Settings.Default.savedArgs = txtArgs.Text; + Settings.Default.dlType = 1; + } + else { + if (Settings.Default.saveArgs) + Settings.Default.savedArgs = txtArgs.Text; + Settings.Default.dlType = 2; + } Settings.Default.Save(); } diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index 3cbfb8d5..b9094d37 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -37,7 +37,7 @@ public string ytDLVersion { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("1.6")] + [global::System.Configuration.DefaultSettingValueAttribute("1.61")] public decimal currentVersion { get { return ((decimal)(this["currentVersion"])); diff --git a/Properties/Settings.settings b/Properties/Settings.settings index dce56433..f27df18f 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -6,7 +6,7 @@ 2017.09.01 - 1.6 + 1.61 False diff --git a/Resources/Settings.Designer.cs b/Resources/Settings.Designer.cs index 0f3de737..e909b864 100644 --- a/Resources/Settings.Designer.cs +++ b/Resources/Settings.Designer.cs @@ -310,5 +310,17 @@ public int convVidBit { this["convVidBit"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int dlType { + get { + return ((int)(this["dlType"])); + } + set { + this["dlType"] = value; + } + } } } diff --git a/Resources/Settings.settings b/Resources/Settings.settings index 4abdc019..18066f78 100644 --- a/Resources/Settings.settings +++ b/Resources/Settings.settings @@ -74,5 +74,8 @@ 18 + + 0 + \ No newline at end of file