Skip to content

Commit

Permalink
Patch release [v4.0.1.0]
Browse files Browse the repository at this point in the history
- Fixed a bug where downloads could not be started again if the previous one failed
- Double-clicking on custom argument text boxes now opens the documentation pages for each redist (forgot to add this)
- History now sorts in descending order
  • Loading branch information
o7q committed Aug 16, 2023
1 parent a1b477a commit 951d569
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 76 deletions.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
~ v4.0.1.0
- Fixed a bug where downloads could not be started again if the previous one failed
- Double-clicking on custom argument text boxes now opens the documentation pages for each redist (forgot to add this)
- History now sorts in descending order

~ v4.0.0.0
- I completely re-wrote MediaDownloader from the ground-up, I fixed several major issues and greatly optimized parts of the code
- Added a feature to queue multiple downloads
Expand Down
4 changes: 2 additions & 2 deletions src/MediaDownloader/MediaDownloader/Init.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static void Main()

if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
{
CustomMessageBox customMessageBox = new CustomMessageBox("An instance of MediaDownloader is already running.\nHaving two or more instances of MediaDownloader running simultaneously can cause issues (file corruption, malfunctioning).\n\nAre you sure you want to continue?\n\nPress OK to continue\nPress X to cancel", true);
CustomMessageBox customMessageBox = new CustomMessageBox("An instance of MediaDownloader is already running.\n\nHaving two or more instances of MediaDownloader running simultaneously\ncan cause issues (file corruption, malfunctioning).\n\nAre you sure you want to continue?\n\nPress OK to continue\nPress CLOSE to cancel", true);
customMessageBox.ShowDialog();
if (customMessageBox.Result == DialogResult.Cancel)
return;
Expand All @@ -32,7 +32,7 @@ static void Main()

if (!ytdlpCheck || !ffmpegCheck)
{
CustomMessageBox customMessageBox = new CustomMessageBox("One or more redist files are missing.\nMediaDownloader will download and install them automatically.\n\nPress OK to continue\nPress X to cancel", true);
CustomMessageBox customMessageBox = new CustomMessageBox("One or more redist files are missing.\nMediaDownloader will download and install them automatically.\n\nPress OK to continue\nPress CLOSE to cancel", true);
customMessageBox.ShowDialog();

if (customMessageBox.Result == DialogResult.Cancel)
Expand Down
2 changes: 2 additions & 0 deletions src/MediaDownloader/MediaDownloader/MainMenu.Designer.cs

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

122 changes: 64 additions & 58 deletions src/MediaDownloader/MediaDownloader/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ namespace MediaDownloader
{
public partial class MainMenu : Form
{
// program events

public MainMenu()
{
InitializeComponent();
Expand All @@ -27,8 +25,8 @@ public MainMenu()

private void Program_Load(object sender, EventArgs e)
{
UpdateListBox(QueueListBox, "MediaDownloader\\config\\queue");
UpdateListBox(HistoryListBox, "MediaDownloader\\config\\history");
UpdateListBox(QueueListBox, "MediaDownloader\\config\\queue", false);
UpdateListBox(HistoryListBox, "MediaDownloader\\config\\history", true);

UpdateVersionLabel();

Expand Down Expand Up @@ -194,16 +192,57 @@ private void QueueRemoveButton_Click(object sender, EventArgs e)
return;

File.Delete("MediaDownloader\\config\\queue\\" + currentQueueItem.OUTPUT_NAME + ".mdq");
UpdateListBox(QueueListBox, "MediaDownloader\\config\\queue");
UpdateListBox(QueueListBox, "MediaDownloader\\config\\queue", false);

if (QueueListBox.Items.Count >= 1)
QueueListBox.SelectedIndex = 0;
}

private void HistoryListBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (HistoryListBox.Items.Count == 0)
return;

CONFIG.HISTORY_SELECTED_INDEX = HistoryListBox.SelectedIndex;
}

private void HistoryLoadButton_Click(object sender, EventArgs e)
{
if (HistoryListBox.SelectedItems.Count == 0)
return;

LoadQueueItem("MediaDownloader\\config\\history\\" + HistoryListBox.SelectedItem + ".mdq");
}

private void HistoryRefreshButton_Click(object sender, EventArgs e)
{
UpdateListBox(HistoryListBox, "MediaDownloader\\config\\history", true);
}

private void HistoryRemoveButton_Click(object sender, EventArgs e)
{
if (HistoryListBox.SelectedItems.Count == 0)
return;

File.Delete("MediaDownloader\\config\\history\\" + HistoryListBox.SelectedItem + ".mdq");
UpdateListBox(HistoryListBox, "MediaDownloader\\config\\history", true);

if (HistoryListBox.Items.Count == 0)
CONFIG.HISTORY_SAVE_INDEX = 0;

if (HistoryListBox.Items.Count >= 1)
HistoryListBox.SelectedIndex = 0;
}

private void HistoryListBox_DrawItem(object sender, DrawItemEventArgs e)
{
DrawListBox(HistoryListBox, e, Color.FromArgb(218, 112, 214));
}

private void SaveQueueItem()
{
WriteQueueItem(currentQueueItem, "MediaDownloader\\config\\queue\\" + currentQueueItem.OUTPUT_NAME + ".mdq");
UpdateListBox(QueueListBox, "MediaDownloader\\config\\queue");
UpdateListBox(QueueListBox, "MediaDownloader\\config\\queue", false);
}

private void LoadQueueItem(string queueItemFile)
Expand Down Expand Up @@ -238,11 +277,6 @@ private void LoadQueueItem(string queueItemFile)
OutputPauseCheckBox.Checked = currentQueueItem.OUTPUT_ENABLE_PAUSE;
}

private void ViewAvailableFormatsButton_Click(object sender, EventArgs e)
{
Task.Run(() => StartProcess("MediaDownloader\\redist\\yt-dlp\\yt-dlp.exe", "-q --ffmpeg-location \"MediaDownloader\\redist\\ffmpeg\\ffmpeg.exe\" --list-formats " + currentQueueItem.URL, "MediaDownloader " + VERSION + " [DEBUG : FORMAT LIST]", true, true));
}

private void OutputChangeLocationButton_Click(object sender, EventArgs e)
{
using (OpenFileDialog selectFolderDialog = new OpenFileDialog())
Expand Down Expand Up @@ -331,6 +365,11 @@ private void OutputClearLocationButton_Click(object sender, EventArgs e)
OutputLocationTextBox.Text = "";
}

private void ViewAvailableFormatsButton_Click(object sender, EventArgs e)
{
Task.Run(() => StartProcess("MediaDownloader\\redist\\yt-dlp\\yt-dlp.exe", "-q --ffmpeg-location \"MediaDownloader\\redist\\ffmpeg\\ffmpeg.exe\" --list-formats " + currentQueueItem.URL, "MediaDownloader " + VERSION + " [DEBUG : FORMAT LIST]", true, true));
}

#region ConfigUpdate
private void UrlTextBox_TextChanged(object sender, EventArgs e)
{
Expand Down Expand Up @@ -627,6 +666,11 @@ private void OutputPauseCheckBox_CheckedChanged(object sender, EventArgs e)
{
currentQueueItem.OUTPUT_ENABLE_PAUSE = OutputPauseCheckBox.Checked;
}

private void HistoryCheckBox_CheckedChanged(object sender, EventArgs e)
{
CONFIG.HISTORY_ENABLE = HistoryCheckBox.Checked;
}
#endregion

private void MenuExpandButton_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -752,6 +796,15 @@ private void QueueListBox_DrawItem(object sender, DrawItemEventArgs e)
DrawListBox(QueueListBox, e, Color.FromArgb(147, 112, 219));
}

private void OutputYtdlpArgumentsTextBox_DoubleClick(object sender, EventArgs e)
{
Process.Start("https://github.com/yt-dlp/yt-dlp#usage-and-options");
}

private void OutputFfmpegArgumentsTextBox_DoubleClick(object sender, EventArgs e)
{
Process.Start("https://ffmpeg.org/ffmpeg.html");
}

private void CloseButton_Click(object sender, EventArgs e)
{
Expand All @@ -769,7 +822,6 @@ private void MinimizeButton_Click(object sender, EventArgs e)
WindowState = FormWindowState.Minimized;
}


private void TitlebarPanel_MouseDown(object sender, MouseEventArgs e)
{
MoveForm(Handle, e);
Expand All @@ -786,51 +838,5 @@ private void VersionLabel_MouseDown(object sender, MouseEventArgs e)
{
MoveForm(Handle, e);
}

private void HistoryRefreshButton_Click(object sender, EventArgs e)
{
UpdateListBox(HistoryListBox, "MediaDownloader\\config\\history");
}

private void HistoryListBox_DrawItem(object sender, DrawItemEventArgs e)
{
DrawListBox(HistoryListBox, e, Color.FromArgb(218, 112, 214));
}

private void HistoryRemoveButton_Click(object sender, EventArgs e)
{
if (HistoryListBox.SelectedItems.Count == 0)
return;

File.Delete("MediaDownloader\\config\\history\\" + HistoryListBox.SelectedItem + ".mdq");
UpdateListBox(HistoryListBox, "MediaDownloader\\config\\history");

if (HistoryListBox.Items.Count == 0)
CONFIG.HISTORY_SAVE_INDEX = 0;

if (HistoryListBox.Items.Count >= 1)
HistoryListBox.SelectedIndex = 0;
}

private void HistoryListBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (HistoryListBox.Items.Count == 0)
return;

CONFIG.HISTORY_SELECTED_INDEX = HistoryListBox.SelectedIndex;
}

private void HistoryLoadButton_Click(object sender, EventArgs e)
{
if (HistoryListBox.SelectedItems.Count == 0)
return;

LoadQueueItem("MediaDownloader\\config\\history\\" + HistoryListBox.SelectedItem + ".mdq");
}

private void HistoryCheckBox_CheckedChanged(object sender, EventArgs e)
{
CONFIG.HISTORY_ENABLE = HistoryCheckBox.Checked;
}
}
}
2 changes: 1 addition & 1 deletion src/MediaDownloader/MediaDownloader/MainMenu.resx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
<data name="$this.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAArMAAAD0CAYAAACIJa7mAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wAAADsABataJCQAA/7JJREFUeF7s/Xm3dVtSFA6/n6Coe+tWgSDSI6KogIh0iiIiKIIgndJ3St8J+u3P
vwAADr8BOAVTJAAA/7JJREFUeF7s/Xm3dVtSFA6/n6Coe+tWgSDSI6KogIh0iiIiKIIgndJ3St8J+u3P
G23OXPs8hfoDhSrmGiNGZkZG5ty3/qkY81l7n//ffe5zn/vc5z73uc997nOf+9znPve5z33uc5/73Oc+
97nPfe5zn/vc5z73uc997nOf+9znPve5z33uc5/73Oc+97nPfe5zn/vc5z73uc997nOf+9znPve5z33u
c5/73Oc+97nPfe5zn/vc5z73uc997nOf+9znPve5z33uc5/73Oc+97nPfe5zn/vc5z73uc997nOf+9zn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace MediaDownloader.Data
{
public static class Storage
{
public const string VERSION = "v4.0.0";
public const string VERSION = "v4.0.1";
public static ConfigBase CONFIG = new ConfigBase();
public static bool IS_DOWNLOADING = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,19 @@ public static void ConvertMedia(QueueItemBase queueItem, string downloadFile)

case "gif":
{
string gifPaletteArguments = "-loglevel verbose -y -i \"MediaDownloader\\working\\converted.mp4\" -vf palettegen \"MediaDownloader\\working\\gif_palette.png\"";
string gifPaletteArguments = "-loglevel verbose -y -i \"MediaDownloader\\working\\converted.mp4\" -vf palettegen \"MediaDownloader\\working\\converted_gif_palette.png\"";
StartProcess("MediaDownloader\\redist\\ffmpeg\\ffmpeg.exe", gifPaletteArguments, "MediaDownloader " + VERSION + " [CONVERTING : GIF PALETTE]", queueItem.OUTPUT_ENABLE_DISPLAY, queueItem.OUTPUT_ENABLE_PAUSE);
string gifConvertArguments = "-loglevel verbose -y -i \"MediaDownloader\\working\\converted.mp4\" -i \"MediaDownloader\\working\\gif_palette.png\" -lavfi \"paletteuse\" \"MediaDownloader\\working\\converted.gif\"";
string gifConvertArguments = "-loglevel verbose -y -i \"MediaDownloader\\working\\converted.mp4\" -i \"MediaDownloader\\working\\converted_gif_palette.png\" -lavfi \"paletteuse\" \"MediaDownloader\\working\\converted_gif.gif\"";
StartProcess("MediaDownloader\\redist\\ffmpeg\\ffmpeg.exe", gifConvertArguments, "MediaDownloader " + VERSION + " [CONVERTING : GIF]", queueItem.OUTPUT_ENABLE_DISPLAY, queueItem.OUTPUT_ENABLE_PAUSE);

string copyLocation = queueItem.OUTPUT_LOCATION == "" || queueItem.OUTPUT_LOCATION == null ? "Downloads" : queueItem.OUTPUT_LOCATION;
File.Copy("MediaDownloader\\working\\converted.gif", copyLocation + "\\" + queueItem.OUTPUT_NAME + ".gif");
File.Copy("MediaDownloader\\working\\converted_gif.gif", copyLocation + "\\" + queueItem.OUTPUT_NAME + ".gif");
}
break;

case "sequence":
{
Directory.CreateDirectory("MediaDownloader\\working\\converted");
Directory.CreateDirectory("MediaDownloader\\working\\converted_sequence");

string imageExtension = "";
switch (queueItem.OUTPUT_FORMAT)
Expand All @@ -195,11 +195,11 @@ public static void ConvertMedia(QueueItemBase queueItem, string downloadFile)
break;
}

string sequenceConvertArguments = "-loglevel verbose -y -i \"MediaDownloader\\working\\converted.mp4\" \"MediaDownloader\\working\\converted\\" + queueItem.OUTPUT_NAME + ".%d." + imageExtension;
string sequenceConvertArguments = "-loglevel verbose -y -i \"MediaDownloader\\working\\converted.mp4\" \"MediaDownloader\\working\\converted_sequence\\" + queueItem.OUTPUT_NAME + ".%d." + imageExtension;
StartProcess("MediaDownloader\\redist\\ffmpeg\\ffmpeg.exe", sequenceConvertArguments, "MediaDownloader " + VERSION + " [CONVERTING : IMAGE SEQUENCE]", queueItem.OUTPUT_ENABLE_DISPLAY, queueItem.OUTPUT_ENABLE_PAUSE);

string copyLocation = queueItem.OUTPUT_LOCATION == "" || queueItem.OUTPUT_LOCATION == null ? "Downloads" : queueItem.OUTPUT_LOCATION;
Directory.Move("MediaDownloader\\working\\converted", copyLocation + "\\" + queueItem.OUTPUT_NAME);
Directory.Move("MediaDownloader\\working\\converted_sequence", copyLocation + "\\" + queueItem.OUTPUT_NAME);
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ public static void StartDownload(QueueItemBase queueItem, Button downloadButton,
{
CustomMessageBox customMessageBox = new CustomMessageBox("Error: Download Failed!", true);
customMessageBox.ShowDialog();

ChangeDownloadButtonColors(false, downloadButton, downloadAllButton);
IS_DOWNLOADING = false;

return;
}
ConvertMedia(queueItem, downloadFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,29 @@ public static QueueItemBase ReadQueueItem(string queueFile)
switch (queueItemSettingPair[0])
{
case "URL": queueItem.URL = queueItemSettingPair[1]; break;

case "OUTPUT_NAME": queueItem.OUTPUT_NAME = queueItemSettingPair[1]; break;
case "OUTPUT_LOCATION": queueItem.OUTPUT_LOCATION = queueItemSettingPair[1]; break;

case "OUTPUT_FORMAT": queueItem.OUTPUT_FORMAT = queueItemSettingPair[1]; break;

case "OUTPUT_BITRATE_VIDEO": queueItem.OUTPUT_BITRATE_VIDEO = queueItemSettingPair[1]; break;
case "OUTPUT_BITRATE_AUDIO": queueItem.OUTPUT_BITRATE_AUDIO = queueItemSettingPair[1]; break;

case "OUTPUT_ENABLE_CHANGE_RESOLUTION": queueItem.OUTPUT_ENABLE_CHANGE_RESOLUTION = bool.Parse(queueItemSettingPair[1]); break;
case "OUTPUT_RESOLUTION_WIDTH": queueItem.OUTPUT_RESOLUTION_WIDTH = queueItemSettingPair[1]; break;
case "OUTPUT_RESOLUTION_HEIGHT": queueItem.OUTPUT_RESOLUTION_HEIGHT = queueItemSettingPair[1]; break;

case "OUTPUT_ENABLE_CHANGE_FRAMERATE": queueItem.OUTPUT_ENABLE_CHANGE_FRAMERATE = bool.Parse(queueItemSettingPair[1]); break;
case "OUTPUT_FRAMERATE": queueItem.OUTPUT_FRAMERATE = queueItemSettingPair[1]; break;

case "OUTPUT_ENABLE_CHANGE_TIMEFRAME": queueItem.OUTPUT_ENABLE_CHANGE_TIMEFRAME = bool.Parse(queueItemSettingPair[1]); break;
case "OUTPUT_TIMEFRAME_START": queueItem.OUTPUT_TIMEFRAME_START = queueItemSettingPair[1]; break;
case "OUTPUT_TIMEFRAME_END": queueItem.OUTPUT_TIMEFRAME_END = queueItemSettingPair[1]; break;

case "OUTPUT_YTDLP_ARGUMENTS": queueItem.OUTPUT_YTDLP_ARGUMENTS = queueItemSettingPair[1]; break;
case "OUTPUT_FFMPEG_ARGUMENTS": queueItem.OUTPUT_FFMPEG_ARGUMENTS = queueItemSettingPair[1]; break;

case "OUTPUT_ENABLE_DISPLAY": queueItem.OUTPUT_ENABLE_DISPLAY = bool.Parse(queueItemSettingPair[1]); break;
case "OUTPUT_ENABLE_PAUSE": queueItem.OUTPUT_ENABLE_PAUSE = bool.Parse(queueItemSettingPair[1]); break;
}
Expand Down
4 changes: 1 addition & 3 deletions src/MediaDownloader/MediaDownloader/Scripts/Tools/Files.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.IO;

namespace MediaDownloader.Tools
{
Expand Down
20 changes: 15 additions & 5 deletions src/MediaDownloader/MediaDownloader/Scripts/Tools/Forms.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using System.IO;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Drawing;
using System.IO;

namespace MediaDownloader.Tools
{
Expand Down Expand Up @@ -80,15 +81,24 @@ public static void ChangeDownloadButtonColors(bool isDownloading, Button downloa
}
}

public static void UpdateListBox(ListBox listBox, string source)
public static void UpdateListBox(ListBox listBox, string source, bool descendingOrder)
{
listBox.Items.Clear();
List<string> itemList = new List<string>();

foreach (string file in Directory.GetFiles(source))
{
string item = Path.GetFileNameWithoutExtension(file);
listBox.Items.Add(item);
itemList.Add(item);
}

if (descendingOrder == true)
itemList.Sort((a, b) => b.CompareTo(a));
else
itemList.Sort();

listBox.Items.Clear();
foreach (var item in itemList)
listBox.Items.Add(item);
}

public static void DrawListBox(ListBox listbox, DrawItemEventArgs e, Color color)
Expand Down

0 comments on commit 951d569

Please sign in to comment.