Skip to content

Commit

Permalink
Minor UI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
weespin committed Jun 2, 2021
1 parent a123f34 commit cfb80a9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
12 changes: 6 additions & 6 deletions Form1.Designer.cs

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

19 changes: 17 additions & 2 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Linq;
using System.Net;
using System.Resources;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
Expand Down Expand Up @@ -218,6 +219,9 @@ static class Downloader
//ParralelOptions for albums
public static ParallelOptions g_albumsParralelOptions = new ParallelOptions()
{ MaxDegreeOfParallelism = Environment.ProcessorCount };
public static int nTotalAlbums = 0;
public static int nAlbumsDownloaded = 0;

static void UpdateTitle(int value,int max)
{
Program.MainForm.Invoke(new Action(() =>
Expand Down Expand Up @@ -246,13 +250,21 @@ public enum EDownloadQuality : byte

public static void DownloadAlbums(List<string> url)
{

if (!Directory.Exists(Downloader.m_szDownloadPath))
{
Directory.CreateDirectory(Downloader.m_szDownloadPath);
}
ThreadPool.SetMinThreads(g_songsParralelOptions.MaxDegreeOfParallelism, g_songsParralelOptions.MaxDegreeOfParallelism);
System.Net.ServicePointManager.DefaultConnectionLimit = Int32.MaxValue;
nAlbumsDownloaded = 0;
nTotalAlbums = url.Count;
if (g_albumsParralelOptions.MaxDegreeOfParallelism != 1)
{
UpdateTitle(nAlbumsDownloaded, nTotalAlbums);
}
Parallel.ForEach(url,g_albumsParralelOptions, DownloadAlbum);
ResetTitle();
}

public static string GetHTMLFromURL(string sUrl)
Expand Down Expand Up @@ -353,7 +365,7 @@ public static void DownloadAlbum(string sUrl)
return;
}
var downloadLinkNodes = songPageDocument.DocumentNode.SelectNodes("//span[@class='songDownloadLink']"); //[1].ParentElement.GetAttribute("href");
//Do not use Parallel.ForEach.Foreach we usually have ~2 nodes
//Do not use Parallel.ForEach as we usually have ~2 nodes
int nDownloadNodes = downloadLinkNodes.Count;
for (var index = 0; index < nDownloadNodes; index++)
{
Expand Down Expand Up @@ -404,7 +416,10 @@ public static void DownloadAlbum(string sUrl)
});
Task.WaitAll(currentTasks.ToArray());
Program.MainForm.Log($"Finished downloading {szAlbumName}!");
ResetTitle();
if (g_albumsParralelOptions.MaxDegreeOfParallelism != 1)
{
UpdateTitle(++nAlbumsDownloaded, nTotalAlbums);
}
}
}
}
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.4.0.0")]
[assembly: AssemblyFileVersion("2.4.0.0")]
[assembly: AssemblyVersion("2.4.1.0")]
[assembly: AssemblyFileVersion("2.4.1.0")]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### A simple Bulk Khinsider downloader with GUI
[![Github Downloads (total)](https://img.shields.io/github/downloads/weespin/KhinsiderDownloader/total.svg)](https://github.com/weespin/KhinsiderDownloader)
# Screenshots
![Screenshot](https://yiff.nullcoreproject.net/i/635a991b.png)
![Screenshot](https://yiff.nullcoreproject.net/i/95845254.png)

-----
#### NOTE: Using more than 2 threads can cause timeouts

0 comments on commit cfb80a9

Please sign in to comment.