diff --git a/README.md b/README.md index c8d1fe3..71da651 100644 --- a/README.md +++ b/README.md @@ -427,7 +427,7 @@ tag1 is null, use tag2. String literals enclosed in parentheses are ignored in t - "{artist( - )title|filename}" If artist and title are not null, name it 'Artist - Title', otherwise use the original filename. - - "{albumartist(/)album(/)track(. )title|(missing-tags/)filename}" + - "{albumartist(/)album(/)track(. )title|(missing-tags/)foldername(/)filename}" Sort files into artist/album folders if all tags are present, otherwise put them in the 'missing-tags' folder. @@ -582,7 +582,7 @@ sldl "artist=MC MENTAL" --aggregate --album --interactive Create a file named `wishlist.txt`, and add some items as detailed in [Input types: List](#list): ```bash echo "title=My Favorite Song, artist=Artist" >> wishlist.txt -echo "album=Album" "format=mp3" >> wishlist.txt +echo "album=Album, album-track-count=5" "format=mp3" >> wishlist.txt ``` Add a profile to your `sldl.conf`: ``` @@ -603,7 +603,7 @@ sldl --profile wishlist ## Notes - For macOS builds you can use publish.sh to build the app. Download dotnet from https://dotnet.microsoft.com/en-us/download/dotnet/6.0, then run `chmod +x publish.sh && sh publish.sh`. For intel macs, uncomment the x64 and comment the arm64 section in publish.sh. -- `--display single` and especially `double` can cause the printed lines to be duplicated or overwritten on some configurations. Use `simple` if that's an issue. +- `--display single` and especially `double` can cause the printed lines to be duplicated or overwritten on some configurations (new windows terminal, git bash). Use another terminal or `--display-mode simple` in case of issues. ## Docker diff --git a/slsk-batchdl/Download.cs b/slsk-batchdl/Download.cs index fb37e86..1b3906e 100644 --- a/slsk-batchdl/Download.cs +++ b/slsk-batchdl/Download.cs @@ -109,7 +109,7 @@ public class DownloadWrapper { public string savePath; public string displayText = ""; - public int downloadRotatingBarState = 0; + public int barState = 0; public Soulseek.File file; public Transfer? transfer; public SearchResponse response; @@ -145,8 +145,6 @@ public class DownloadWrapper public void UpdateText() { - downloadRotatingBarState++; - downloadRotatingBarState %= bars.Length; float? percentage = bytesTransferred / (float)file.Size; queued = (transfer?.State & TransferStates.Queued) != 0; string bar; @@ -156,7 +154,7 @@ public class DownloadWrapper if (stalled) { state = "Stalled"; - bar = ""; + bar = " "; } else if (transfer != null) { @@ -166,9 +164,13 @@ public class DownloadWrapper state = "Queued (R)"; else state = "Queued (L)"; + bar = " "; } else if ((transfer.State & TransferStates.Initializing) != 0) + { state = "Initialize"; + bar = " "; + } else if ((transfer.State & TransferStates.Completed) != 0) { var flag = transfer.State & (TransferStates.Succeeded | TransferStates.Cancelled @@ -178,20 +180,28 @@ public class DownloadWrapper if (flag == TransferStates.Succeeded) success = true; + + bar = ""; } else { state = transfer.State.ToString(); if ((transfer.State & TransferStates.InProgress) != 0) + { downloading = true; + barState = (barState + 1) % bars.Length; + bar = bars[barState] + " "; + } + else + { + bar = " "; + } } - - bar = success ? "" : bars[downloadRotatingBarState] + " "; } else { state = "NullState"; - bar = ""; + bar = " "; } string txt = $"{bar}{state}:".PadRight(14) + $" {displayText}"; diff --git a/slsk-batchdl/FileManager.cs b/slsk-batchdl/FileManager.cs index 7b5eb6b..0dc6897 100644 --- a/slsk-batchdl/FileManager.cs +++ b/slsk-batchdl/FileManager.cs @@ -240,18 +240,20 @@ public class FileManager case "filename": res = Utils.GetFileNameWithoutExtSlsk(slfile?.Filename ?? ""); break; case "foldername": - if (remoteCommonDir == null || slfile == null) + if (string.IsNullOrEmpty(remoteCommonDir) || slfile == null) { - res = Utils.GetBaseNameSlsk(Utils.GetDirectoryNameSlsk(slfile?.Filename ?? "")); - return true; + if (!string.IsNullOrEmpty(remoteCommonDir)) + res = Path.GetFileName(Utils.NormalizedPath(remoteCommonDir)); + else + res = Path.GetDirectoryName(Utils.NormalizedPath(slfile.Filename)); } else { string d = Path.GetDirectoryName(Utils.NormalizedPath(slfile.Filename)); string r = Path.GetFileName(remoteCommonDir); res = Path.Join(r, Path.GetRelativePath(remoteCommonDir, d)); - return true; } + return true; case "extractor": res = Config.I.inputType.ToString(); break; case "default-folder": diff --git a/slsk-batchdl/Help.cs b/slsk-batchdl/Help.cs index a53fd82..277ba94 100644 --- a/slsk-batchdl/Help.cs +++ b/slsk-batchdl/Help.cs @@ -401,7 +401,7 @@ public static class Help ""{artist( - )title|filename}"" If artist and title are not null, name it 'Artist - Title', otherwise use the original filename. - ""{albumartist(/)album(/)track(. )title|(missing-tags/)filename}"" + ""{albumartist(/)album(/)track(. )title|(missing-tags/)foldername(/)filename}"" Sort files into artist/album folders if all tags are present, otherwise put them in the 'missing-tags' folder. diff --git a/slsk-batchdl/Printing.cs b/slsk-batchdl/Printing.cs index 30f4160..816a78e 100644 --- a/slsk-batchdl/Printing.cs +++ b/slsk-batchdl/Printing.cs @@ -298,7 +298,7 @@ public static class Printing if (lastIndex != -1) { int secondLastIndex = gcp.LastIndexOf('\\', lastIndex - 1); - gcp = secondLastIndex == -1 ? gcp[(lastIndex + 1)..] : gcp[(secondLastIndex + 1)..]; + gcp = secondLastIndex == -1 ? gcp : gcp[(secondLastIndex + 1)..]; } return (gcp, res); diff --git a/slsk-batchdl/Program.cs b/slsk-batchdl/Program.cs index 0965750..4c352a7 100644 --- a/slsk-batchdl/Program.cs +++ b/slsk-batchdl/Program.cs @@ -501,7 +501,7 @@ static partial class Program PrintAlbum(tracks); } - var semaphore = new SemaphoreSlim(Config.I.concurrentProcesses); + var semaphore = new SemaphoreSlim(999); // Needs to be uncapped due to a bug that causes album downloads to fail after some time using var cts = new CancellationTokenSource(); try diff --git a/slsk-batchdl/Search.cs b/slsk-batchdl/Search.cs index dd6acb8..68296d8 100644 --- a/slsk-batchdl/Search.cs +++ b/slsk-batchdl/Search.cs @@ -15,25 +15,6 @@ using SlFile = Soulseek.File; using SlDictionary = System.Collections.Concurrent.ConcurrentDictionary; -using System.Diagnostics; - -class TimerReporter -{ - private Stopwatch stopwatch; - - public TimerReporter() - { - stopwatch = new Stopwatch(); - stopwatch.Start(); - } - - public void Report(string message = "") - { - Console.WriteLine($"Time elapsed: {stopwatch.ElapsedMilliseconds} ms. {message}"); - stopwatch.Restart(); - } -} - static class Search { public static RateLimitedSemaphore? searchSemaphore; @@ -604,7 +585,16 @@ static class Search int newFiles = 0; try { - var allFiles = await GetAllFilesInFolder(response.Username, folder, cancellationToken); + List<(string dir, SlFile file)> allFiles; + try + { + allFiles = await GetAllFilesInFolder(response.Username, folder, cancellationToken); + } + catch (Exception e) + { + Console.WriteLine($"Error: Error getting all files in directory '{folder}: {e}'"); + return 0; + } if (allFiles.Count > tracks.Count) {