From 9d1c0de2fd6f9ce8b5d53f7d7a52be2b2277d472 Mon Sep 17 00:00:00 2001 From: fiso64 Date: Sun, 19 Nov 2023 18:02:19 +0100 Subject: [PATCH] csv parse bug --- slsk-batchdl/Program.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/slsk-batchdl/Program.cs b/slsk-batchdl/Program.cs index 9d270d4..4a0a6b9 100644 --- a/slsk-batchdl/Program.cs +++ b/slsk-batchdl/Program.cs @@ -186,7 +186,7 @@ static class Program "\n -n --number Download the first n tracks of a playlist" + "\n -o --offset Skip a specified number of tracks" + "\n --reverse Download tracks in reverse order" + - "\n --remove-from-playlist Remove downloaded tracks from playlist (for spotify only)" + + "\n --remove-from-playlist Remove downloaded tracks from playlist (spotify only)" + "\n --name-format Name format for downloaded tracks, e.g \"{artist} - {title}\"" + "\n --m3u Create an m3u8 playlist file" + "\n" + @@ -210,7 +210,7 @@ static class Program "\n --pref-banned-users Comma-separated list of users to deprioritize" + "\n --pref-danger-words Comma-separated list of words that should appear in either" + "\n both search result and track title or in neither of the" + - "\n two. (default: see github)" + + "\n two. (default: \"mix,dj , edit,cover\")" + "\n" + "\n -s --skip-existing Skip if a track matching file conditions is found in the" + "\n output folder or your music library (if provided)" + @@ -224,7 +224,7 @@ static class Program "\n during the last run." + "\n --remove-ft Remove \"ft.\" or \"feat.\" and everything after from the" + "\n track names before searching" + - "\n --remove-regex Remove a regex from all track names and artist names " + + "\n --remove-regex Remove a regex from all track titles and artist names" + "\n --no-artist-search Perform a search without artist name if nothing was" + "\n found. Only use for sources such as youtube or soundcloud" + "\n where the \"artist\" could just be an uploader." + @@ -234,7 +234,7 @@ static class Program "\n --yt-dlp Use yt-dlp to download tracks that weren't found on" + "\n Soulseek. yt-dlp must be available from the command line." + "\n" + - "\n --config Specify config file location" + + "\n --config Manually specify config file location" + "\n --search-timeout Max search time in ms (default: 6000)" + "\n --max-stale-time Max download time without progress in ms (default: 50000)" + "\n --concurrent-downloads Max concurrent searches & downloads (default: 2)" + @@ -786,7 +786,7 @@ static class Program var d = RemoveTracksIfExist(tracks, musicDir, necessaryCond, useTagsCheckExisting, preciseSkip); d.ToList().ForEach(x => existing.TryAdd(x.Key, x.Value)); } - else if (!System.IO.Directory.Exists(musicDir)) + else if (musicDir != "" && !System.IO.Directory.Exists(musicDir)) Console.WriteLine($"Path does not exist: {musicDir}"); foreach (var x in existing) @@ -1932,9 +1932,8 @@ static class Program static async Task> ParseCsvIntoTrackInfo(string path, string? artistCol = "", string? trackCol = "", - string? lengthCol = "", string? albumCol = "", string? descCol = "", string? ytIdCol = "", string timeUnit = "", bool ytParse = false) + string? lengthCol = "", string? albumCol = "", string? descCol = "", string? ytIdCol = "", string timeUnit = "s", bool ytParse = false) { - if (timeUnit == "") timeUnit = "s"; var tracks = new List(); using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) @@ -1993,7 +1992,7 @@ static class Program var descIndex = string.IsNullOrEmpty(cols[4]) ? -1 : Array.IndexOf(header, cols[4]); var ytIdIndex = string.IsNullOrEmpty(cols[5]) ? -1 : Array.IndexOf(header, cols[5]); - var regex = new Regex($"{Regex.Escape(d)}(?=(?:[^\"']*\"[^\"']*\")*[^\"']*$)"); // thank you, ChatGPT. + var regex = new Regex($"{Regex.Escape(d)}(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"); while (!reader.EndOfStream) { @@ -2005,7 +2004,7 @@ static class Program var desc = ""; var track = new Track(); - if (artistIndex >= 0) track.ArtistName = values[artistIndex].Trim('"').Split(',').First().Trim(' '); + if (artistIndex >= 0) track.ArtistName = values[artistIndex].Trim('"'); if (trackIndex >= 0) track.TrackTitle = values[trackIndex].Trim('"'); if (albumIndex >= 0) track.Album = values[albumIndex].Trim('"'); if (descIndex >= 0) desc = values[descIndex].Trim('"');