Initial Commit
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
bin/
|
||||
obj/
|
||||
.vs/
|
||||
6
App.config
Normal file
6
App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
22
App.cs
Normal file
22
App.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ytdlp_gui
|
||||
{
|
||||
internal static class App
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Main());
|
||||
}
|
||||
}
|
||||
}
|
||||
86
Download.Designer.cs
generated
Normal file
86
Download.Designer.cs
generated
Normal file
@ -0,0 +1,86 @@
|
||||
namespace ytdlp_gui
|
||||
{
|
||||
partial class Download
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.lblStatus = new System.Windows.Forms.Label();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.progressBar = new System.Windows.Forms.ProgressBar();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lblStatus
|
||||
//
|
||||
this.lblStatus.AutoSize = true;
|
||||
this.lblStatus.Location = new System.Drawing.Point(13, 13);
|
||||
this.lblStatus.Name = "lblStatus";
|
||||
this.lblStatus.Size = new System.Drawing.Size(139, 25);
|
||||
this.lblStatus.TabIndex = 0;
|
||||
this.lblStatus.Text = "Connecting...";
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Abort;
|
||||
this.btnCancel.Location = new System.Drawing.Point(625, 41);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(110, 40);
|
||||
this.btnCancel.TabIndex = 7;
|
||||
this.btnCancel.Text = "Cancel";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
//
|
||||
// progressBar
|
||||
//
|
||||
this.progressBar.Location = new System.Drawing.Point(18, 41);
|
||||
this.progressBar.Name = "progressBar";
|
||||
this.progressBar.Size = new System.Drawing.Size(601, 40);
|
||||
this.progressBar.TabIndex = 8;
|
||||
//
|
||||
// Download
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(747, 102);
|
||||
this.Controls.Add(this.progressBar);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.Controls.Add(this.lblStatus);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.Name = "Download";
|
||||
this.Text = "Download";
|
||||
this.Load += new System.EventHandler(this.Download_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label lblStatus;
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
private System.Windows.Forms.ProgressBar progressBar;
|
||||
}
|
||||
}
|
||||
86
Download.cs
Normal file
86
Download.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ytdlp_gui
|
||||
{
|
||||
public partial class Download : Form
|
||||
{
|
||||
public Download(string url)
|
||||
{
|
||||
ytdlp = new YTdlp();
|
||||
this.url = url;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Download_Load(object sender, EventArgs e)
|
||||
{
|
||||
// Get windows user download folder
|
||||
string user = Environment.GetEnvironmentVariable("USERNAME");
|
||||
string workdir = @"C:\Users\"+user+@"\Downloads\";
|
||||
|
||||
process = ytdlp.Download(url, false, workdir);
|
||||
|
||||
process.Start += (_sender, start_event) =>
|
||||
{
|
||||
lblStatus.Text = String.Format(
|
||||
"Connecting to %s...",
|
||||
start_event.provider
|
||||
);
|
||||
};
|
||||
|
||||
process.Progress += (_sender, prog_event) =>
|
||||
{
|
||||
int progress = (int)(prog_event.progress * 100 + 0.5);
|
||||
this.Text = "Downloading - " + progress.ToString() + "%";
|
||||
lblStatus.Text = prog_event.file;
|
||||
progressBar.Value = progress;
|
||||
};
|
||||
|
||||
process.Finished += (_sender, finish_event) =>
|
||||
{
|
||||
Regex regex = new Regex(@"^(.+)\s\[\w+\](\.[\w.]+)$");
|
||||
Match match = regex.Match(finish_event.file);
|
||||
|
||||
if (!match.Success)
|
||||
{
|
||||
MessageBox.Show(this, "Could not find the file we just downloaded...", "Uhhh...");
|
||||
this.Close();
|
||||
}
|
||||
|
||||
string newFile = match.Groups[1].Value + match.Groups[2].Value;
|
||||
|
||||
string filePath = Path.Combine(workdir, finish_event.file);
|
||||
string newFilePath = Path.Combine(workdir, newFile);
|
||||
|
||||
System.IO.File.Move(filePath, newFilePath);
|
||||
System.IO.File.SetLastWriteTime(newFilePath, DateTime.Now);
|
||||
|
||||
this.Close();
|
||||
};
|
||||
|
||||
// Can run in background :)
|
||||
_ = process.Run();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
protected string url;
|
||||
protected YTdlp ytdlp;
|
||||
protected YTdlpProcess process;
|
||||
}
|
||||
}
|
||||
120
Download.resx
Normal file
120
Download.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
12
FFmpeg.cs
Normal file
12
FFmpeg.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ytdlp_gui
|
||||
{
|
||||
internal class FFmpeg
|
||||
{
|
||||
}
|
||||
}
|
||||
241
Main.Designer.cs
generated
Normal file
241
Main.Designer.cs
generated
Normal file
@ -0,0 +1,241 @@
|
||||
namespace ytdlp_gui
|
||||
{
|
||||
partial class Main
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.textUrl = new System.Windows.Forms.TextBox();
|
||||
this.checkDownloadPlaylist = new System.Windows.Forms.CheckBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.textPlaylistFolder = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.checkPlaylistFolder = new System.Windows.Forms.CheckBox();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.comboConvertFormat = new System.Windows.Forms.ComboBox();
|
||||
this.checkConvert = new System.Windows.Forms.CheckBox();
|
||||
this.btnDownload = new System.Windows.Forms.Button();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.checkAudioOnly = new System.Windows.Forms.CheckBox();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(13, 13);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(66, 25);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "URL: ";
|
||||
//
|
||||
// textUrl
|
||||
//
|
||||
this.textUrl.Location = new System.Drawing.Point(86, 6);
|
||||
this.textUrl.Name = "textUrl";
|
||||
this.textUrl.Size = new System.Drawing.Size(702, 31);
|
||||
this.textUrl.TabIndex = 1;
|
||||
//
|
||||
// checkDownloadPlaylist
|
||||
//
|
||||
this.checkDownloadPlaylist.AutoSize = true;
|
||||
this.checkDownloadPlaylist.Enabled = false;
|
||||
this.checkDownloadPlaylist.Location = new System.Drawing.Point(25, 178);
|
||||
this.checkDownloadPlaylist.Name = "checkDownloadPlaylist";
|
||||
this.checkDownloadPlaylist.Size = new System.Drawing.Size(212, 29);
|
||||
this.checkDownloadPlaylist.TabIndex = 2;
|
||||
this.checkDownloadPlaylist.Text = "Download playlist";
|
||||
this.checkDownloadPlaylist.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.textPlaylistFolder);
|
||||
this.groupBox1.Controls.Add(this.label2);
|
||||
this.groupBox1.Controls.Add(this.checkPlaylistFolder);
|
||||
this.groupBox1.Enabled = false;
|
||||
this.groupBox1.Location = new System.Drawing.Point(18, 58);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(373, 108);
|
||||
this.groupBox1.TabIndex = 3;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Playlist";
|
||||
//
|
||||
// textPlaylistFolder
|
||||
//
|
||||
this.textPlaylistFolder.Location = new System.Drawing.Point(94, 60);
|
||||
this.textPlaylistFolder.Name = "textPlaylistFolder";
|
||||
this.textPlaylistFolder.Size = new System.Drawing.Size(273, 31);
|
||||
this.textPlaylistFolder.TabIndex = 2;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(7, 67);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(80, 25);
|
||||
this.label2.TabIndex = 1;
|
||||
this.label2.Text = "Name: ";
|
||||
//
|
||||
// checkPlaylistFolder
|
||||
//
|
||||
this.checkPlaylistFolder.AutoSize = true;
|
||||
this.checkPlaylistFolder.Location = new System.Drawing.Point(12, 30);
|
||||
this.checkPlaylistFolder.Name = "checkPlaylistFolder";
|
||||
this.checkPlaylistFolder.Size = new System.Drawing.Size(177, 29);
|
||||
this.checkPlaylistFolder.TabIndex = 0;
|
||||
this.checkPlaylistFolder.Text = "Save to folder";
|
||||
this.checkPlaylistFolder.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.label3);
|
||||
this.groupBox2.Controls.Add(this.comboConvertFormat);
|
||||
this.groupBox2.Controls.Add(this.checkConvert);
|
||||
this.groupBox2.Enabled = false;
|
||||
this.groupBox2.Location = new System.Drawing.Point(397, 58);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(391, 108);
|
||||
this.groupBox2.TabIndex = 4;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Convert";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(6, 67);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(91, 25);
|
||||
this.label3.TabIndex = 3;
|
||||
this.label3.Text = "Format: ";
|
||||
//
|
||||
// comboConvertFormat
|
||||
//
|
||||
this.comboConvertFormat.FormattingEnabled = true;
|
||||
this.comboConvertFormat.Items.AddRange(new object[] {
|
||||
"mp4",
|
||||
"mp3"});
|
||||
this.comboConvertFormat.Location = new System.Drawing.Point(103, 58);
|
||||
this.comboConvertFormat.Name = "comboConvertFormat";
|
||||
this.comboConvertFormat.Size = new System.Drawing.Size(282, 33);
|
||||
this.comboConvertFormat.TabIndex = 2;
|
||||
this.comboConvertFormat.Text = "mp4";
|
||||
//
|
||||
// checkConvert
|
||||
//
|
||||
this.checkConvert.AutoSize = true;
|
||||
this.checkConvert.Checked = true;
|
||||
this.checkConvert.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.checkConvert.Location = new System.Drawing.Point(11, 30);
|
||||
this.checkConvert.Name = "checkConvert";
|
||||
this.checkConvert.Size = new System.Drawing.Size(119, 29);
|
||||
this.checkConvert.TabIndex = 0;
|
||||
this.checkConvert.Text = "Convert";
|
||||
this.checkConvert.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnDownload
|
||||
//
|
||||
this.btnDownload.Location = new System.Drawing.Point(535, 172);
|
||||
this.btnDownload.Name = "btnDownload";
|
||||
this.btnDownload.Size = new System.Drawing.Size(138, 40);
|
||||
this.btnDownload.TabIndex = 5;
|
||||
this.btnDownload.Text = "Download";
|
||||
this.btnDownload.UseVisualStyleBackColor = true;
|
||||
this.btnDownload.Click += new System.EventHandler(this.btnDownload_Click);
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btnCancel.Location = new System.Drawing.Point(678, 172);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(110, 40);
|
||||
this.btnCancel.TabIndex = 6;
|
||||
this.btnCancel.Text = "Cancel";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
//
|
||||
// checkAudioOnly
|
||||
//
|
||||
this.checkAudioOnly.AutoSize = true;
|
||||
this.checkAudioOnly.Enabled = false;
|
||||
this.checkAudioOnly.Location = new System.Drawing.Point(244, 178);
|
||||
this.checkAudioOnly.Name = "checkAudioOnly";
|
||||
this.checkAudioOnly.Size = new System.Drawing.Size(145, 29);
|
||||
this.checkAudioOnly.TabIndex = 7;
|
||||
this.checkAudioOnly.Text = "Audio only";
|
||||
this.checkAudioOnly.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// Main
|
||||
//
|
||||
this.AcceptButton = this.btnDownload;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(192F, 192F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.CancelButton = this.btnCancel;
|
||||
this.ClientSize = new System.Drawing.Size(800, 224);
|
||||
this.Controls.Add(this.checkAudioOnly);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.Controls.Add(this.btnDownload);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.checkDownloadPlaylist);
|
||||
this.Controls.Add(this.textUrl);
|
||||
this.Controls.Add(this.label1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "Main";
|
||||
this.Text = "Youtube Downloader";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Main_FormClosing);
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox textUrl;
|
||||
private System.Windows.Forms.CheckBox checkDownloadPlaylist;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.CheckBox checkPlaylistFolder;
|
||||
private System.Windows.Forms.TextBox textPlaylistFolder;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.ComboBox comboConvertFormat;
|
||||
private System.Windows.Forms.CheckBox checkConvert;
|
||||
private System.Windows.Forms.Button btnDownload;
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.CheckBox checkAudioOnly;
|
||||
}
|
||||
}
|
||||
|
||||
51
Main.cs
Normal file
51
Main.cs
Normal file
@ -0,0 +1,51 @@
|
||||
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 ytdlp_gui
|
||||
{
|
||||
public partial class Main : Form
|
||||
{
|
||||
public Main()
|
||||
{
|
||||
downloads = new List<Download>();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void btnDownload_Click(object sender, EventArgs e)
|
||||
{
|
||||
Download download = new Download(textUrl.Text);
|
||||
download.Show();
|
||||
downloads.Add(download);
|
||||
|
||||
download.FormClosed += (_sender, _e) => {
|
||||
downloads.Remove(download);
|
||||
};
|
||||
}
|
||||
|
||||
private void Main_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (downloads.Count == 0)
|
||||
return;
|
||||
var window = MessageBox.Show(
|
||||
"Close the window?\nClosing current window will cancel current downloads!",
|
||||
"Are you sure?",
|
||||
MessageBoxButtons.YesNo
|
||||
);
|
||||
e.Cancel = (window == DialogResult.No);
|
||||
}
|
||||
|
||||
protected List<Download> downloads;
|
||||
}
|
||||
}
|
||||
120
Main.resx
Normal file
120
Main.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
49
Program.cs
Normal file
49
Program.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ytdlp_gui
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public Program(string name)
|
||||
{
|
||||
// Check for extension
|
||||
if (Path.GetExtension(name) == "")
|
||||
// If missing, add .exe as default
|
||||
name += ".exe";
|
||||
|
||||
// Is the program next to us?
|
||||
string exe_path = System.Reflection.Assembly.GetEntryAssembly().Location;
|
||||
string exe_directory = Path.GetDirectoryName(exe_path);
|
||||
program = Path.Combine(exe_directory, name);
|
||||
|
||||
// Did we find it?
|
||||
if (File.Exists(program))
|
||||
// Finish if we did
|
||||
return;
|
||||
|
||||
// Otherwise...
|
||||
// Get list of PATHs on Windows
|
||||
string[] paths = System.Environment.GetEnvironmentVariable("PATH").Split(';');
|
||||
|
||||
// Check for program on every path
|
||||
foreach (string path in paths)
|
||||
{
|
||||
program = Path.Combine(path, name);
|
||||
if (File.Exists(program))
|
||||
// Finish if we found it
|
||||
return;
|
||||
}
|
||||
|
||||
// We could not find the program
|
||||
throw new Exception("Could not find "+name);
|
||||
}
|
||||
|
||||
public readonly string program;
|
||||
}
|
||||
}
|
||||
33
Properties/AssemblyInfo.cs
Normal file
33
Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ytdlp-gui")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ytdlp-gui")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2025")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("f54bd871-4c4e-4069-bfbf-b91a89e2a9ff")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
71
Properties/Resources.Designer.cs
generated
Normal file
71
Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,71 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ytdlp_gui.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ytdlp_gui.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
Properties/Resources.resx
Normal file
117
Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
30
Properties/Settings.Designer.cs
generated
Normal file
30
Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ytdlp_gui.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
Properties/Settings.settings
Normal file
7
Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
234
YTdlp.cs
Normal file
234
YTdlp.cs
Normal file
@ -0,0 +1,234 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Deployment.Application;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ytdlp_gui
|
||||
{
|
||||
public class YTdlpStartEventArgs : EventArgs
|
||||
{
|
||||
public YTdlpStartEventArgs(string provider)
|
||||
{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public readonly string provider;
|
||||
}
|
||||
|
||||
public class YTdlpProgressEventArgs : EventArgs
|
||||
{
|
||||
public YTdlpProgressEventArgs(string provider, string action, string file, float progress)
|
||||
{
|
||||
this.provider = provider;
|
||||
this.action = action;
|
||||
this.file = file;
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
public readonly string provider;
|
||||
public readonly string action;
|
||||
public readonly string file;
|
||||
public readonly float progress;
|
||||
}
|
||||
|
||||
public class YTdlpErrorEventArgs : EventArgs
|
||||
{
|
||||
public YTdlpErrorEventArgs(string provider, string error)
|
||||
{
|
||||
this.provider = provider;
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public readonly string provider;
|
||||
public readonly string error;
|
||||
}
|
||||
|
||||
public class YTdlpFinishedEventArgs : EventArgs
|
||||
{
|
||||
public YTdlpFinishedEventArgs(string provider, string file, string[] files)
|
||||
{
|
||||
this.provider = provider;
|
||||
this.file = file;
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
public readonly string provider;
|
||||
public readonly string file;
|
||||
public readonly string[] files;
|
||||
}
|
||||
|
||||
public class YTdlpProcess
|
||||
{
|
||||
public YTdlpProcess(Process process)
|
||||
{
|
||||
this.process = process;
|
||||
|
||||
ci = (CultureInfo)CultureInfo.CurrentCulture.Clone();
|
||||
ci.NumberFormat.CurrencyDecimalSeparator = ".";
|
||||
|
||||
files = new List<string>();
|
||||
|
||||
this.download_regex = new Regex(@"([0-9.]+)%\s+of\s+([0-9.]+)(\w+)\s+at\s+([0-9.]+)(\w+\/\w+)\sETA\s(\d+:\d+)");
|
||||
this.download_finish_regex = new Regex(@"([0-9.]+)%\s+of\s+([0-9.]+)(\w+)\s+in\s+(\d+:\d+:\d+)\s+at\s+([0-9.]+)(\w+\/\w+)");
|
||||
this.merge_regex = new Regex(@"Merging formats into ""(.+)""");
|
||||
}
|
||||
|
||||
public async Task<string> Run()
|
||||
{
|
||||
process.Start();
|
||||
|
||||
string line = null;
|
||||
bool first = true;
|
||||
while ((line = await process.StandardOutput.ReadLineAsync()) != null)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
provider = (new Regex(@"\w+")).Match(line).Value;
|
||||
first = false;
|
||||
}
|
||||
line = line.Trim();
|
||||
|
||||
if (line.StartsWith("[info] "))
|
||||
ProgInfo(line.Substring("[info] ".Length).TrimStart());
|
||||
|
||||
if (line.StartsWith("[download] "))
|
||||
ProgDownload(line.Substring("[download] ".Length).TrimStart());
|
||||
|
||||
if (line.StartsWith("[Merger] "))
|
||||
ProgMerger(line.Substring("[Merger] ".Length).TrimStart());
|
||||
}
|
||||
|
||||
Finished?.Invoke(this, new YTdlpFinishedEventArgs(provider, File, files.ToArray()));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void ProgInfo(string line)
|
||||
{
|
||||
}
|
||||
|
||||
protected void ProgDownload(string line)
|
||||
{
|
||||
const string dest_str = "Destination: ";
|
||||
if (line.StartsWith(dest_str))
|
||||
File = line.Substring(dest_str.Length);
|
||||
|
||||
Match match;
|
||||
|
||||
match = download_regex.Match(line);
|
||||
if (match.Success)
|
||||
{
|
||||
GroupCollection groups = match.Groups;
|
||||
float progress = ParseFloat( groups[1].Value ) / 100 ;
|
||||
float total = ParseFloat( groups[2].Value ) ;
|
||||
string total_unit = groups[3].Value ;
|
||||
float speed = ParseFloat( groups[4].Value ) ;
|
||||
string speed_unit = groups[5].Value ;
|
||||
string estamated_time = groups[6].Value ;
|
||||
|
||||
YTdlpProgressEventArgs args = new YTdlpProgressEventArgs(
|
||||
provider,
|
||||
"download",
|
||||
File,
|
||||
progress
|
||||
);
|
||||
Progress?.Invoke(this, args);
|
||||
}
|
||||
|
||||
match = download_finish_regex.Match(line);
|
||||
if (match.Success)
|
||||
{
|
||||
GroupCollection groups = match.Groups;
|
||||
float progress = ParseFloat( groups[1].Value ) / 100 ;
|
||||
float total = ParseFloat( groups[2].Value ) ;
|
||||
string total_unit = groups[3].Value ;
|
||||
string total_time = groups[4].Value ;
|
||||
float speed = ParseFloat( groups[5].Value ) ;
|
||||
string speed_unit = groups[6].Value ;
|
||||
|
||||
YTdlpProgressEventArgs args = new YTdlpProgressEventArgs(
|
||||
provider,
|
||||
"download",
|
||||
File,
|
||||
progress
|
||||
);
|
||||
Progress?.Invoke(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
protected void ProgMerger(string line)
|
||||
{
|
||||
Match match;
|
||||
|
||||
match = merge_regex.Match(line);
|
||||
if (match.Success)
|
||||
{
|
||||
File = match.Groups[1].Value;
|
||||
|
||||
YTdlpProgressEventArgs args = new YTdlpProgressEventArgs(
|
||||
provider,
|
||||
"merge",
|
||||
file,
|
||||
1
|
||||
);
|
||||
Progress?.Invoke(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
private float ParseFloat(string str)
|
||||
{
|
||||
return float.Parse(str, NumberStyles.Any, ci);
|
||||
}
|
||||
|
||||
private readonly Process process;
|
||||
private readonly CultureInfo ci;
|
||||
private readonly Regex download_regex;
|
||||
private readonly Regex download_finish_regex;
|
||||
private readonly Regex merge_regex;
|
||||
private string provider;
|
||||
private string File {
|
||||
get { return file; }
|
||||
set { file = value; if (!files.Contains(value)) files.Add(value); }
|
||||
}
|
||||
private string file;
|
||||
private List<string> files;
|
||||
|
||||
public event EventHandler<YTdlpStartEventArgs> Start;
|
||||
public event EventHandler<YTdlpProgressEventArgs> Progress;
|
||||
public event EventHandler<YTdlpErrorEventArgs> Error;
|
||||
public event EventHandler<YTdlpFinishedEventArgs> Finished;
|
||||
}
|
||||
|
||||
public class YTdlp : Program
|
||||
{
|
||||
public YTdlp() : base("yt-dlp")
|
||||
{
|
||||
}
|
||||
|
||||
public YTdlpProcess Download(string url, bool download_playlist, string workdir)
|
||||
{
|
||||
Process process = new Process();
|
||||
process.StartInfo.FileName = program;
|
||||
process.StartInfo.Arguments = String.Format(
|
||||
"{0} \"{1}\"",
|
||||
download_playlist ? "--yes-playlist" : "--no-playlist",
|
||||
url.Replace("\"", "\"\"\"")
|
||||
);
|
||||
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.CreateNoWindow = true;
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.RedirectStandardError = true;
|
||||
process.StartInfo.WorkingDirectory = workdir;
|
||||
|
||||
return new YTdlpProcess(process);
|
||||
}
|
||||
}
|
||||
}
|
||||
95
ytdlp-gui.csproj
Normal file
95
ytdlp-gui.csproj
Normal file
@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{F54BD871-4C4E-4069-BFBF-B91A89E2A9FF}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>ytdlp_gui</RootNamespace>
|
||||
<AssemblyName>ytdlp-gui</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Download.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Download.Designer.cs">
|
||||
<DependentUpon>Download.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FFmpeg.cs" />
|
||||
<Compile Include="Main.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Main.Designer.cs">
|
||||
<DependentUpon>Main.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="App.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="YTdlp.cs" />
|
||||
<EmbeddedResource Include="Download.resx">
|
||||
<DependentUpon>Download.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Main.resx">
|
||||
<DependentUpon>Main.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
25
ytdlp-gui.sln
Normal file
25
ytdlp-gui.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.13.35931.197 d17.13
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ytdlp-gui", "ytdlp-gui.csproj", "{F54BD871-4C4E-4069-BFBF-B91A89E2A9FF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F54BD871-4C4E-4069-BFBF-B91A89E2A9FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F54BD871-4C4E-4069-BFBF-B91A89E2A9FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F54BD871-4C4E-4069-BFBF-B91A89E2A9FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F54BD871-4C4E-4069-BFBF-B91A89E2A9FF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {AF0893DB-6F02-4532-8669-00B970001D38}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Reference in New Issue
Block a user