Skip to content

Commit

Permalink
2.11 - can you hear me now
Browse files Browse the repository at this point in the history
Fixed quality being required when downloading, causing any videos with the best quality being lower than the one selected be undownloadable without selecting "best" (Download.cs)
Fixed audio not downloading (Download.cs)
Fixed the unnecessary amount of new calls in settings, for some reason... (frmSettings)
Moved 8K to the top, it fits better there. (frmMain, Download.cs)

Not available in this version, but being worked on:
Added batch downloading (frmBatch)
Added file merging (frmMain, Covert.cs)

Those instances of future additions are not visible in youtube-dl-gui-compatible because youtube-dl-gui-compatible is a build with new additions omitted until they're completed due to the differences in the code due to .NET Framework 3.5. Consider the compatible branch a different application due to the amount of code changes.
  • Loading branch information
murrty1 authored Jul 24, 2019
1 parent 2d324f8 commit cf76a83
Show file tree
Hide file tree
Showing 14 changed files with 707 additions and 79 deletions.
2 changes: 1 addition & 1 deletion App.config
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
<applicationSettings>
<youtube_dl_gui.Properties.Settings>
<setting name="appVersion" serializeAs="String">
<value>2.1</value>
<value>2.11</value>
</setting>
<setting name="stubVersion" serializeAs="String">
<value>1</value>
Expand Down
56 changes: 54 additions & 2 deletions Classes/Convert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,64 @@ public static bool convertFile(string input, string output, int convType = -1) {
}
}

public static bool mergeFiles(string videoFile, string audioFile, bool delete) {
public static bool mergeFiles(string input1, string input2, string output, bool mergeAudio, bool delete) {
try {
string[] formatsV = { ".avi", ".flv", ".mkv", ".mov", ".mp4", ".webm", ".wmv" };
bool input1IsVideo = false; // is input1 video?

Process merger = new Process();
merger.StartInfo.UseShellExecute = true;
merger.StartInfo.FileName = "ffmpeg.exe";
for (int i = 0; i < formatsV.Length; i++) {
if (input1.EndsWith(formatsV[i])) {
input1IsVideo = true;
break;
}
}

if (mergeAudio) {
if (input1IsVideo) {
merger.StartInfo.Arguments = " -i \"" + input1 + "\" \"" + Path.GetDirectoryName(input1) + "\\tempaudio.mp3\"";
}
else {
merger.StartInfo.Arguments = " -i \"" + input2 + "\" \"" + Path.GetDirectoryName(input2) + "\\tempaudio.mp3\"";
}

merger.Start();
merger.WaitForExit();


if (input1IsVideo) {
merger.StartInfo.Arguments = " -i \"" + input2 + "\" -i \"" + Path.GetDirectoryName(input1) + "\\tempaudio.mp3\" -filter_complex amix=inputs=2:duration=longest \"" + Path.GetDirectoryName(input1) + "\\final.mp3\"";
}
else {
merger.StartInfo.Arguments = " -i \"" + input1 + "\" -i \"" + Path.GetDirectoryName(input2) + "\\tempaudio.mp3\" -filter_complex amix=inputs=2:duration=longest \"" + Path.GetDirectoryName(input2) + "\\final.mp3\"";
}
merger.Start();
merger.WaitForExit();

if (input1IsVideo) {
merger.StartInfo.Arguments = " -i \"" + input1 + "\" -i \"" + Path.GetDirectoryName(input1) + "\\final.mp3\" -map 0:v -map 1:a -longest -c copy -y \"" + output + "\"";
}
else {
merger.StartInfo.Arguments = " -i \"" + input2 + "\" -i \"" + Path.GetDirectoryName(input2) + "\\final.mp3\" -map 0:v -map 1:a -longest -c copy -y \"" + output + "\"";
}

merger.Start();
merger.WaitForExit();
}
else {
if (input1IsVideo) {
merger.StartInfo.Arguments = " -i \"" + input1 + "\" -i \"" + input2 + "\" -map 0:v -map 1:a -c copy -y \"" + output + "\"";
}
else {
merger.StartInfo.Arguments = " -i \"" + input1 + "\" -i \"" + input2 + "\" -map 1:v -map 0:a -c copy -y \"" + output + "\"";
}

merger.Start();
}

//merger.StartInfo.Arguments = " -i \"" + videoFile + "\" -i \"" + audioFile + "\" -codec copy \"" + Settings.Default.DownloadDir + "\\Merged\\" + Path.GetFileName(videoFile) + "\"";
merger.Start();
return true;
}
catch (Exception ex) {
Expand Down
30 changes: 15 additions & 15 deletions Classes/Download.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ class Download {
/// Built-in video qualities
/// </summary>
public static string[] videoQualities = {
" -f \"bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 0 best
" -f \"bestvideo[height<=4320][fps>=48]\"", // 1 4320p60
" -f \"bestvideo[height<=4320][fps<=32]\"", // 2 4320p30
" -f \"bestvideo[height<=2160][fps>=48]\"", // 3 2160p60
" -f \"bestvideo[height<=2160][fps<=32]\"", // 4 2160p30
" -f \"bestvideo[height<=1440][fps>=48]\"", // 5 1440p60
" -f \"bestvideo[height<=1440][fps<=32]\"", // 6 1440p30
" -f \"bestvideo[height<=1080][fps>=48]\"", // 7 1080p60
" -f \"bestvideo[height<=1080][fps<=32]\"", // 8 1080p30
" -f \"bestvideo[height<=720][fps>=48]\"", // 9 720p60
" -f \"bestvideo[height<=720][fps<=32]\"", // 10 720p30
" -f \"bestvideo[height<=480]\"", // 11 480p
" -f \"bestvideo[height<=360]\"", // 12 360p
" -f \"bestvideo[height<=240]\"", // 13 240p
" -f \"bestvideo[height<=144]\"" // 14 144p
" -f \"bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 0 best
" -f \"bestvideo[height<=4320][fps>=48]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 1 4320p60
" -f \"bestvideo[height<=4320][fps<=32]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 2 4320p30
" -f \"bestvideo[height<=2160][fps>=48]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 3 2160p60
" -f \"bestvideo[height<=2160][fps<=32]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 4 2160p30
" -f \"bestvideo[height<=1440][fps>=48]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 5 1440p60
" -f \"bestvideo[height<=1440][fps<=32]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 6 1440p30
" -f \"bestvideo[height<=1080][fps<=60]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 7 1080p60
" -f \"bestvideo[height<=1080][fps<=32]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 8 1080p30
" -f \"bestvideo[height<=720][fps>=48]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 9 720p60
" -f \"bestvideo[height<=720][fps<=32]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 10 720p30
" -f \"bestvideo[height<=480]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 11 480p
" -f \"bestvideo[height<=360]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 12 360p
" -f \"bestvideo[height<=240]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 13 240p
" -f \"bestvideo[height<=144]+bestaudio[ext=m4a]/best[ext=mp4]/best\"" // 14 144p
};
/// <summary>
/// Built-in audio qualities
Expand Down
196 changes: 196 additions & 0 deletions Forms/frmBatch.Designer.cs

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

84 changes: 84 additions & 0 deletions Forms/frmBatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace youtube_dl_gui {
public partial class frmBatch : Form {
public string argsText = string.Empty;

public frmBatch() {
InitializeComponent();
if (System.IO.File.Exists(Environment.CurrentDirectory + "\\args.txt")) {
argsText = System.IO.File.ReadAllText(Environment.CurrentDirectory + "\\args.txt");

if (argsText.Replace(" ", "") == "")
argsText = "<empty args.txt>";
}
else {
argsText = "<args.txt unavailable>";
}
}

private void btnAdd_Click(object sender, EventArgs e) {
if (comboBox1.SelectedIndex < 0) {
return;
}

listLink.Items.Add(textBox1.Text);
listType.Items.Add(comboBox1.GetItemText(comboBox1.SelectedItem));
switch (comboBox1.SelectedIndex) {
case 2:
listArgs.Items.Add(argsText);
break;
case 3:
if (Saved.Default.downloadArgs.Replace(" ", "") == "") {
listArgs.Items.Add("<saved args empty>");
}
else {
listArgs.Items.Add(Saved.Default.downloadArgs);
}
break;
case 4:
listArgs.Items.Add(textBox2.Text);
break;
default:
listArgs.Items.Add("<n/a>");
break;
}
if (comboBox1.SelectedIndex < 4) {
}
else {
}

textBox1.Clear();
textBox2.Clear();
}

private void btnRemove_Click(object sender, EventArgs e) {
if (listLink.SelectedIndex == -1) {
return;
}

int currentIndex = listLink.SelectedIndex;
listLink.Items.RemoveAt(currentIndex);
listType.Items.RemoveAt(currentIndex);
listArgs.Items.RemoveAt(currentIndex);
listLink.SelectedIndex = currentIndex;
}

private void btnStart_Click(object sender, EventArgs e) {

}

private void listLink_SelectedIndexChanged(object sender, EventArgs e) {
listType.SelectedIndex = listLink.SelectedIndex;
listArgs.SelectedIndex = listLink.SelectedIndex;
}
}
}
Loading

0 comments on commit cf76a83

Please sign in to comment.