Update to 0.1.0.0 fixing internal issues.
This commit is contained in:
parent
3df47d4cfe
commit
9c357525ca
4
YTDLNetFrontEnd/YTDLNetFrontEnd/Main.Designer.cs
generated
4
YTDLNetFrontEnd/YTDLNetFrontEnd/Main.Designer.cs
generated
@ -120,7 +120,7 @@
|
|||||||
this.buttonInstall.Margin = new System.Windows.Forms.Padding(0);
|
this.buttonInstall.Margin = new System.Windows.Forms.Padding(0);
|
||||||
this.buttonInstall.Name = "buttonInstall";
|
this.buttonInstall.Name = "buttonInstall";
|
||||||
this.buttonInstall.Size = new System.Drawing.Size(142, 24);
|
this.buttonInstall.Size = new System.Drawing.Size(142, 24);
|
||||||
this.buttonInstall.TabIndex = 4;
|
this.buttonInstall.TabIndex = 1;
|
||||||
this.buttonInstall.Text = "Install";
|
this.buttonInstall.Text = "Install";
|
||||||
this.buttonInstall.UseVisualStyleBackColor = true;
|
this.buttonInstall.UseVisualStyleBackColor = true;
|
||||||
this.buttonInstall.Click += new System.EventHandler(this.buttonInstall_Click);
|
this.buttonInstall.Click += new System.EventHandler(this.buttonInstall_Click);
|
||||||
@ -132,7 +132,7 @@
|
|||||||
this.buttonExit.Margin = new System.Windows.Forms.Padding(0);
|
this.buttonExit.Margin = new System.Windows.Forms.Padding(0);
|
||||||
this.buttonExit.Name = "buttonExit";
|
this.buttonExit.Name = "buttonExit";
|
||||||
this.buttonExit.Size = new System.Drawing.Size(142, 24);
|
this.buttonExit.Size = new System.Drawing.Size(142, 24);
|
||||||
this.buttonExit.TabIndex = 5;
|
this.buttonExit.TabIndex = 2;
|
||||||
this.buttonExit.Text = "Exit";
|
this.buttonExit.Text = "Exit";
|
||||||
this.buttonExit.UseVisualStyleBackColor = true;
|
this.buttonExit.UseVisualStyleBackColor = true;
|
||||||
this.buttonExit.Click += new System.EventHandler(this.buttonExit_Click);
|
this.buttonExit.Click += new System.EventHandler(this.buttonExit_Click);
|
||||||
|
@ -55,25 +55,34 @@ namespace com.captainalm.YTDLNetFrontEnd
|
|||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setEnableButtons(bool value)
|
||||||
|
{
|
||||||
|
this.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
buttonExit.Enabled = value;
|
||||||
|
buttonInstall.Enabled = value;
|
||||||
|
buttonGo.Enabled = value;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
private void backgroundWorkerMain_DoWork(object sender, DoWorkEventArgs e)
|
private void backgroundWorkerMain_DoWork(object sender, DoWorkEventArgs e)
|
||||||
{
|
{
|
||||||
switch ((BWArg)e.Argument)
|
switch ((BWArg)e.Argument)
|
||||||
{
|
{
|
||||||
case BWArg.Install:
|
case BWArg.Install:
|
||||||
this.Invoke(new Action(() => {
|
setEnableButtons(false);
|
||||||
buttonExit.Enabled = false;
|
|
||||||
buttonInstall.Enabled = false;
|
|
||||||
}));
|
|
||||||
|
|
||||||
var loctxt =
|
var loctxt =
|
||||||
YTDL.executeInstall((YTDL.getInstalled() != ApplicationType.Unavailable) ? YTDL.getInstalled() :
|
YTDL.executeInstall((YTDL.getInstalled() != ApplicationType.Unavailable) ? YTDL.getInstalled() :
|
||||||
(((Control.ModifierKeys & Keys.Shift) == Keys.Shift) ? ApplicationType.YoutubeDL : ApplicationType.YT_DLP),
|
(((Control.ModifierKeys & Keys.Shift) == Keys.Shift) ? ApplicationType.YoutubeDL : ApplicationType.YT_DLP),
|
||||||
YTDL.getInstalled() != ApplicationType.Unavailable) +
|
YTDL.getInstalled() != ApplicationType.Unavailable) +
|
||||||
Environment.NewLine;
|
Environment.NewLine;
|
||||||
|
|
||||||
this.Invoke(new Action(() =>
|
this.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
textBoxOutput.Text += loctxt;
|
textBoxOutput.AppendText(loctxt);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (YTDL.getInstalled() != ApplicationType.Unavailable)
|
if (YTDL.getInstalled() != ApplicationType.Unavailable)
|
||||||
{
|
{
|
||||||
this.Invoke(new Action(() =>
|
this.Invoke(new Action(() =>
|
||||||
@ -82,18 +91,11 @@ namespace com.captainalm.YTDLNetFrontEnd
|
|||||||
buttonInstall.Text = "Update";
|
buttonInstall.Text = "Update";
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
this.Invoke(new Action(() =>
|
|
||||||
{
|
setEnableButtons(true);
|
||||||
buttonInstall.Enabled = true;
|
|
||||||
buttonExit.Enabled = true;
|
|
||||||
}));
|
|
||||||
break;
|
break;
|
||||||
case BWArg.Go:
|
case BWArg.Go:
|
||||||
this.Invoke(new Action(() =>
|
setEnableButtons(false);
|
||||||
{
|
|
||||||
buttonExit.Enabled = false;
|
|
||||||
buttonGo.Enabled = false;
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (theProcess != null)
|
if (theProcess != null)
|
||||||
{
|
{
|
||||||
@ -106,6 +108,7 @@ namespace com.captainalm.YTDLNetFrontEnd
|
|||||||
this.Invoke(new Action(() =>
|
this.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
theTarget = textBoxEntry.Text;
|
theTarget = textBoxEntry.Text;
|
||||||
|
textBoxEntry.Text = "";
|
||||||
}));
|
}));
|
||||||
|
|
||||||
theProcess = YTDL.executeApplication(theTarget);
|
theProcess = YTDL.executeApplication(theTarget);
|
||||||
@ -119,11 +122,8 @@ namespace com.captainalm.YTDLNetFrontEnd
|
|||||||
theProcess.EnableRaisingEvents = true;
|
theProcess.EnableRaisingEvents = true;
|
||||||
theProcess.WaitForExit();
|
theProcess.WaitForExit();
|
||||||
}
|
}
|
||||||
this.Invoke(new Action(() =>
|
|
||||||
{
|
setEnableButtons(true);
|
||||||
buttonGo.Enabled = true;
|
|
||||||
buttonExit.Enabled = true;
|
|
||||||
}));
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -132,24 +132,37 @@ namespace com.captainalm.YTDLNetFrontEnd
|
|||||||
|
|
||||||
void theProcess_Exited(object sender, EventArgs e)
|
void theProcess_Exited(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
theProcess.CancelOutputRead();
|
try
|
||||||
theProcess.CancelErrorRead();
|
{
|
||||||
|
theProcess.CancelOutputRead();
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
theProcess.CancelErrorRead();
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void theProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
|
void theProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Data.Equals("")) return;
|
if (e.Data == null || e.Data.Equals("")) return;
|
||||||
this.Invoke(new Action(() =>
|
this.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
textBoxOutput.Text += "Error: " + e.Data + Environment.NewLine;
|
textBoxOutput.AppendText("Error: " + e.Data + Environment.NewLine);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void theProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
|
void theProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (e.Data == null || e.Data.Equals("")) return;
|
||||||
this.Invoke(new Action(() =>
|
this.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
textBoxOutput.Text += e.Data + Environment.NewLine;
|
textBoxOutput.AppendText(e.Data + Environment.NewLine);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.0.0.0")]
|
[assembly: AssemblyVersion("0.1.0.0")]
|
||||||
[assembly: AssemblyFileVersion("0.0.0.0")]
|
[assembly: AssemblyFileVersion("0.1.0.0")]
|
||||||
|
@ -46,26 +46,14 @@ namespace com.captainalm.YTDLNetFrontEnd
|
|||||||
default:
|
default:
|
||||||
return "Invalid Package Name";
|
return "Invalid Package Name";
|
||||||
}
|
}
|
||||||
var pipProSet = new ProcessStartInfo(findExecutableInPath("python"), "-m pip install " + packageName + ((update) ? " --upgrade" : "")) { UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true };
|
var pipProSet = new ProcessStartInfo(findExecutableInPath("python"), "-m pip install " + packageName + ((update) ? " --upgrade" : ""))
|
||||||
|
{ UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true, StandardOutputEncoding = Encoding.UTF8, StandardErrorEncoding = Encoding.UTF8 };
|
||||||
using (var pipPro = Process.Start(pipProSet))
|
using (var pipPro = Process.Start(pipProSet))
|
||||||
{
|
{
|
||||||
using (var errTSR = new ThreadedStreamReader(pipPro.StandardError.BaseStream))
|
var rpote = new ReadProcessOutputToEnd(pipPro);
|
||||||
{
|
pipPro.WaitForExit();
|
||||||
using (var outTSR = new ThreadedStreamReader(pipPro.StandardOutput.BaseStream))
|
if (!rpote.getError().Equals("")) return rpote.getError();
|
||||||
{
|
return rpote.getOutput();
|
||||||
pipPro.WaitForExit();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var terr = System.Text.Encoding.UTF8.GetString(errTSR.getData());
|
|
||||||
var tout = System.Text.Encoding.UTF8.GetString(outTSR.getData());
|
|
||||||
if (terr != "") return terr; else return tout;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return "Exception:" + e.GetType().FullName + ":" + e.Message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,11 +64,13 @@ namespace com.captainalm.YTDLNetFrontEnd
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var pipProSet = new ProcessStartInfo(findExecutableInPath("python"), "-m pip freeze") {UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true};
|
var pipProSet = new ProcessStartInfo(findExecutableInPath("python"), "-m pip freeze")
|
||||||
|
{ UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true, StandardOutputEncoding = Encoding.UTF8, StandardErrorEncoding = Encoding.UTF8 };
|
||||||
using (var pipPro = Process.Start(pipProSet))
|
using (var pipPro = Process.Start(pipProSet))
|
||||||
{
|
{
|
||||||
var theList = pipPro.StandardOutput.ReadToEnd();
|
var rpote = new ReadProcessOutputToEnd(pipPro);
|
||||||
pipPro.WaitForExit();
|
pipPro.WaitForExit();
|
||||||
|
var theList = rpote.getOutput();
|
||||||
if (theList.Contains("yt-dlp")) installed = ApplicationType.YT_DLP;
|
if (theList.Contains("yt-dlp")) installed = ApplicationType.YT_DLP;
|
||||||
else if (theList.Contains("youtube-dl")) installed = ApplicationType.YoutubeDL;
|
else if (theList.Contains("youtube-dl")) installed = ApplicationType.YoutubeDL;
|
||||||
else installed = ApplicationType.Unavailable;
|
else installed = ApplicationType.Unavailable;
|
||||||
@ -114,44 +104,67 @@ namespace com.captainalm.YTDLNetFrontEnd
|
|||||||
YT_DLP = 2
|
YT_DLP = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
class ThreadedStreamReader : IDisposable
|
class ReadProcessOutputToEnd : IDisposable
|
||||||
{
|
{
|
||||||
Thread theThread;
|
Process theProcess;
|
||||||
MemoryStream msToRet;
|
string tout = "";
|
||||||
Stream theStream;
|
string terr = "";
|
||||||
public ThreadedStreamReader(Stream streamIn)
|
|
||||||
|
|
||||||
|
public ReadProcessOutputToEnd(Process processIn)
|
||||||
{
|
{
|
||||||
theStream = streamIn;
|
theProcess = processIn;
|
||||||
msToRet = new MemoryStream();
|
theProcess.BeginOutputReadLine();
|
||||||
theThread = new Thread(thread_execute);
|
theProcess.BeginErrorReadLine();
|
||||||
theThread.IsBackground = true;
|
theProcess.OutputDataReceived += theProcess_OutputDataReceived;
|
||||||
theThread.Start();
|
theProcess.ErrorDataReceived += theProcess_ErrorDataReceived;
|
||||||
|
theProcess.Exited += theProcess_Exited;
|
||||||
|
theProcess.EnableRaisingEvents = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void thread_execute()
|
void theProcess_Exited(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int b;
|
theProcess.CancelOutputRead();
|
||||||
while ((b = theStream.ReadByte()) != -1) msToRet.WriteByte((byte)b);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
theProcess.CancelErrorRead();
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
{
|
{
|
||||||
var msg = System.Text.Encoding.UTF8.GetBytes("Exception:" + e.GetType().FullName + ":" + e.Message);
|
|
||||||
msToRet.Write(msg, 0, msg.Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getData()
|
void theProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
|
||||||
{
|
{
|
||||||
theThread.Join();
|
if (e.Data == null || e.Data.Equals("")) return;
|
||||||
return msToRet.ToArray();
|
terr += e.Data + Environment.NewLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
void theProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data == null || e.Data.Equals("")) return;
|
||||||
|
tout += e.Data + Environment.NewLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string getOutput()
|
||||||
|
{
|
||||||
|
return tout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string getError()
|
||||||
|
{
|
||||||
|
return terr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
theThread.Join();
|
theProcess.Close();
|
||||||
msToRet.Close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user