Skip to content

Commit

Permalink
Merge branch 'release-1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Otiel committed Jun 13, 2019
2 parents ca7890c + b6eda0c commit 6765570
Show file tree
Hide file tree
Showing 15 changed files with 302 additions and 198 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 1.1.0

## Improvements

* Updated the following languages thanks to contributors: German, Norwegian Bokmål, Polish, Spanish.
* More data will be logged when a crash occurs.
* Minor UI improvements.

## Bug fixes

* Fixed a bug causing albums with no tracks to be downloaded. Thanks **@wilbishardis**! [#106](https://github.com/Otiel/BandcampDownloader/issues/106)
* Fixed a bug preventing the app from getting updates info on Windows 7. [#109](https://github.com/Otiel/BandcampDownloader/issues/109)

# 1.0.0

## New features
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align="center"><img alt="Download" src="docs/images/Cloud.png"> Bandcamp Downloader</h1>
<h1 align="center"><img alt="Icon" src="docs/images/Cloud.png"> Bandcamp Downloader</h1>

<p align="center">
<a href="https://github.com/Otiel/BandcampDownloader/releases/latest"><img alt="Download" src="docs/images/DownloadButton.png"></a>
Expand Down
29 changes: 12 additions & 17 deletions src/BandcampDownloader/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.Net;
using System.Windows;
using Config.Net;
using NLog;
using NLog.Config;
using NLog.Targets;
using WpfMessageBoxLibrary;

namespace BandcampDownloader {

Expand All @@ -26,23 +26,18 @@ protected override void OnStartup(StartupEventArgs e) {
// Manage unhandled exceptions
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

// Define the default security protocol to use for connection as TLS (#109)
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

InitializeSettings();
LanguageHelper.ApplyLanguage(UserSettings.Language);
ThemeHelper.ApplySkin(UserSettings.Theme);
}

private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) {
LogExceptionToFile((Exception) e.ExceptionObject);

LogUnhandledExceptionToFile((Exception) e.ExceptionObject);

var msgProperties = new WpfMessageBoxProperties() {
Button = MessageBoxButton.OK,
ButtonOkText = BandcampDownloader.Properties.Resources.messageBoxButtonOK,
Image = MessageBoxImage.Error,
Text = String.Format(BandcampDownloader.Properties.Resources.messageBoxUnhandledException, Constants.UrlIssues),
Title = "Bandcamp Downloader",
};
WpfMessageBox.Show(ref msgProperties);
MessageBox.Show(String.Format(BandcampDownloader.Properties.Resources.messageBoxUnhandledException, Constants.UrlIssues), "Bandcamp Downloader", MessageBoxButton.OK, MessageBoxImage.Error);
}

/// <summary>
Expand All @@ -63,8 +58,8 @@ private void InitializeLogger() {
}

/// <summary>
/// Initializes data context for bindings between settings values and settings controls.
/// This must be called before initializing UI forms.
/// Initializes data context for bindings between settings values and settings controls. This must be called
/// before initializing UI forms.
/// </summary>
private void InitializeSettings() {
App.UserSettings = new ConfigurationBuilder<IUserSettings>().UseIniFile(Constants.UserSettingsFilePath).Build();
Expand All @@ -75,13 +70,13 @@ private void InitializeSettings() {
}

/// <summary>
/// Writes the specified Exception to the application log file.
/// Writes the specified Exception to the application log file, along with the .NET version.
/// </summary>
/// <param name="exception">The Exception to log.</param>
private void LogExceptionToFile(Exception exception) {
private void LogUnhandledExceptionToFile(Exception exception) {
Logger logger = LogManager.GetCurrentClassLogger();
logger.Log(LogLevel.Fatal, String.Format("{0} {1}", exception.GetType().ToString(), exception.Message));
logger.Log(LogLevel.Fatal, exception.StackTrace);
logger.Log(LogLevel.Fatal, $".NET Framework version: {SystemVersionHelper.GetDotNetFrameworkVersion()}");
LogHelper.LogExceptionAndInnerExceptionsToFile(exception);
}
}
}
1 change: 1 addition & 0 deletions src/BandcampDownloader/BandcampDownloader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
<Compile Include="Core\DownloadManager.cs" />
<Compile Include="Core\LogArgs.cs" />
<Compile Include="Helpers\LanguageHelper.cs" />
<Compile Include="Helpers\SystemVersionHelper.cs" />
<Compile Include="Helpers\ThemeHelper.cs" />
<Compile Include="Model\FileType.cs" />
<Compile Include="Helpers\BandcampHelper.cs" />
Expand Down
9 changes: 7 additions & 2 deletions src/BandcampDownloader/Core/DownloadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public DownloadManager(string urls) {

// Increase the maximum of concurrent connections to be able to download more than 2 (which is the default value) files at the same time
ServicePointManager.DefaultConnectionLimit = 50;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
}

/// <summary>
Expand Down Expand Up @@ -382,7 +381,13 @@ private async Task<List<Album>> GetAlbumsAsync(List<string> urls) {

// Get info on album
try {
albums.Add(BandcampHelper.GetAlbum(htmlCode));
Album album = BandcampHelper.GetAlbum(htmlCode);

if (album.Tracks.Count > 0) {
albums.Add(album);
} else {
LogAdded(this, new LogArgs($"No tracks found for {url}, album will not be downloaded", LogType.Warning));
}
} catch {
LogAdded(this, new LogArgs($"Could not retrieve album info for {url}", LogType.Error));
continue;
Expand Down
23 changes: 23 additions & 0 deletions src/BandcampDownloader/Helpers/LogHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Windows.Media;
using NLog;

namespace BandcampDownloader {

Expand Down Expand Up @@ -37,5 +38,27 @@ public static SolidColorBrush GetColor(LogType logType) {

return color;
}

/// <summary>
/// Writes the specified Exception and all its InnerException to the application log file.
/// </summary>
/// <param name="exception">The Exception to log.</param>
public static void LogExceptionAndInnerExceptionsToFile(Exception exception) {
LogExceptionToFile(exception);

if (exception.InnerException != null) {
LogExceptionAndInnerExceptionsToFile(exception.InnerException);
}
}

/// <summary>
/// Writes the specified Exception to the application log file.
/// </summary>
/// <param name="exception">The Exception to log.</param>
public static void LogExceptionToFile(Exception exception) {
Logger logger = LogManager.GetCurrentClassLogger();
logger.Log(LogLevel.Fatal, String.Format("{0} {1}", exception.GetType().ToString(), exception.Message));
logger.Log(LogLevel.Fatal, exception.StackTrace);
}
}
}
64 changes: 64 additions & 0 deletions src/BandcampDownloader/Helpers/SystemVersionHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using Microsoft.Win32;

namespace BandcampDownloader {

internal static class SystemVersionHelper {

/// <summary>
/// Returns the .NET Framework version installed by querying the registry.
/// </summary>
public static string GetDotNetFrameworkVersion() {
const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";

using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey)) {
if (ndpKey != null && ndpKey.GetValue("Release") != null) {
return GetDotNetFrameworkVersion((int) ndpKey.GetValue("Release"));
} else {
return "Version 4.5 or later is not detected.";
}
}
}

/// <summary>
/// Returns the .NET Framework version from the specified value of the "Release" DWORD, following the rules
/// defined on https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed
/// </summary>
/// <param name="releaseKey">The value of the "Release" DWORD.</param>
private static string GetDotNetFrameworkVersion(int releaseKey) {
// Checking the version using >= enables forward compatibility.
if (releaseKey >= 528040) {
return "4.8 or later";
}
if (releaseKey >= 461808) {
return "4.7.2";
}
if (releaseKey >= 461308) {
return "4.7.1";
}
if (releaseKey >= 460798) {
return "4.7";
}
if (releaseKey >= 394802) {
return "4.6.2";
}
if (releaseKey >= 394254) {
return "4.6.1";
}
if (releaseKey >= 393295) {
return "4.6";
}
if (releaseKey >= 379893) {
return "4.5.2";
}
if (releaseKey >= 378675) {
return "4.5.1";
}
if (releaseKey >= 378389) {
return "4.5";
}

// This code should never execute. A non-null release key should mean that 4.5 or later is installed.
return "No 4.5 or later version detected";
}
}
}
4 changes: 2 additions & 2 deletions src/BandcampDownloader/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
// 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("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyVersion("1.1.0")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: GuidAttribute("8C171C7F-9BAC-4EC0-A287-59908B48953F")]
2 changes: 1 addition & 1 deletion src/BandcampDownloader/Properties/Resources.Designer.cs

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

Loading

0 comments on commit 6765570

Please sign in to comment.