diff --git a/CHANGELOG.md b/CHANGELOG.md index 261d389e..3536060f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +# 0.2.10.0 + +## New features + +* Added "About" section on Settings window. + +## Improvements + +* Minor UI improvements. + +## Bug fixes + +* Fixed a bug preventing the cover art to be saved in the tracks. [#88](https://github.com/Otiel/BandcampDownloader/issues/88) + # 0.2.9.0 ## New features diff --git a/README.md b/README.md index 391e6f9c..db058f46 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ BandcampDownloader is a Windows application that helps downloading albums from [ * Convert it to jpg, * Resize it, * Save it in tracks tags and in folder. +* Create playlist file (supported formats are: m3u, pls, wpl, zpl).

Screenshot diff --git a/src/BandcampDownloader.sln b/src/BandcampDownloader.sln index ce5c1c23..ccfe3022 100644 --- a/src/BandcampDownloader.sln +++ b/src/BandcampDownloader.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28306.52 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28803.352 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BandcampDownloader", "BandcampDownloader\BandcampDownloader.csproj", "{F6E97E00-B958-4745-974E-14C6A72E5D03}" EndProject @@ -26,6 +26,7 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution + RESX_SortFileContentOnSave = True SolutionGuid = {52F50432-02C4-4952-8CA7-F992D75FB5B5} EndGlobalSection EndGlobal diff --git a/src/BandcampDownloader/App.xaml b/src/BandcampDownloader/App.xaml index 64fbf6ec..12ee0dd4 100644 --- a/src/BandcampDownloader/App.xaml +++ b/src/BandcampDownloader/App.xaml @@ -2,5 +2,4 @@ x:Class="BandcampDownloader.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - StartupUri="UI/Dialogs/WindowMain.xaml"> - \ No newline at end of file + StartupUri="UI/Dialogs/WindowMain.xaml" /> \ No newline at end of file diff --git a/src/BandcampDownloader/App.xaml.cs b/src/BandcampDownloader/App.xaml.cs index 89b60108..62a5b81e 100644 --- a/src/BandcampDownloader/App.xaml.cs +++ b/src/BandcampDownloader/App.xaml.cs @@ -29,7 +29,7 @@ protected override void OnStartup(StartupEventArgs e) { /// private void InitializeSettings() { App.UserSettings = new ConfigurationBuilder().UseIniFile(Constants.UserSettingsFilePath).Build(); - if (String.IsNullOrEmpty(UserSettings.DownloadsPath)) { + if (string.IsNullOrEmpty(UserSettings.DownloadsPath)) { // Its default value cannot be set in settings as it isn't determined by a constant function App.UserSettings.DownloadsPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\{artist}\\{album}"; } diff --git a/src/BandcampDownloader/BandcampDownloader.csproj b/src/BandcampDownloader/BandcampDownloader.csproj index 263d3866..5733b5a3 100644 --- a/src/BandcampDownloader/BandcampDownloader.csproj +++ b/src/BandcampDownloader/BandcampDownloader.csproj @@ -88,8 +88,8 @@ ..\packages\Costura.Fody.3.3.2\lib\net40\Costura.dll - - ..\packages\HtmlAgilityPack.1.11.3\lib\Net45\HtmlAgilityPack.dll + + ..\packages\HtmlAgilityPack.1.11.4\lib\Net45\HtmlAgilityPack.dll ..\packages\ImageResizer.4.2.5\lib\net45\ImageResizer.dll @@ -107,7 +107,7 @@ ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll - ..\packages\NLog.4.6.2\lib\net45\NLog.dll + ..\packages\NLog.4.6.3\lib\net45\NLog.dll ..\packages\PlaylistsNET.1.0.4\lib\net45\PlaylistsNET.dll @@ -139,8 +139,8 @@ ..\packages\WPFLocalizeExtension.3.3.1\lib\net452\WPFLocalizeExtension.dll - - ..\packages\XAMLMarkupExtensions.1.6.0\lib\net452\XAMLMarkupExtensions.dll + + ..\packages\XAMLMarkupExtensions.1.5.1\lib\net452\XAMLMarkupExtensions.dll @@ -161,6 +161,9 @@ + + UserControlSettingsAbout.xaml + UserControlChangelog.xaml @@ -228,6 +231,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -325,7 +332,7 @@ - + @@ -339,7 +346,19 @@ - + + + + + + + + + + + + + diff --git a/src/BandcampDownloader/Core/Constants.cs b/src/BandcampDownloader/Core/Constants.cs index 3354dba2..4a034a88 100644 --- a/src/BandcampDownloader/Core/Constants.cs +++ b/src/BandcampDownloader/Core/Constants.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using System.Reflection; namespace BandcampDownloader { @@ -8,38 +7,46 @@ internal static class Constants { ///

/// The version number of BandcampDownloader. /// - public static readonly String AppVersion = Assembly.GetEntryAssembly().GetName().Version.ToString(); + public static readonly string AppVersion = Assembly.GetEntryAssembly().GetName().Version.ToString(); + /// + /// The absolute path to the log file. + /// + public static readonly string LogFilePath = Directory.GetParent(Assembly.GetExecutingAssembly().Location) + @"\BandcampDownloader.log"; + /// + /// The log file maximum size in bytes. + /// + public static readonly long MaxLogSize = 1024 * 1024; /// /// The URL redirecting to the changelog file on GitHub. /// - public static readonly String ChangelogUrl = "https://raw.githubusercontent.com/Otiel/BandcampDownloader/master/CHANGELOG.md"; + public static readonly string UrlChangelog = "https://raw.githubusercontent.com/Otiel/BandcampDownloader/master/CHANGELOG.md"; /// /// The URL redirecting to the help page on translating the app on GitHub. /// - public static readonly String HelpTranslateWebsite = "https://github.com/Otiel/BandcampDownloader/blob/master/docs/help-translate.md"; + public static readonly string UrlHelpTranslate = "https://github.com/Otiel/BandcampDownloader/blob/master/docs/help-translate.md"; + /// + /// The URL redirecting to the issues page on GitHub. + /// + public static readonly string UrlIssues = "https://github.com/Otiel/BandcampDownloader/issues"; /// /// The URL redirecting to the latest release on GitHub. /// - public static readonly String LatestReleaseWebsite = "https://github.com/Otiel/BandcampDownloader/releases/latest"; + public static readonly string UrlLatestRelease = "https://github.com/Otiel/BandcampDownloader/releases/latest"; /// - /// The absolute path to the log file. + /// The URL redirecting to the releases page on GitHub. /// - public static readonly String LogFilePath = Directory.GetParent(Assembly.GetExecutingAssembly().Location) + @"\BandcampDownloader.log"; + public static readonly string UrlReleases = "https://github.com/Otiel/BandcampDownloader/releases"; /// - /// The log file maximum size in bytes. + /// The URL redirecting to the zip file. Must be formatted with a version. /// - public static readonly long MaxLogSize = 1024 * 1024; + public static readonly string UrlReleaseZip = "https://github.com/Otiel/BandcampDownloader/releases/download/v{0}/BandcampDownloader.zip"; /// /// The website URL of BandcampDownloader. /// - public static readonly String ProjectWebsite = "https://github.com/Otiel/BandcampDownloader"; + public static readonly string UrlWebsite = "https://github.com/Otiel/BandcampDownloader"; /// /// The absolute path to the settings file. /// - public static readonly String UserSettingsFilePath = Directory.GetParent(Assembly.GetExecutingAssembly().Location) + @"\BandcampDownloader.ini"; - /// - /// The URL redirecting to the zip file. Must be formatted with a version. - /// - public static readonly String ZipUrl = "https://github.com/Otiel/BandcampDownloader/releases/download/v{0}/BandcampDownloader.zip"; + public static readonly string UserSettingsFilePath = Directory.GetParent(Assembly.GetExecutingAssembly().Location) + @"\BandcampDownloader.ini"; } } \ No newline at end of file diff --git a/src/BandcampDownloader/Core/DownloadManager.cs b/src/BandcampDownloader/Core/DownloadManager.cs index d0bbcdac..ea0dff9c 100644 --- a/src/BandcampDownloader/Core/DownloadManager.cs +++ b/src/BandcampDownloader/Core/DownloadManager.cs @@ -5,6 +5,7 @@ using System.Net; using System.Text; using System.Text.RegularExpressions; +using System.Threading; using System.Threading.Tasks; using ImageResizer; @@ -14,7 +15,7 @@ internal class DownloadManager { /// /// The URLs to download. /// - private readonly String _urls; + private readonly string _urls; /// /// The albums to download. /// @@ -22,11 +23,11 @@ internal class DownloadManager { /// /// True if we received the order to cancel downloads; false otherwise. /// - private Boolean _cancelDownloads; + private bool _cancelDownloads; /// - /// The list of WebClients currently used to download files. Used when downloads must be cancelled. + /// Used when downloads must be cancelled. /// - private List _pendingDownloads = new List(); + private CancellationTokenSource _cancellationTokenSource; /// /// The files to download, or being downloaded, or already downloaded. Used to compute the current received bytes and the total bytes to download. @@ -39,7 +40,7 @@ internal class DownloadManager { /// Initializes a new instance of DownloadManager. /// /// The URLs we'll download from. - public DownloadManager(String urls) { + public DownloadManager(string urls) { _urls = urls; } @@ -48,20 +49,15 @@ public DownloadManager(String urls) { /// public void CancelDownloads() { _cancelDownloads = true; - - lock (_pendingDownloads) { - // Stop current downloads - foreach (WebClient webClient in _pendingDownloads) { - webClient.CancelAsync(); - } - } + // Stop current downloads + _cancellationTokenSource.Cancel(); } /// /// Fetch albums data from the URLs specified when creating this DownloadManager. /// public async Task FetchUrlsAsync() { - var urls = _urls.Split(new String[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList(); + var urls = _urls.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList(); urls = urls.Distinct().ToList(); // Get URLs of albums to download @@ -84,7 +80,7 @@ public async Task StartDownloadsAsync() { throw new Exception("Must call FetchUrls before calling StartDownloadsAsync"); } - _pendingDownloads = new List(); + _cancellationTokenSource = new CancellationTokenSource(); // Start downloading albums if (App.UserSettings.DownloadOneAlbumAtATime) { @@ -94,7 +90,7 @@ public async Task StartDownloadsAsync() { } } else { // Parallel download - Int32[] albumsIndexes = Enumerable.Range(0, _albums.Count).ToArray(); + int[] albumsIndexes = Enumerable.Range(0, _albums.Count).ToArray(); await Task.WhenAll(albumsIndexes.Select(i => DownloadAlbumAsync(_albums[i]))); } } @@ -125,8 +121,8 @@ private async Task DownloadAlbumAsync(Album album) { } // Download & tag tracks - Boolean[] tracksDownloaded = new Boolean[album.Tracks.Count]; - Int32[] indexes = Enumerable.Range(0, album.Tracks.Count).ToArray(); + bool[] tracksDownloaded = new bool[album.Tracks.Count]; + int[] indexes = Enumerable.Range(0, album.Tracks.Count).ToArray(); await Task.WhenAll(indexes.Select(async i => tracksDownloaded[i] = await DownloadAndTagTrackAsync(album, album.Tracks[i], artwork))); // Create playlist file @@ -151,11 +147,11 @@ private async Task DownloadAlbumAsync(Album album) { /// The album of the track to download. /// The track to download. /// The cover art. - private async Task DownloadAndTagTrackAsync(Album album, Track track, TagLib.Picture artwork) { + private async Task DownloadAndTagTrackAsync(Album album, Track track, TagLib.Picture artwork) { LogAdded(this, new LogArgs($"Downloading track \"{track.Title}\" from url: {track.Mp3Url}", LogType.VerboseInfo)); int tries = 0; - Boolean trackDownloaded = false; + bool trackDownloaded = false; TrackFile currentFile = DownloadingFiles.Where(f => f.Url == track.Mp3Url).First(); if (File.Exists(track.Path)) { @@ -219,25 +215,15 @@ private async Task DownloadAndTagTrackAsync(Album album, Track track, T } }; - lock (_pendingDownloads) { - if (_cancelDownloads) { - // Abort - return false; - } - // Register current download - _pendingDownloads.Add(webClient); - } + // Register current download + _cancellationTokenSource.Token.Register(webClient.CancelAsync); // Start download try { await webClient.DownloadFileTaskAsync(track.Mp3Url, track.Path); } catch (WebException ex) when (ex.Status == WebExceptionStatus.RequestCanceled) { // Downloads cancelled by the user - // Do nothing - } - - lock (_pendingDownloads) { - _pendingDownloads.Remove(webClient); + return false; } } } while (!trackDownloaded && tries < App.UserSettings.DownloadMaxTries); @@ -254,7 +240,7 @@ private async Task DownloadAndTagTrackAsync(Album album, Track track, T TagLib.Picture artworkInTags = null; int tries = 0; - Boolean artworkDownloaded = false; + bool artworkDownloaded = false; TrackFile currentFile = DownloadingFiles.Where(f => f.Url == album.ArtworkUrl).First(); do { @@ -283,9 +269,7 @@ private async Task DownloadAndTagTrackAsync(Album album, Track track, T settings.MaxWidth = App.UserSettings.CoverArtInFolderMaxSize; } - await Task.Run(() => { - ImageBuilder.Current.Build(album.ArtworkTempPath, album.ArtworkPath, settings); // Save it to the album folder - }); + ImageBuilder.Current.Build(album.ArtworkTempPath, album.ArtworkPath, settings); // Save it to the album folder } else if (App.UserSettings.SaveCoverArtInFolder) { File.Copy(album.ArtworkTempPath, album.ArtworkPath, true); } @@ -302,9 +286,7 @@ await Task.Run(() => { settings.MaxWidth = App.UserSettings.CoverArtInTagsMaxSize; } - await Task.Run(() => { - ImageBuilder.Current.Build(album.ArtworkTempPath, album.ArtworkTempPath, settings); // Save it to %Temp% - }); + ImageBuilder.Current.Build(album.ArtworkTempPath, album.ArtworkTempPath, settings); // Save it to %Temp% } artworkInTags = new TagLib.Picture(album.ArtworkTempPath) { Description = "Picture" @@ -333,25 +315,15 @@ await Task.Run(() => { } }; - lock (_pendingDownloads) { - if (_cancelDownloads) { - // Abort - return null; - } - // Register current download - _pendingDownloads.Add(webClient); - } + // Register current download + _cancellationTokenSource.Token.Register(webClient.CancelAsync); // Start download try { await webClient.DownloadFileTaskAsync(album.ArtworkUrl, album.ArtworkTempPath); } catch (WebException ex) when (ex.Status == WebExceptionStatus.RequestCanceled) { // Downloads cancelled by the user - // Do nothing - } - - lock (_pendingDownloads) { - _pendingDownloads.Remove(webClient); + return null; } } } while (!artworkDownloaded && tries < App.UserSettings.DownloadMaxTries); @@ -363,14 +335,14 @@ await Task.Run(() => { /// Returns the albums located at the specified URLs. /// /// The URLs. - private async Task> GetAlbumsAsync(List urls) { + private async Task> GetAlbumsAsync(List urls) { var albums = new List(); - foreach (String url in urls) { + foreach (string url in urls) { LogAdded(this, new LogArgs($"Retrieving album data for {url}", LogType.Info)); // Retrieve URL HTML source code - String htmlCode = ""; + string htmlCode = ""; using (var webClient = new WebClient() { Encoding = Encoding.UTF8 }) { ProxyHelper.SetProxy(webClient); @@ -403,20 +375,20 @@ private async Task> GetAlbumsAsync(List urls) { /// Returns the artists discography from any URL (artist, album, track). /// /// The URLs. - private async Task> GetArtistDiscographyAsync(List urls) { - var albumsUrls = new List(); + private async Task> GetArtistDiscographyAsync(List urls) { + var albumsUrls = new List(); - foreach (String url in urls) { + foreach (string url in urls) { LogAdded(this, new LogArgs($"Retrieving artist discography from {url}", LogType.Info)); // Retrieve URL HTML source code - String htmlCode = ""; + string htmlCode = ""; using (var webClient = new WebClient() { Encoding = Encoding.UTF8 }) { ProxyHelper.SetProxy(webClient); if (_cancelDownloads) { // Abort - return new List(); + return new List(); } try { @@ -433,7 +405,7 @@ private async Task> GetArtistDiscographyAsync(List urls) { LogAdded(this, new LogArgs($"No discography could be found on {url}. Try to uncheck the \"Download artist discography\" option", LogType.Error)); continue; } - String artistMusicPage = regex.Match(htmlCode).Groups["url"].Value + "/music"; + string artistMusicPage = regex.Match(htmlCode).Groups["url"].Value + "/music"; // Retrieve artist "music" page HTML source code using (var webClient = new WebClient() { Encoding = Encoding.UTF8 }) { @@ -441,7 +413,7 @@ private async Task> GetArtistDiscographyAsync(List urls) { if (_cancelDownloads) { // Abort - return new List(); + return new List(); } try { @@ -477,12 +449,12 @@ private async Task> GetArtistDiscographyAsync(List urls) { /// The URL. /// The title of the file to be displayed in the log. /// The type of the file. - private async Task GetFileSizeAsync(String url, String titleForLog, FileType fileType) { + private async Task GetFileSizeAsync(string url, string titleForLog, FileType fileType) { long size = 0; - Boolean sizeRetrieved; + bool sizeRetrieved; int tries = 0; - String fileTypeForLog; - String protocolMethod; + string fileTypeForLog; + string protocolMethod; switch (fileType) { case FileType.Artwork: @@ -548,7 +520,7 @@ private async Task> GetFilesToDownloadAsync(List albums) // Tracks if (App.UserSettings.RetrieveFilesSize) { - Int32[] tracksIndexes = Enumerable.Range(0, album.Tracks.Count).ToArray(); + int[] tracksIndexes = Enumerable.Range(0, album.Tracks.Count).ToArray(); await Task.WhenAll(tracksIndexes.Select(async i => { long size = await GetFileSizeAsync(album.Tracks[i].Mp3Url, album.Tracks[i].Title, FileType.Track); files.Add(new TrackFile(album.Tracks[i].Mp3Url, 0, size)); diff --git a/src/BandcampDownloader/Core/LogArgs.cs b/src/BandcampDownloader/Core/LogArgs.cs index e4e4955c..50295533 100644 --- a/src/BandcampDownloader/Core/LogArgs.cs +++ b/src/BandcampDownloader/Core/LogArgs.cs @@ -4,9 +4,9 @@ namespace BandcampDownloader { internal class LogArgs: EventArgs { public LogType LogType { get; private set; } - public String Message { get; private set; } + public string Message { get; private set; } - public LogArgs(String message, LogType logType) { + public LogArgs(string message, LogType logType) { Message = message; LogType = logType; } diff --git a/src/BandcampDownloader/Core/PlaylistCreator.cs b/src/BandcampDownloader/Core/PlaylistCreator.cs index 771745df..986a1db8 100644 --- a/src/BandcampDownloader/Core/PlaylistCreator.cs +++ b/src/BandcampDownloader/Core/PlaylistCreator.cs @@ -24,7 +24,7 @@ public PlaylistCreator(Album album) { /// Saves the playlist to a file. /// public void SavePlaylistToFile() { - String fileContent; + string fileContent; switch (App.UserSettings.PlaylistFormat) { case PlaylistFormat.m3u: @@ -49,7 +49,7 @@ public void SavePlaylistToFile() { /// /// Returns the playlist in m3u format. /// - private String CreateM3uPlaylist() { + private string CreateM3uPlaylist() { var playlist = new M3uPlaylist() { IsExtended = App.UserSettings.M3uExtended, }; @@ -70,7 +70,7 @@ private String CreateM3uPlaylist() { /// /// Returns the playlist in pls format. /// - private String CreatePlsPlaylist() { + private string CreatePlsPlaylist() { var playlist = new PlsPlaylist(); foreach (Track track in _album.Tracks) { @@ -87,7 +87,7 @@ private String CreatePlsPlaylist() { /// /// Returns the playlist in wpl format. /// - private String CreateWplPlaylist() { + private string CreateWplPlaylist() { var playlist = new WplPlaylist() { Title = _album.Title, }; @@ -109,7 +109,7 @@ private String CreateWplPlaylist() { /// /// Returns the playlist in zpl format. /// - private String CreateZplPlaylist() { + private string CreateZplPlaylist() { var playlist = new ZplPlaylist() { Title = _album.Title, }; diff --git a/src/BandcampDownloader/Core/UserSettings.cs b/src/BandcampDownloader/Core/UserSettings.cs index 24672400..9b2921fd 100644 --- a/src/BandcampDownloader/Core/UserSettings.cs +++ b/src/BandcampDownloader/Core/UserSettings.cs @@ -1,5 +1,4 @@ -using System; -using System.ComponentModel; +using System.ComponentModel; using Config.Net; namespace BandcampDownloader { @@ -51,72 +50,72 @@ public enum TagRemoveAction { public interface IUserSettings { [Option(DefaultValue = 0.05)] - Double AllowedFileSizeDifference { get; set; } + double AllowedFileSizeDifference { get; set; } [Option(DefaultValue = true)] - Boolean CheckForUpdates { get; set; } + bool CheckForUpdates { get; set; } [Option(DefaultValue = "{album}")] - String CoverArtFileNameFormat { get; set; } + string CoverArtFileNameFormat { get; set; } [Option(DefaultValue = true)] - Boolean CoverArtInFolderConvertToJpg { get; set; } + bool CoverArtInFolderConvertToJpg { get; set; } [Option(DefaultValue = 1000)] int CoverArtInFolderMaxSize { get; set; } [Option(DefaultValue = false)] - Boolean CoverArtInFolderResize { get; set; } + bool CoverArtInFolderResize { get; set; } [Option(DefaultValue = true)] - Boolean CoverArtInTagsConvertToJpg { get; set; } + bool CoverArtInTagsConvertToJpg { get; set; } [Option(DefaultValue = 1000)] int CoverArtInTagsMaxSize { get; set; } [Option(DefaultValue = true)] - Boolean CoverArtInTagsResize { get; set; } + bool CoverArtInTagsResize { get; set; } [Option(DefaultValue = false)] - Boolean CreatePlaylist { get; set; } + bool CreatePlaylist { get; set; } [Option(DefaultValue = false)] - Boolean DownloadArtistDiscography { get; set; } + bool DownloadArtistDiscography { get; set; } [Option(DefaultValue = 7)] int DownloadMaxTries { get; set; } [Option(DefaultValue = false)] - Boolean DownloadOneAlbumAtATime { get; set; } + bool DownloadOneAlbumAtATime { get; set; } // Time in seconds between retries [Option(DefaultValue = 0.2)] - Double DownloadRetryCooldown { get; set; } + double DownloadRetryCooldown { get; set; } // Exponential per cooldown - ex. (value of 1.2 would yield cooldowns of x^(1.2^0), x^(1.2^1), x^(1.2^2), ..) [Option(DefaultValue = 4.0)] - Double DownloadRetryExponent { get; set; } + double DownloadRetryExponent { get; set; } [Option(DefaultValue = "")] - String DownloadsPath { get; set; } + string DownloadsPath { get; set; } [Option(DefaultValue = false)] - Boolean EnableApplicationSounds { get; set; } + bool EnableApplicationSounds { get; set; } [Option(DefaultValue = "{tracknum} {artist} - {title}.mp3")] - String FileNameFormat { get; set; } + string FileNameFormat { get; set; } [Option(DefaultValue = Language.en)] Language Language { get; set; } [Option(DefaultValue = true)] - Boolean M3uExtended { get; set; } + bool M3uExtended { get; set; } [Option(DefaultValue = true)] - Boolean ModifyTags { get; set; } + bool ModifyTags { get; set; } [Option(DefaultValue = "{album}")] - String PlaylistFileNameFormat { get; set; } + string PlaylistFileNameFormat { get; set; } [Option(DefaultValue = PlaylistFormat.m3u)] PlaylistFormat PlaylistFormat { get; set; } @@ -125,22 +124,22 @@ public interface IUserSettings { ProxyType Proxy { get; set; } [Option(DefaultValue = "")] - String ProxyHttpAddress { get; set; } + string ProxyHttpAddress { get; set; } [Option(DefaultValue = "")] int ProxyHttpPort { get; set; } [Option(DefaultValue = true)] - Boolean RetrieveFilesSize { get; set; } + bool RetrieveFilesSize { get; set; } [Option(DefaultValue = false)] - Boolean SaveCoverArtInFolder { get; set; } + bool SaveCoverArtInFolder { get; set; } [Option(DefaultValue = true)] - Boolean SaveCoverArtInTags { get; set; } + bool SaveCoverArtInTags { get; set; } [Option(DefaultValue = false)] - Boolean ShowVerboseLog { get; set; } + bool ShowVerboseLog { get; set; } [Option(DefaultValue = TagEditAction.Modify)] TagEditAction TagAlbumArtist { get; set; } diff --git a/src/BandcampDownloader/Helpers/BandcampHelper.cs b/src/BandcampDownloader/Helpers/BandcampHelper.cs index 6098b9e2..8a82e3df 100644 --- a/src/BandcampDownloader/Helpers/BandcampHelper.cs +++ b/src/BandcampDownloader/Helpers/BandcampHelper.cs @@ -14,9 +14,9 @@ internal static class BandcampHelper { /// /// The HTML source code of a Bandcamp album page. /// The data on the album of the specified Bandcamp page. - public static Album GetAlbum(String htmlCode) { + public static Album GetAlbum(string htmlCode) { // Keep the interesting part of htmlCode only - String albumData; + string albumData; try { albumData = GetAlbumData(htmlCode); } catch (Exception e) { @@ -56,13 +56,13 @@ public static Album GetAlbum(String htmlCode) { /// /// The HTML source code of a Bandcamp page. /// The albums URL existing on the specified Bandcamp page. - public static List GetAlbumsUrl(String htmlCode) { + public static List GetAlbumsUrl(string htmlCode) { // Get artist bandcamp page var regex = new Regex("band_url = \"(?.*)\""); if (!regex.IsMatch(htmlCode)) { throw new NoAlbumFoundException(); } - String artistPage = regex.Match(htmlCode).Groups["url"].Value; + string artistPage = regex.Match(htmlCode).Groups["url"].Value; // Get albums ("real" albums or track-only pages) relative urls regex = new Regex("href=\"(?/(album|track)/.*)\""); @@ -70,7 +70,7 @@ public static List GetAlbumsUrl(String htmlCode) { throw new NoAlbumFoundException(); } - var albumsUrl = new List(); + var albumsUrl = new List(); foreach (Match m in regex.Matches(htmlCode)) { albumsUrl.Add(artistPage + m.Groups["url"].Value); } @@ -80,29 +80,29 @@ public static List GetAlbumsUrl(String htmlCode) { return albumsUrl; } - private static String FixJson(String albumData) { + private static string FixJson(string albumData) { // Some JSON is not correctly formatted in bandcamp pages, so it needs to be fixed before we can deserialize it // In trackinfo property, we have for instance: // url: "http://verbalclick.bandcamp.com" + "/album/404" // -> Remove the " + " var regex = new Regex("(?url: \".+)\" \\+ \"(?.+\",)"); - String fixedData = regex.Replace(albumData, "${root}${album}"); + string fixedData = regex.Replace(albumData, "${root}${album}"); return fixedData; } - private static String GetAlbumData(String htmlCode) { - String startString = "var TralbumData = {"; - String stopString = "};"; + private static string GetAlbumData(string htmlCode) { + string startString = "var TralbumData = {"; + string stopString = "};"; if (htmlCode.IndexOf(startString) == -1) { // Could not find startString throw new Exception("Could not find the following string in HTML code: var TralbumData = {"); } - String albumDataTemp = htmlCode.Substring(htmlCode.IndexOf(startString) + startString.Length - 1); - String albumData = albumDataTemp.Substring(0, albumDataTemp.IndexOf(stopString) + 1); + string albumDataTemp = htmlCode.Substring(htmlCode.IndexOf(startString) + startString.Length - 1); + string albumData = albumDataTemp.Substring(0, albumDataTemp.IndexOf(stopString) + 1); return albumData; } diff --git a/src/BandcampDownloader/Helpers/EnumerationExtension.cs b/src/BandcampDownloader/Helpers/EnumerationExtension.cs index 995bfb43..d14a5fab 100644 --- a/src/BandcampDownloader/Helpers/EnumerationExtension.cs +++ b/src/BandcampDownloader/Helpers/EnumerationExtension.cs @@ -8,8 +8,8 @@ namespace BandcampDownloader { internal class EnumerationExtension: MarkupExtension { public class EnumerationMember { - public String Description { get; set; } - public Object Value { get; set; } + public string Description { get; set; } + public object Value { get; set; } } private Type _enumType; @@ -34,10 +34,10 @@ public EnumerationExtension(Type enumType) { EnumType = enumType ?? throw new ArgumentNullException("enumType"); } - public override Object ProvideValue(IServiceProvider serviceProvider) { + public override object ProvideValue(IServiceProvider serviceProvider) { Array enumValues = Enum.GetValues(EnumType); EnumerationMember[] enumerationMembers = ( - from Object enumValue in enumValues + from object enumValue in enumValues select new EnumerationMember { Value = enumValue, Description = GetDescription(enumValue) @@ -45,7 +45,7 @@ from Object enumValue in enumValues return enumerationMembers; } - private string GetDescription(Object enumValue) { + private string GetDescription(object enumValue) { return EnumType.GetField(enumValue.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false).FirstOrDefault() is DescriptionAttribute descriptionAttribute ? descriptionAttribute.Description : enumValue.ToString(); } } diff --git a/src/BandcampDownloader/Helpers/Extensions.cs b/src/BandcampDownloader/Helpers/Extensions.cs index 0692ae49..b5911af6 100644 --- a/src/BandcampDownloader/Helpers/Extensions.cs +++ b/src/BandcampDownloader/Helpers/Extensions.cs @@ -10,7 +10,7 @@ internal static class Extensions { /// /// Returns true if scroll position of the current RichTextBox is at the end; false otherwise. /// - public static Boolean IsScrolledToEnd(this RichTextBox richTextBox) { + public static bool IsScrolledToEnd(this RichTextBox richTextBox) { return richTextBox.VerticalOffset > richTextBox.ExtentHeight - richTextBox.ViewportHeight - 10; } @@ -18,7 +18,7 @@ public static Boolean IsScrolledToEnd(this RichTextBox richTextBox) { /// Replaces the forbidden chars \ / : * ? " < > | from the System.String /// object by an underscore _ in order to be used for a Windows file or folder. /// - public static String ToAllowedFileName(this String fileName) { + public static string ToAllowedFileName(this string fileName) { if (fileName == null) { throw new ArgumentNullException("fileName"); } diff --git a/src/BandcampDownloader/Helpers/FileHelper.cs b/src/BandcampDownloader/Helpers/FileHelper.cs index 03479d4e..cb0e8ee5 100644 --- a/src/BandcampDownloader/Helpers/FileHelper.cs +++ b/src/BandcampDownloader/Helpers/FileHelper.cs @@ -13,7 +13,7 @@ internal static class FileHelper { /// The protocol method to use in order to retrieve the file /// size. /// The size of the file located at the provided URL. - public static async Task GetFileSizeAsync(String url, String protocolMethod) { + public static async Task GetFileSizeAsync(string url, string protocolMethod) { WebRequest webRequest = HttpWebRequest.Create(url); webRequest.Method = protocolMethod; long fileSize; @@ -27,4 +27,4 @@ public static async Task GetFileSizeAsync(String url, String protocolMetho return fileSize; } } -} +} \ No newline at end of file diff --git a/src/BandcampDownloader/Helpers/TagHelper.cs b/src/BandcampDownloader/Helpers/TagHelper.cs index f460c360..456e65ec 100644 --- a/src/BandcampDownloader/Helpers/TagHelper.cs +++ b/src/BandcampDownloader/Helpers/TagHelper.cs @@ -1,6 +1,4 @@ -using System; - -namespace BandcampDownloader { +namespace BandcampDownloader { internal static class TagHelper { @@ -10,13 +8,13 @@ internal static class TagHelper { /// The file to update. /// The value used if TagEditAction = Modify. /// The TagEditAction specifying how the tag should be updated. - public static TagLib.File UpdateAlbumArtist(TagLib.File file, String albumArtist, TagEditAction editAction) { + public static TagLib.File UpdateAlbumArtist(TagLib.File file, string albumArtist, TagEditAction editAction) { switch (editAction) { case TagEditAction.Empty: - file.Tag.AlbumArtists = new String[1] { "" }; + file.Tag.AlbumArtists = new string[1] { "" }; break; case TagEditAction.Modify: - file.Tag.AlbumArtists = new String[1] { albumArtist }; + file.Tag.AlbumArtists = new string[1] { albumArtist }; break; case TagEditAction.DoNotModify: break; @@ -32,7 +30,7 @@ public static TagLib.File UpdateAlbumArtist(TagLib.File file, String albumArtist /// The file to update. /// The value used if TagEditAction = Modify. /// The TagEditAction specifying how the tag should be updated. - public static TagLib.File UpdateAlbumTitle(TagLib.File file, String albumTitle, TagEditAction editAction) { + public static TagLib.File UpdateAlbumTitle(TagLib.File file, string albumTitle, TagEditAction editAction) { switch (editAction) { case TagEditAction.Empty: file.Tag.Album = ""; @@ -76,13 +74,13 @@ public static TagLib.File UpdateAlbumYear(TagLib.File file, uint albumYear, TagE /// The file to update. /// The value used if TagEditAction = Modify. /// The TagEditAction specifying how the tag should be updated. - public static TagLib.File UpdateArtist(TagLib.File file, String artist, TagEditAction editAction) { + public static TagLib.File UpdateArtist(TagLib.File file, string artist, TagEditAction editAction) { switch (editAction) { case TagEditAction.Empty: - file.Tag.Performers = new String[1] { "" }; + file.Tag.Performers = new string[1] { "" }; break; case TagEditAction.Modify: - file.Tag.Performers = new String[1] { artist }; + file.Tag.Performers = new string[1] { artist }; break; case TagEditAction.DoNotModify: break; @@ -116,7 +114,7 @@ public static TagLib.File UpdateComments(TagLib.File file, TagRemoveAction remov /// The file to update. /// The value used if TagEditAction = Modify. /// The TagEditAction specifying how the tag should be updated. - public static TagLib.File UpdateTrackLyrics(TagLib.File file, String trackLyrics, TagEditAction editAction) { + public static TagLib.File UpdateTrackLyrics(TagLib.File file, string trackLyrics, TagEditAction editAction) { switch (editAction) { case TagEditAction.Empty: file.Tag.Lyrics = ""; @@ -160,7 +158,7 @@ public static TagLib.File UpdateTrackNumber(TagLib.File file, uint trackNumber, /// The file to update. /// The value used if TagEditAction = Modify. /// The TagEditAction specifying how the tag should be updated. - public static TagLib.File UpdateTrackTitle(TagLib.File file, String trackTitle, TagEditAction editAction) { + public static TagLib.File UpdateTrackTitle(TagLib.File file, string trackTitle, TagEditAction editAction) { switch (editAction) { case TagEditAction.Empty: file.Tag.Title = ""; diff --git a/src/BandcampDownloader/Helpers/UpdatesHelper.cs b/src/BandcampDownloader/Helpers/UpdatesHelper.cs index f180fccd..eb1c4676 100644 --- a/src/BandcampDownloader/Helpers/UpdatesHelper.cs +++ b/src/BandcampDownloader/Helpers/UpdatesHelper.cs @@ -1,5 +1,6 @@ using System; using System.Net; +using System.Threading.Tasks; namespace BandcampDownloader { @@ -8,16 +9,16 @@ internal static class UpdatesHelper { /// /// Returns the latest version available. /// - public static Version GetLatestVersion() { + public static async Task GetLatestVersionAsync() { // Note: GitHub uses a HTTP redirect to redirect from the generic latest release page to the actual latest release page // Retrieve the redirect page from the GitHub latest release page - var request = HttpWebRequest.CreateHttp(Constants.LatestReleaseWebsite); + var request = HttpWebRequest.CreateHttp(Constants.UrlLatestRelease); request.AllowAutoRedirect = false; - String redirectPage = ""; + string redirectPage = ""; try { - using (var response = (HttpWebResponse) request.GetResponse()) { - redirectPage = response.GetResponseHeader("Location"); + using (WebResponse response = await request.GetResponseAsync()) { + redirectPage = ((HttpWebResponse) response).GetResponseHeader("Location"); // redirectPage should be like "https://github.com/Otiel/BandcampDownloader/releases/tag/vX.X.X.X" } } catch { @@ -25,7 +26,7 @@ public static Version GetLatestVersion() { } // Extract the version number from the URL - String latestVersionNumber; + string latestVersionNumber; try { latestVersionNumber = redirectPage.Substring(redirectPage.LastIndexOf("/v") + 2); // X.X.X.X } catch { diff --git a/src/BandcampDownloader/Model/Album.cs b/src/BandcampDownloader/Model/Album.cs index faa57ecb..1e2d7b79 100644 --- a/src/BandcampDownloader/Model/Album.cs +++ b/src/BandcampDownloader/Model/Album.cs @@ -8,27 +8,27 @@ internal class Album { /// /// The album artist. /// - public String Artist { get; set; } + public string Artist { get; set; } /// /// The local path (full path with file name) where the artwork file should be saved. /// - public String ArtworkPath { get; private set; } + public string ArtworkPath { get; private set; } /// /// The local path (full path with file name) to the %TEMP% folder where the artwork file should be saved. /// - public String ArtworkTempPath { get; private set; } + public string ArtworkTempPath { get; private set; } /// /// The URL where the artwork should be downloaded from. /// - public String ArtworkUrl { get; set; } + public string ArtworkUrl { get; set; } /// /// True if the album has an artwork; false otherwise. /// - public Boolean HasArtwork { + public bool HasArtwork { get { return ArtworkUrl != null; } @@ -37,12 +37,12 @@ public Boolean HasArtwork { /// /// The local path (full path) to the folder where the album should be saved. /// - public String Path { get; private set; } + public string Path { get; private set; } /// /// The local path (full path with file name) where the playlist file should be saved. /// - public String PlaylistPath { get; private set; } + public string PlaylistPath { get; private set; } /// /// The release date of the album. @@ -52,7 +52,7 @@ public Boolean HasArtwork { /// /// The album title. /// - public String Title { get; set; } + public string Title { get; set; } /// /// The list of tracks contained in the album. @@ -62,7 +62,7 @@ public Boolean HasArtwork { /// /// Initializes a new Album. /// - public Album(String artist, String artworkUrl, DateTime releaseDate, String title) { + public Album(string artist, string artworkUrl, DateTime releaseDate, string title) { Artist = artist; ArtworkUrl = artworkUrl; ReleaseDate = releaseDate; @@ -77,7 +77,7 @@ public Album(String artist, String artworkUrl, DateTime releaseDate, String titl /// /// Returns the file extension to be used for the playlist, depending of the type of playlist defined in UserSettings. /// - private static String GetPlaylistFileExtension() { + private static string GetPlaylistFileExtension() { switch (App.UserSettings.PlaylistFormat) { case PlaylistFormat.m3u: return ".m3u"; @@ -97,8 +97,8 @@ private static String GetPlaylistFileExtension() { /// the UserSettings, by replacing the placeholders strings with their corresponding values. /// The returned file name does NOT contain the extension. /// - private String ParseCoverArtFileName() { - String fileName = App.UserSettings.CoverArtFileNameFormat + private string ParseCoverArtFileName() { + string fileName = App.UserSettings.CoverArtFileNameFormat .Replace("{year}", ReleaseDate.Year.ToString()) .Replace("{month}", ReleaseDate.Month.ToString("00")) .Replace("{day}", ReleaseDate.Day.ToString("00")) @@ -111,8 +111,8 @@ private String ParseCoverArtFileName() { /// Returns the folder path from the specified path format, by replacing the placeholders strings with their /// corresponding values. If the path is too long (> 247 characters), it will be stripped. /// - private String ParseFolderPath() { - String path = App.UserSettings.DownloadsPath; + private string ParseFolderPath() { + string path = App.UserSettings.DownloadsPath; path = path.Replace("{year}", ReleaseDate.Year.ToString().ToAllowedFileName()); path = path.Replace("{month}", ReleaseDate.Month.ToString("00").ToAllowedFileName()); path = path.Replace("{day}", ReleaseDate.Day.ToString("00").ToAllowedFileName()); @@ -131,8 +131,8 @@ private String ParseFolderPath() { /// Returns the file name to be used for the playlist file of the specified album from the file name format saved /// in the UserSettings, by replacing the placeholders strings with their corresponding values. /// - private String ParsePlaylistFileName() { - String fileName = App.UserSettings.PlaylistFileNameFormat + private string ParsePlaylistFileName() { + string fileName = App.UserSettings.PlaylistFileNameFormat .Replace("{year}", ReleaseDate.Year.ToString()) .Replace("{month}", ReleaseDate.Month.ToString("00")) .Replace("{day}", ReleaseDate.Day.ToString("00")) @@ -146,11 +146,11 @@ private String ParsePlaylistFileName() { /// replacing the placeholders strings with their corresponding values. If the path is too long (> 259 /// characters), it will be stripped. /// - private String ParsePlaylistPath() { - String fileExt = GetPlaylistFileExtension(); + private string ParsePlaylistPath() { + string fileExt = GetPlaylistFileExtension(); // Compute paths where to save artwork - String filePath = Path + "\\" + ParsePlaylistFileName() + fileExt; + string filePath = Path + "\\" + ParsePlaylistFileName() + fileExt; if (filePath.Length >= 260) { // Windows doesn't do well with path + filename >= 260 characters (and path >= 248 characters) @@ -167,10 +167,10 @@ private String ParsePlaylistPath() { /// private void SetArtworkPaths() { if (HasArtwork) { - String artworkFileExt = System.IO.Path.GetExtension(ArtworkUrl); + string artworkFileExt = System.IO.Path.GetExtension(ArtworkUrl); // In order to prevent #54 (artworkTempPath used at the same time by another downloading thread), we'll add a random number to the name of the artwork file saved in Temp directory - String randomNumber = App.Random.Next(1, 1000).ToString("00#"); + string randomNumber = App.Random.Next(1, 1000).ToString("00#"); // Compute paths where to save artwork ArtworkTempPath = System.IO.Path.GetTempPath() + "\\" + ParseCoverArtFileName() + randomNumber + artworkFileExt; diff --git a/src/BandcampDownloader/Model/JSON/JsonAlbum.cs b/src/BandcampDownloader/Model/JSON/JsonAlbum.cs index faf5c04d..f3fcd0d5 100644 --- a/src/BandcampDownloader/Model/JSON/JsonAlbum.cs +++ b/src/BandcampDownloader/Model/JSON/JsonAlbum.cs @@ -6,17 +6,17 @@ namespace BandcampDownloader { internal class JsonAlbum { - private readonly String _urlEnd = "_0.jpg"; - private readonly String _urlStart = "https://f4.bcbits.com/img/a"; // Uses the art_id variable to retrieve the image from Bandcamp hosting site + private readonly string _urlEnd = "_0.jpg"; + private readonly string _urlStart = "https://f4.bcbits.com/img/a"; // Uses the art_id variable to retrieve the image from Bandcamp hosting site [JsonProperty("current")] public JsonAlbumData AlbumData { get; set; } [JsonProperty("art_id")] - public String ArtId { get; set; } + public string ArtId { get; set; } [JsonProperty("artist")] - public String Artist { get; set; } + public string Artist { get; set; } [JsonProperty("album_release_date")] public DateTime ReleaseDate { get; set; } @@ -26,7 +26,7 @@ internal class JsonAlbum { public Album ToAlbum() { // Some albums do not have a cover art - String artworkUrl = ArtId == null ? null : _urlStart + ArtId.PadLeft(10, '0') + _urlEnd; + string artworkUrl = ArtId == null ? null : _urlStart + ArtId.PadLeft(10, '0') + _urlEnd; var album = new Album(Artist, artworkUrl, ReleaseDate, AlbumData.AlbumTitle); diff --git a/src/BandcampDownloader/Model/JSON/JsonAlbumData.cs b/src/BandcampDownloader/Model/JSON/JsonAlbumData.cs index d040069d..1ad75c17 100644 --- a/src/BandcampDownloader/Model/JSON/JsonAlbumData.cs +++ b/src/BandcampDownloader/Model/JSON/JsonAlbumData.cs @@ -1,11 +1,10 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace BandcampDownloader { internal class JsonAlbumData { [JsonProperty("title")] - public String AlbumTitle { get; set; } + public string AlbumTitle { get; set; } } } \ No newline at end of file diff --git a/src/BandcampDownloader/Model/JSON/JsonMp3File.cs b/src/BandcampDownloader/Model/JSON/JsonMp3File.cs index d097be36..2727bf45 100644 --- a/src/BandcampDownloader/Model/JSON/JsonMp3File.cs +++ b/src/BandcampDownloader/Model/JSON/JsonMp3File.cs @@ -1,11 +1,10 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace BandcampDownloader { internal class JsonMp3File { [JsonProperty("mp3-128")] - public String Url { get; set; } + public string Url { get; set; } } } \ No newline at end of file diff --git a/src/BandcampDownloader/Model/JSON/JsonTrack.cs b/src/BandcampDownloader/Model/JSON/JsonTrack.cs index b5bb67e8..c57d46c2 100644 --- a/src/BandcampDownloader/Model/JSON/JsonTrack.cs +++ b/src/BandcampDownloader/Model/JSON/JsonTrack.cs @@ -1,27 +1,26 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace BandcampDownloader { internal class JsonTrack { [JsonProperty("duration")] - public Double Duration { get; set; } + public double Duration { get; set; } [JsonProperty("file")] public JsonMp3File File { get; set; } [JsonProperty("lyrics")] - public String Lyrics { get; set; } + public string Lyrics { get; set; } [JsonProperty("track_num")] public int Number { get; set; } [JsonProperty("title")] - public String Title { get; set; } + public string Title { get; set; } public Track ToTrack(Album album) { - String mp3Url = (File.Url.StartsWith("//") ? "http:" : "") + File.Url; // "//example.com" Uri lacks protocol + string mp3Url = (File.Url.StartsWith("//") ? "http:" : "") + File.Url; // "//example.com" Uri lacks protocol int number = Number == 0 ? 1 : Number; // For bandcamp track pages, Number will be 0. Set 1 instead return new Track(album, Duration, Lyrics, mp3Url, number, Title); diff --git a/src/BandcampDownloader/Model/Track.cs b/src/BandcampDownloader/Model/Track.cs index 8ec9fee7..346c7c2b 100644 --- a/src/BandcampDownloader/Model/Track.cs +++ b/src/BandcampDownloader/Model/Track.cs @@ -1,6 +1,4 @@ -using System; - -namespace BandcampDownloader { +namespace BandcampDownloader { internal class Track { @@ -12,17 +10,17 @@ internal class Track { /// /// The track length (in seconds). /// - public Double Duration { get; set; } + public double Duration { get; set; } /// /// The track lyrics. /// - public String Lyrics { get; set; } + public string Lyrics { get; set; } /// /// The URL where the track should be downloaded from. /// - public String Mp3Url { get; set; } + public string Mp3Url { get; set; } /// /// The track number. @@ -32,17 +30,17 @@ internal class Track { /// /// The local path (full path with file name) where the track file should be saved. /// - public String Path { get; private set; } + public string Path { get; private set; } /// /// The track title. /// - public String Title { get; set; } + public string Title { get; set; } /// /// Initializes a new Track. /// - public Track(Album album, Double duration, String lyrics, String mp3Url, int number, String title) { + public Track(Album album, double duration, string lyrics, string mp3Url, int number, string title) { Album = album; Duration = duration; Lyrics = lyrics; @@ -57,8 +55,8 @@ public Track(Album album, Double duration, String lyrics, String mp3Url, int num /// Returns the file name to be used for the track from the file name format saved in the UserSettings, by /// replacing the placeholders strings with their corresponding values. The returned file name DOES contain the extension. /// - private String ParseTrackFileName() { - String fileName = App.UserSettings.FileNameFormat + private string ParseTrackFileName() { + string fileName = App.UserSettings.FileNameFormat .Replace("{year}", Album.ReleaseDate.Year.ToString()) .Replace("{month}", Album.ReleaseDate.Month.ToString("00")) .Replace("{day}", Album.ReleaseDate.Day.ToString("00")) @@ -73,10 +71,10 @@ private String ParseTrackFileName() { /// Returns the file path to be used for the track from the file name format saved in the UserSettings, by /// replacing the placeholders strings with their corresponding values. The returned file path DOES contain the extension. /// - private String ParseTrackFilePath() { - String fileName = ParseTrackFileName(); + private string ParseTrackFilePath() { + string fileName = ParseTrackFileName(); - String path = Album.Path + "\\" + fileName; + string path = Album.Path + "\\" + fileName; if (path.Length >= 260) { // Windows doesn't do well with path + filename >= 260 characters (and path >= 248 characters) // album.Path has been shorten to 247 characters before, so we have 12 characters max left for "\filename.ext", so 11 character max for "filename.ext" diff --git a/src/BandcampDownloader/Model/TrackFile.cs b/src/BandcampDownloader/Model/TrackFile.cs index 8b24af9d..aa75055e 100644 --- a/src/BandcampDownloader/Model/TrackFile.cs +++ b/src/BandcampDownloader/Model/TrackFile.cs @@ -1,14 +1,12 @@ -using System; - -namespace BandcampDownloader { +namespace BandcampDownloader { internal class TrackFile { public long BytesReceived { get; set; } - public Boolean Downloaded { get; set; } + public bool Downloaded { get; set; } public long Size { get; set; } - public String Url { get; set; } + public string Url { get; set; } - public TrackFile(String url, long bytesReceived, long size) { + public TrackFile(string url, long bytesReceived, long size) { Url = url; BytesReceived = bytesReceived; Size = size; diff --git a/src/BandcampDownloader/Properties/AssemblyInfo.cs b/src/BandcampDownloader/Properties/AssemblyInfo.cs index 8c91246c..f0a95192 100644 --- a/src/BandcampDownloader/Properties/AssemblyInfo.cs +++ b/src/BandcampDownloader/Properties/AssemblyInfo.cs @@ -1,10 +1,8 @@ using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Windows; -// General Information about an assembly is controlled through the following +// 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("BandcampDownloader")] @@ -16,12 +14,12 @@ [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 +// 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)] -//In order to begin building localizable applications, set +//In order to begin building localizable applications, set //CultureYouAreCodingWith in your .csproj file //inside a . For example, if you are using US english //in your source files, set the to en-US. Then uncomment @@ -30,27 +28,25 @@ //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) + //(used if a resource is not found in the page, + // or application resource dictionaries) ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) )] - // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Build and Revision Numbers +// 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("0.2.9.0")] -[assembly: AssemblyFileVersion("0.2.9.0")] -[assembly: GuidAttribute("8C171C7F-9BAC-4EC0-A287-59908B48953F")] +[assembly: AssemblyVersion("0.2.10.0")] +[assembly: AssemblyFileVersion("0.2.10.0")] +[assembly: GuidAttribute("8C171C7F-9BAC-4EC0-A287-59908B48953F")] \ No newline at end of file diff --git a/src/BandcampDownloader/Properties/Resources.Designer.cs b/src/BandcampDownloader/Properties/Resources.Designer.cs index 45084ba2..70d20414 100644 --- a/src/BandcampDownloader/Properties/Resources.Designer.cs +++ b/src/BandcampDownloader/Properties/Resources.Designer.cs @@ -169,6 +169,15 @@ internal static string buttonStop { } } + /// + /// Looks up a localized string similar to _View. + /// + internal static string buttonViewChangelog { + get { + return ResourceManager.GetString("buttonViewChangelog", resourceCulture); + } + } + /// /// Looks up a localized string similar to Could not download changelog from {0}. /// @@ -556,6 +565,15 @@ internal static string labelButtonResetSettings { } } + /// + /// Looks up a localized string similar to Changelog. + /// + internal static string labelChangelog { + get { + return ResourceManager.GetString("labelChangelog", resourceCulture); + } + } + /// /// Looks up a localized string similar to Changelog. /// @@ -673,6 +691,15 @@ internal static string labelHttpPort { } } + /// + /// Looks up a localized string similar to Report a bug. + /// + internal static string labelIssues { + get { + return ResourceManager.GetString("labelIssues", resourceCulture); + } + } + /// /// Looks up a localized string similar to _Language. /// @@ -683,155 +710,182 @@ internal static string labelLanguage { } /// - /// Looks up a localized string similar to _Lyrics. + /// Looks up a localized string similar to About. /// - internal static string labelLyrics { + internal static string labelListBoxItemAbout { get { - return ResourceManager.GetString("labelLyrics", resourceCulture); + return ResourceManager.GetString("labelListBoxItemAbout", resourceCulture); } } /// - /// Looks up a localized string similar to File _name format. + /// Looks up a localized string similar to Advanced settings. /// - internal static string labelPlaylistFileNameFormat { + internal static string labelListBoxItemAdvanced { get { - return ResourceManager.GetString("labelPlaylistFileNameFormat", resourceCulture); + return ResourceManager.GetString("labelListBoxItemAdvanced", resourceCulture); } } /// - /// Looks up a localized string similar to Playlist _format. + /// Looks up a localized string similar to Cover art. /// - internal static string labelPlaylistFormat { + internal static string labelListBoxItemCoverArt { get { - return ResourceManager.GetString("labelPlaylistFormat", resourceCulture); + return ResourceManager.GetString("labelListBoxItemCoverArt", resourceCulture); } } /// - /// Looks up a localized string similar to Some settings cannot be changed while tracks are downloading.. + /// Looks up a localized string similar to Downloads. /// - internal static string labelSettingsInfo { + internal static string labelListBoxItemDownloads { get { - return ResourceManager.GetString("labelSettingsInfo", resourceCulture); + return ResourceManager.GetString("labelListBoxItemDownloads", resourceCulture); } } /// - /// Looks up a localized string similar to Track n_umber. + /// Looks up a localized string similar to General. /// - internal static string labelTrackNumber { + internal static string labelListBoxItemGeneral { get { - return ResourceManager.GetString("labelTrackNumber", resourceCulture); + return ResourceManager.GetString("labelListBoxItemGeneral", resourceCulture); } } /// - /// Looks up a localized string similar to _Title. + /// Looks up a localized string similar to Network. /// - internal static string labelTrackTitle { + internal static string labelListBoxItemNetwork { get { - return ResourceManager.GetString("labelTrackTitle", resourceCulture); + return ResourceManager.GetString("labelListBoxItemNetwork", resourceCulture); } } /// - /// Looks up a localized string similar to (the log file is always verbose). + /// Looks up a localized string similar to Playlist. /// - internal static string labelVerboseLogInfo { + internal static string labelListBoxItemPlaylist { get { - return ResourceManager.GetString("labelVerboseLogInfo", resourceCulture); + return ResourceManager.GetString("labelListBoxItemPlaylist", resourceCulture); } } /// - /// Looks up a localized string similar to Could not check for updates. + /// Looks up a localized string similar to Naming and tags. /// - internal static string labelVersionError { + internal static string labelListBoxItemTags { get { - return ResourceManager.GetString("labelVersionError", resourceCulture); + return ResourceManager.GetString("labelListBoxItemTags", resourceCulture); } } /// - /// Looks up a localized string similar to A new version is available. + /// Looks up a localized string similar to _Lyrics. /// - internal static string labelVersionNewUpdateAvailable { + internal static string labelLyrics { get { - return ResourceManager.GetString("labelVersionNewUpdateAvailable", resourceCulture); + return ResourceManager.GetString("labelLyrics", resourceCulture); } } /// - /// Looks up a localized string similar to Album release _year. + /// Looks up a localized string similar to File _name format. /// - internal static string labelYear { + internal static string labelPlaylistFileNameFormat { get { - return ResourceManager.GetString("labelYear", resourceCulture); + return ResourceManager.GetString("labelPlaylistFileNameFormat", resourceCulture); } } /// - /// Looks up a localized string similar to Advanced settings. + /// Looks up a localized string similar to Playlist _format. /// - internal static string listBoxItemAdvanced { + internal static string labelPlaylistFormat { get { - return ResourceManager.GetString("listBoxItemAdvanced", resourceCulture); + return ResourceManager.GetString("labelPlaylistFormat", resourceCulture); } } /// - /// Looks up a localized string similar to Cover art. + /// Looks up a localized string similar to Some settings cannot be changed while tracks are downloading.. /// - internal static string listBoxItemCoverArt { + internal static string labelSettingsInfo { get { - return ResourceManager.GetString("listBoxItemCoverArt", resourceCulture); + return ResourceManager.GetString("labelSettingsInfo", resourceCulture); } } /// - /// Looks up a localized string similar to Downloads. + /// Looks up a localized string similar to Track n_umber. /// - internal static string listBoxItemDownloads { + internal static string labelTrackNumber { get { - return ResourceManager.GetString("listBoxItemDownloads", resourceCulture); + return ResourceManager.GetString("labelTrackNumber", resourceCulture); } } /// - /// Looks up a localized string similar to General. + /// Looks up a localized string similar to _Title. /// - internal static string listBoxItemGeneral { + internal static string labelTrackTitle { get { - return ResourceManager.GetString("listBoxItemGeneral", resourceCulture); + return ResourceManager.GetString("labelTrackTitle", resourceCulture); } } /// - /// Looks up a localized string similar to Network. + /// Looks up a localized string similar to (the log file is always verbose). /// - internal static string listBoxItemNetwork { + internal static string labelVerboseLogInfo { get { - return ResourceManager.GetString("listBoxItemNetwork", resourceCulture); + return ResourceManager.GetString("labelVerboseLogInfo", resourceCulture); } } /// - /// Looks up a localized string similar to Playlist. + /// Looks up a localized string similar to Version. /// - internal static string listBoxItemPlaylist { + internal static string labelVersion { get { - return ResourceManager.GetString("listBoxItemPlaylist", resourceCulture); + return ResourceManager.GetString("labelVersion", resourceCulture); } } /// - /// Looks up a localized string similar to Naming and tags. + /// Looks up a localized string similar to Could not check for updates. + /// + internal static string labelVersionError { + get { + return ResourceManager.GetString("labelVersionError", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A new version is available. /// - internal static string listBoxItemTags { + internal static string labelVersionNewUpdateAvailable { get { - return ResourceManager.GetString("listBoxItemTags", resourceCulture); + return ResourceManager.GetString("labelVersionNewUpdateAvailable", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Website. + /// + internal static string labelWebsite { + get { + return ResourceManager.GetString("labelWebsite", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Album release _year. + /// + internal static string labelYear { + get { + return ResourceManager.GetString("labelYear", resourceCulture); } } @@ -956,6 +1010,15 @@ internal static string radioButtonSystemProxy { } } + /// + /// Looks up a localized string similar to Save as. + /// + internal static string saveFileDialogTitle { + get { + return ResourceManager.GetString("saveFileDialogTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Do not modify. /// @@ -1002,11 +1065,11 @@ internal static string TagRemoveAction_Empty { } /// - /// Looks up a localized string similar to Go to website. + /// Looks up a localized string similar to Releases history. /// - internal static string textBlockGoToWebsite { + internal static string textBlockReleasesWebsite { get { - return ResourceManager.GetString("textBlockGoToWebsite", resourceCulture); + return ResourceManager.GetString("textBlockReleasesWebsite", resourceCulture); } } diff --git a/src/BandcampDownloader/Properties/Resources.de.resx b/src/BandcampDownloader/Properties/Resources.de.resx index 7133696e..3131c2b2 100644 --- a/src/BandcampDownloader/Properties/Resources.de.resx +++ b/src/BandcampDownloader/Properties/Resources.de.resx @@ -150,6 +150,9 @@ _Abbrechen + + _View + Could not download changelog from {0} @@ -269,6 +272,9 @@ Das Herunterladen geht schneller wenn diese Option ausgeschaltet ist. _Zurücksetzen + + Changelog + Changelog @@ -308,9 +314,36 @@ Das Herunterladen geht schneller wenn diese Option ausgeschaltet ist. _Port + + Report a bug + S_prache + + About + + + Erweiterte Einstellungen + + + Cover + + + Downloads + + + Generell + + + Netzwerk + + + Playlist + + + Benennungen und Tags + Son_gtexte @@ -332,36 +365,21 @@ Das Herunterladen geht schneller wenn diese Option ausgeschaltet ist. (Die Logdatei ist immer ausführlich) + + Version + Konnte nicht auf Updates prüfen Eine neue Version ist verfügbar + + Website + Album _Veröffentlichungsjahr - - Erweiterte Einstellungen - - - Cover - - - Downloads - - - Generell - - - Netzwerk - - - Playlist - - - Benennungen und Tags - &Abbrechen @@ -405,11 +423,8 @@ Wollen sie zur Homepage gehen um die neuste version herunterzuladen? S_ystem Proxy - - Nicht ändern - - - Löschen des Tags + + Save as Nicht ändern @@ -420,6 +435,15 @@ Wollen sie zur Homepage gehen um die neuste version herunterzuladen? Im Tag speichern + + Nicht ändern + + + Löschen des Tags + + + Releases history + Hilfe zur Übersetzung @@ -474,9 +498,6 @@ Empfohlender Wert = 4 - {album} Wird mit dem albumnamen ersetzt - {year}, {month} und {day} werden mit dem Erscheinungsdatum ersetzt - - Go to website - You can use placeholders to customize the file name: - {artist} will be replaced by the album artist diff --git a/src/BandcampDownloader/Properties/Resources.fr.resx b/src/BandcampDownloader/Properties/Resources.fr.resx index c9d1a08b..3a3f5029 100644 --- a/src/BandcampDownloader/Properties/Resources.fr.resx +++ b/src/BandcampDownloader/Properties/Resources.fr.resx @@ -150,6 +150,9 @@ _Annuler + + _Voir + Impossible de télécharger les notes de version depuis {0} @@ -269,6 +272,9 @@ Décocher cette option permet de gagner du temps. _Réinitialiser + + Notes de version + Notes de version @@ -308,9 +314,36 @@ Décocher cette option permet de gagner du temps. _Port + + Signaler un bug + _Langue + + À propos + + + Paramètres avancés + + + Pochette + + + Téléchargements + + + Général + + + Réseau + + + Liste de lecture + + + Noms et métadonnées + _Paroles @@ -332,36 +365,21 @@ Décocher cette option permet de gagner du temps. (le fichier log est toujours verbeux) + + Version + Impossible de vérifier les mises à jour Une nouvelle version est disponible + + Site web + Année _de parution de l'album - - Paramètres avancés - - - Pochette - - - Téléchargements - - - Général - - - Réseau - - - Liste de lecture - - - Noms et métadonnées - &Annuler @@ -405,11 +423,8 @@ Voulez-vous aller sur le site web du projet afin de récupérer la dernière ver Proxy _système - - Ne pas modifier - - - Vider les métadonnées + + Save as Ne pas modifier @@ -420,6 +435,15 @@ Voulez-vous aller sur le site web du projet afin de récupérer la dernière ver Enregistrer dans les métadonnées + + Ne pas modifier + + + Vider les métadonnées + + + Historique des versions + Aider à la traduction @@ -474,9 +498,6 @@ Valeur conseillée = 4 - {album} sera remplacé par le nom de l'album - {year} (année), {month} (mois) et {day} (jour) seront remplacés par la date de parution de l'album - - Site web - Vous pouvez utiliser des paramètres de substitution pour personnaliser le nom des fichiers : - {artist} sera remplacé par l'interprète de l'album diff --git a/src/BandcampDownloader/Properties/Resources.it.resx b/src/BandcampDownloader/Properties/Resources.it.resx index 585d54af..5ed5c582 100644 --- a/src/BandcampDownloader/Properties/Resources.it.resx +++ b/src/BandcampDownloader/Properties/Resources.it.resx @@ -1,4 +1,4 @@ - +