Skip to content

Commit

Permalink
Minor Release [v4.3.0.0]
Browse files Browse the repository at this point in the history
- Improved the progress bar for the queue system
- Added a config option to allow only specified urls to be downloaded from
- Double-clicking the url textbox now navigates to the current url in a browser
- Fixed minor bugs
- MediaDownloader Updater v1.1.0
	- Made it run inside a shell window instead of a powershell windows
	- Made it work as a standalone updater
  • Loading branch information
o7q committed Oct 1, 2023
1 parent d06f616 commit d6bb5f6
Show file tree
Hide file tree
Showing 15 changed files with 267 additions and 97 deletions.
Binary file added assets_raw/graphics/button/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
~
~ v4.3.0.0
- Improved the progress bar for the queue system
- Added a config option to allow only specified urls to be downloaded from
- Double-clicking the url textbox now navigates to the current url in a browser
- Improved the updater
- Fixed minor bugs
- MediaDownloader Updater v1.1.0
- Made it run inside a shell window instead of a powershell windows
- Made it work as a standalone updater

~ v4.2.3.0
- Fixed playlist downloader not working with named folders (I broke it for the 2nd time, I swear it's fixed now :) )
Expand Down
3 changes: 2 additions & 1 deletion src/MediaDownloader/MediaDownloader/Init.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ static void Main()
CONFIG = ReadConfig("MediaDownloader\\config\\config.cfg");
else
{
CONFIG.DATA_PACKING_ENABLE = true;
CONFIG.NOTIFICATIONS_ENABLE = true;
CONFIG.DATA_PACKING_ENABLE = true;
CONFIG.TRUSTED_URLS = "youtube.com,youtu.be,twitter.com,instagram.com";
}

if (File.Exists("MediaDownloader\\config\\queue.pack") || Directory.Exists("MediaDownloader\\config\\queue"))
Expand Down
166 changes: 112 additions & 54 deletions src/MediaDownloader/MediaDownloader/MainMenu.Designer.cs

Large diffs are not rendered by default.

73 changes: 54 additions & 19 deletions src/MediaDownloader/MediaDownloader/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,19 @@ private void Program_Load(object sender, EventArgs e)

// update check
var newVersionAvailable = CheckForNewUpdate(VERSION_INTERNAL);
if (newVersionAvailable.Item1 && CONFIG.NOTIFICATIONS_ENABLE)
if (newVersionAvailable.Item1 && CONFIG.NOTIFICATIONS_ENABLE && !VERSION_INTERNAL.Contains("dev"))
{
VERSION_REMOTE = newVersionAvailable.Item2;
NotificationPictureBox.Visible = true;
NotificationLabel.Visible = true;
}

#region loadTooltips
// bind tooltips
string[] tooltipMap = {
"BannerPicture", "MediaDownloader by o7q",
"NotificationPictureBox", "Update available",
"NotificationLabel", "Update available",
"VersionLabel", "Version " + VERSION,

"MinimizeButton", "Minimize",
Expand Down Expand Up @@ -141,7 +143,6 @@ private void Program_Load(object sender, EventArgs e)
"QueueAddButton", "Add an item to the queue",
"QueueRemoveButton", "Remove the selected item from the queue",
"DownloadAllButton", "Download all items in the queue",
"QueueProgressBar", "Queue progress bar",

"HistoryListBox", "List of previous downloads",
"HistoryLoadButton", "Load the config from the selected item",
Expand Down Expand Up @@ -180,18 +181,34 @@ private void DownloadButton_Click(object sender, EventArgs e)
return;
}

if (IS_DOWNLOADING || currentQueueItem.URL == "" || currentQueueItem.URL == null)
bool containsTrustedUrl = CONFIG.TRUSTED_URLS_ENABLE ? false : true;
if (currentQueueItem.URL != null && CONFIG.TRUSTED_URLS_ENABLE)
{
string[] trustedUrls = CONFIG.TRUSTED_URLS.Split(',');
for (int i = 0; i < trustedUrls.Length; i++)
{
if (currentQueueItem.URL.IndexOf(trustedUrls[i], StringComparison.OrdinalIgnoreCase) >= 0)
containsTrustedUrl = true;
}
}

if (IS_DOWNLOADING || currentQueueItem.URL == "" || currentQueueItem.URL == null || !containsTrustedUrl)
return;

Task.Run(() => StartDownload(currentQueueItem, OutputNameTextBox, DownloadButton, DownloadAllButton));
}

private void DownloadAllButton_Click(object sender, EventArgs e)
{
if (IS_DOWNLOADING)
if (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift)
{
IS_DOWNLOADING = false;
ChangeDownloadButtonColors(false, DownloadButton, DownloadAllButton);
return;
}

QueueProgressBar.Value = 0;
if (IS_DOWNLOADING || QueueListBox.Items.Count == 0)
return;

string[] queueList = new string[QueueListBox.Items.Count];
int queueIndex = 0;
Expand All @@ -201,7 +218,7 @@ private void DownloadAllButton_Click(object sender, EventArgs e)
queueIndex++;
}

Task.Run(() => StartDownloadQueue(queueList, DownloadButton, DownloadAllButton, QueueProgressBar));
Task.Run(() => StartDownloadQueue(queueList, DownloadButton, DownloadAllButton, QueueProgressBarPanel, QueueProgressLabel));
}

private void QueueAddButton_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -855,16 +872,23 @@ private void ExpandMenu()
MenuExpandButton.Size = new Size(29, 102);
MenuExpandButton.Text = "<<";

QueueLabel.Visible = true;
QueueDecorationPanel.Visible = true;

QueueListBox.Visible = true;
QueueProgressBar.Visible = true;

DownloadAllButton.Visible = true;

QueueProgressLabel.Visible = true;
QueueProgressBarPanel.Visible = true;
QueueProgressPanel.Visible = true;
QueueProgressDecorationPanel.Visible = true;

QueueAddButton.Visible = true;
QueueRemoveButton.Visible = true;

QueueLabel.Visible = true;
QueueDecorationPanel.Visible = true;
HistoryLabel.Visible = true;
HistoryDecorationPanel.Visible = true;

HistoryListBox.Visible = true;

Expand All @@ -876,9 +900,6 @@ private void ExpandMenu()
HistoryRefreshButton.Visible = true;
HistoryRemoveButton.Visible = true;

HistoryLabel.Visible = true;
HistoryDecorationPanel.Visible = true;

Size = new Size(691, 244);

TitlebarPanel.Size = new Size(691, 35);
Expand All @@ -897,16 +918,23 @@ private void CollapseMenu()
MenuExpandButton.Size = new Size(29, 207);
MenuExpandButton.Text = ">>";

QueueListBox.Visible = false;
QueueProgressBar.Visible = false;
QueueLabel.Visible = false;
QueueDecorationPanel.Visible = false;

QueueListBox.Visible = true;

DownloadAllButton.Visible = false;

QueueProgressLabel.Visible = false;
QueueProgressBarPanel.Visible = false;
QueueProgressPanel.Visible = false;
QueueProgressDecorationPanel.Visible = false;

QueueAddButton.Visible = false;
QueueRemoveButton.Visible = false;

QueueLabel.Visible = false;
QueueDecorationPanel.Visible = false;
HistoryLabel.Visible = false;
HistoryDecorationPanel.Visible = false;

HistoryListBox.Visible = false;

Expand All @@ -918,9 +946,6 @@ private void CollapseMenu()
HistoryRefreshButton.Visible = false;
HistoryRemoveButton.Visible = false;

HistoryLabel.Visible = false;
HistoryDecorationPanel.Visible = false;

Size = new Size(408, 244);

TitlebarPanel.Size = new Size(408, 35);
Expand Down Expand Up @@ -1014,6 +1039,16 @@ private void VersionLabel_MouseDown(object sender, MouseEventArgs e)
}

private void NotificationPictureBox_Click(object sender, EventArgs e)
{
RunUpdateDialog();
}

private void NotificationLabel_Click(object sender, EventArgs e)
{
RunUpdateDialog();
}

private void RunUpdateDialog()
{
string changelog = ReadRemoteResource("https://raw.githubusercontent.com/o7q/MediaDownloader/main/remote/changelog");

Expand Down
1 change: 1 addition & 0 deletions src/MediaDownloader/MediaDownloader/MediaDownloader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="logo.ico" />
<None Include="Resources\settings.png" />
<None Include="Resources\notification.png" />
<None Include="Resources\background.png" />
<None Include="Resources\banner_hq.png" />
Expand Down

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

13 changes: 8 additions & 5 deletions src/MediaDownloader/MediaDownloader/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,19 @@
<data name="background" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\background.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="banner_hq" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\banner_hq.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="x" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\x.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="folder" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="x" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\x.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="notification" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\notification.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="banner_hq" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\banner_hq.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="settings" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,20 @@ public static ConfigBase ReadConfig(string location)

switch (configSettingPair[0])
{
// user config
case "HISTORY_ENABLE": config.HISTORY_ENABLE = bool.Parse(configSettingPair[1]); break;
case "NOTIFICATIONS_ENABLE": config.NOTIFICATIONS_ENABLE = bool.Parse(configSettingPair[1]); break;
case "DATA_PACKING_ENABLE": config.DATA_PACKING_ENABLE = bool.Parse(configSettingPair[1]); break;
case "TRUSTED_URLS_ENABLE": config.TRUSTED_URLS_ENABLE = bool.Parse(configSettingPair[1]); break;
case "TRUSTED_URLS": config.TRUSTED_URLS = configSettingPair[1]; break;

// program config
case "MENU_EXPANDED_ENABLE": config.MENU_EXPANDED_ENABLE = bool.Parse(configSettingPair[1]); break;

case "QUEUE_SELECTED_INDEX": config.QUEUE_SELECTED_INDEX = int.Parse(configSettingPair[1]); break;

case "HISTORY_ENABLE": config.HISTORY_ENABLE = bool.Parse(configSettingPair[1]); break;
case "HISTORY_SELECTED_INDEX": config.HISTORY_SELECTED_INDEX = int.Parse(configSettingPair[1]); break;
case "HISTORY_SAVE_INDEX": config.HISTORY_SAVE_INDEX = int.Parse(configSettingPair[1]); break;

case "DATA_PACKING_ENABLE": config.DATA_PACKING_ENABLE = bool.Parse(configSettingPair[1]); break;
case "NOTIFICATIONS_ENABLE": config.NOTIFICATIONS_ENABLE = bool.Parse(configSettingPair[1]); break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ public class ConfigStructure
{
public struct ConfigBase
{
// user config
public bool HISTORY_ENABLE;
public bool NOTIFICATIONS_ENABLE;
public bool DATA_PACKING_ENABLE;
public bool TRUSTED_URLS_ENABLE;
public string TRUSTED_URLS;

// program config
public bool MENU_EXPANDED_ENABLE;

public int QUEUE_SELECTED_INDEX;

public bool HISTORY_ENABLE;
public int HISTORY_SELECTED_INDEX;
public int HISTORY_SAVE_INDEX;

public bool DATA_PACKING_ENABLE;
public bool NOTIFICATIONS_ENABLE;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Windows.Forms;
using System.Diagnostics;
using System.Windows.Forms;
using static MediaDownloader.Data.QueueItem.QueueItemManager;
using static MediaDownloader.Data.QueueItem.QueueItemStructure;
using static MediaDownloader.Media.Downloaders.Queuer;
Expand All @@ -7,27 +8,57 @@ namespace MediaDownloader.Media.Downloaders
{
public static class BulkQueuer
{
public static void StartDownloadQueue(string[] queueList, Button downloadButton, Button downloadAllButton, ProgressBar progressBar)
public static void StartDownloadQueue(string[] queueList, Button downloadButton, Button downloadAllButton, Panel progressPanel, Label progressLabel)
{
try
{
progressBar.Invoke((MethodInvoker)delegate
progressPanel.Invoke((MethodInvoker)delegate
{
progressBar.Maximum = queueList.Length;
progressPanel.Width = 0;
});

progressLabel.Invoke((MethodInvoker)delegate
{
progressLabel.Text = "1/" + queueList.Length + " | 0.00% | 00:00:00";
});
}
catch { }

int progressBarWidth = 0;
float percentage = 0;
int totalSeconds = 0;

for (int i = 0; i < queueList.Length; i++)
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();

QueueItemBase queueItem = ReadQueueItem("MediaDownloader\\config\\queue_temp\\" + queueList[i] + ".mdq");
StartDownload(queueItem, null, downloadButton, downloadAllButton);

percentage = ((i + 1) / (float)queueList.Length) * 100;
progressBarWidth = (int)((125 / (float)100) * percentage);

stopwatch.Stop();

totalSeconds += stopwatch.Elapsed.Seconds;
int averageSeconds = (totalSeconds / (i + 1)) * (queueList.Length - (i + 1));

int hours = averageSeconds / 3600;
int minutes = (averageSeconds % 3600) / 60;
int seconds = averageSeconds % 60;
string time = $"{hours:D2}:{minutes:D2}:{seconds:D2}";

try
{
progressBar.Invoke((MethodInvoker)delegate
progressPanel.Invoke((MethodInvoker)delegate
{
progressPanel.Width = progressBarWidth;
});

progressLabel.Invoke((MethodInvoker)delegate
{
progressBar.Value = i + 1;
progressLabel.Text = (i + 1) + "/" + queueList.Length + " | " + percentage.ToString("0.00") + "% | " + time;
});
}
catch { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public static void StartDownload(QueueItemBase queueItem, TextBox nameTextBox, B
if (CONFIG.HISTORY_SAVE_INDEX == 0)
CONFIG.HISTORY_SAVE_INDEX = 1;

queueItem.OUTPUT_NAME_AUTO_ENABLE = false;

WriteQueueItem(queueItem, "MediaDownloader\\config\\history_temp\\(" + CONFIG.HISTORY_SAVE_INDEX + ") " + (queueItem.OUTPUT_NAME == "" || queueItem.OUTPUT_NAME == null ? "unnamed" : queueItem.OUTPUT_NAME) + ".mdq");
CONFIG.HISTORY_SAVE_INDEX++;
}
Expand Down
Loading

0 comments on commit d6bb5f6

Please sign in to comment.