Skip to content

Commit

Permalink
v1.61
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
murrty1 authored Feb 4, 2018
1 parent 0a537ee commit 07788f3
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 48 deletions.
5 changes: 4 additions & 1 deletion App.config
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
<setting name="convVidBit" serializeAs="String">
<value>18</value>
</setting>
<setting name="dlType" serializeAs="String">
<value>0</value>
</setting>
</youtube_dl_gui.Resources.Settings>
<youtube_dl_gui.Settings>
<setting name="HoverURL" serializeAs="String">
Expand Down Expand Up @@ -174,7 +177,7 @@
<applicationSettings>
<youtube_dl_gui.Properties.Settings>
<setting name="currentVersion" serializeAs="String">
<value>1.6</value>
<value>1.61</value>
</setting>
</youtube_dl_gui.Properties.Settings>
</applicationSettings>
Expand Down
73 changes: 47 additions & 26 deletions Classes/Download.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class Download {
/// <summary>
/// Argument for best Audio quality downloads
/// </summary>
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";

/// <summary>
/// Tooltip
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -88,32 +88,53 @@ public static bool downloadBest(string URL, string downloadDir, int downloadType
}
}

/// <summary>
/// Downloads with custom formatting & quality options. Must be specified.
/// </summary>
/// <param name="URL">The URL of the video to download.</param>
/// <param name="downloadDir">The directory where it'll be saved to.</param>
/// <param name="downloadType">The download type (0 = Video, 1 = Audio)</param>
/// <param name="args">Custom arguments to pass.</param>
/// <param name="format">The format you want the download to be.</param>
/// <param name="quality">The quality you want the download to be.</param>
/// <returns></returns>
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)
Expand Down
10 changes: 5 additions & 5 deletions Classes/ErrorLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion Forms/frmMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 27 additions & 13 deletions Forms/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Value Profile="(Default)">2017.09.01</Value>
</Setting>
<Setting Name="currentVersion" Type="System.Decimal" Scope="Application">
<Value Profile="(Default)">1.6</Value>
<Value Profile="(Default)">1.61</Value>
</Setting>
<Setting Name="runningUpdate" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
Expand Down
12 changes: 12 additions & 0 deletions Resources/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Resources/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,8 @@
<Setting Name="convVidBit" Type="System.Int32" Scope="User">
<Value Profile="(Default)">18</Value>
</Setting>
<Setting Name="dlType" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings>
</SettingsFile>

0 comments on commit 07788f3

Please sign in to comment.