From b15bb01c897cb5d66c7c71a20ca1a13add35d037 Mon Sep 17 00:00:00 2001 From: fiso64 Date: Mon, 2 Sep 2024 22:43:28 +0200 Subject: [PATCH] fix album conditions --- README.md | 33 ++++++++++++++-------------- slsk-batchdl/FileConditions.cs | 5 ++++- slsk-batchdl/Help.cs | 40 ++++++++++++++++++---------------- slsk-batchdl/Search.cs | 8 +++++-- 4 files changed, 47 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 2fbe42b..c8d1fe3 100644 --- a/README.md +++ b/README.md @@ -355,7 +355,7 @@ The search query is determined as follows: "Waiting"). By default it is configured to allow up to 34 searches every 220 seconds. The default values were determined through experimentation, so they may be incorrect. -### Quality vs Speed +### Speeding things up The following options will make it go faster, but may decrease search result quality or cause instability: - --fast-search skips waiting until the search completes and downloads as soon as a file @@ -363,18 +363,7 @@ The search query is determined as follows: - --concurrent-downloads - set it to 4 or more - --max-stale-time is set to 50 seconds by default, so it will wait a long time before giving up on a file - - --searches-per-time increase at the risk of bans. - -### Quality vs Quantity - The options --strict-title, --strict-artist and --strict-album will filter any file that - does not contain the title/artist/album in the filename (ignoring case, bounded by boundary - chars). - Another way to prevent false downloads is to set --length-tol to 3 or less to make it ignore - any songs that differ from the input by more than 3 seconds. However, all 4 options are already - enabled as 'preferred' conditions by default, meaning that such files will only be downloaded - as a last resort anyways. Hence it is only recommended to enable them if you need to minimize - false downloads as much as possible. - + - --searches-per-time - increase at the risk of bans. ## File conditions @@ -402,6 +391,20 @@ that don't satisfy any condition, but some conditions have precedence over other a file that only satisfies strict-title (if enabled) will always be preferred over a file that only satisfies the format condition. Run with --print "results-full" to reveal the sorting logic. +Conditions can also be supplied as a semicolon-delimited string with --cond and --pref, e.g +--cond "br >= 320; format = mp3,ogg; sr < 96000". + +### Filtering irrelevant results + The options --strict-title, --strict-artist and --strict-album will filter any file that + does not contain the title/artist/album in the filename (ignoring case, bounded by boundary + chars). + Another way to prevent false downloads is to set --length-tol to 3 or less to make it ignore + any songs that differ from the input by more than 3 seconds. However, all 4 options are already + enabled as 'preferred' conditions by default, meaning that such files will only be downloaded + as a last resort anyways. Hence it is only recommended to enable them if you need to minimize + false downloads as much as possible, or for special cases like tracks or albums whose name + is just one or a two characters. + ### Important note Some info may be unavailable depending on the client used by the peer. For example, the standard Soulseek client does not share the file bitrate. If (e.g) --min-bitrate is set, then sldl will @@ -411,10 +414,6 @@ only satisfies the format condition. Run with --print "results-full" to reveal t client will be ignored. Also note that the default preferred conditions will already affect ranking with this option due to the bitrate and samplerate checks. -Conditions can also be supplied as a semicolon-delimited string with --cond and --pref, e.g ---cond "br >= 320; format = mp3,ogg; sr < 96000". - - ## Name format Variables enclosed in {} will be replaced by the corresponding file tag value. diff --git a/slsk-batchdl/FileConditions.cs b/slsk-batchdl/FileConditions.cs index dfbb6db..a23a3e9 100644 --- a/slsk-batchdl/FileConditions.cs +++ b/slsk-batchdl/FileConditions.cs @@ -34,8 +34,11 @@ public class FileConditions AcceptNoLength = other.AcceptNoLength; StrictArtist = other.StrictArtist; StrictTitle = other.StrictTitle; + StrictAlbum = other.StrictAlbum; MinBitDepth = other.MinBitDepth; MaxBitDepth = other.MaxBitDepth; + AcceptMissingProps = other.AcceptMissingProps; + StrictStringDiacrRemove = other.StrictStringDiacrRemove; Formats = other.Formats.ToArray(); BannedUsers = other.BannedUsers.ToArray(); } @@ -203,7 +206,7 @@ public class FileConditions if (!StrictAlbum || alname.Length == 0) return true; - return StrictString(Utils.GetDirectoryNameSlsk(fname), alname, StrictStringDiacrRemove, ignoreCase: true); + return StrictString(Utils.GetDirectoryNameSlsk(fname), alname, StrictStringDiacrRemove, ignoreCase: true, boundarySkipWs: true); } public static string StrictStringPreprocess(string str, bool diacrRemove = true) diff --git a/slsk-batchdl/Help.cs b/slsk-batchdl/Help.cs index 6a73aa3..a53fd82 100644 --- a/slsk-batchdl/Help.cs +++ b/slsk-batchdl/Help.cs @@ -324,25 +324,16 @@ public static class Help ""Waiting""). By default it is configured to allow up to 34 searches every 220 seconds. The default values were determined through experimentation, so they may be incorrect. - Quality vs Speed + Speeding things up The following options will make it go faster, but may decrease search result quality or cause instability: - --fast-search skips waiting until the search completes and downloads as soon as a file - matching the preferred conditions is found - --concurrent-downloads - set it to 4 or more - --max-stale-time is set to 50 seconds by default, so it will wait a long time before giving - up on a file - --searches-per-time increase at the risk of bans. - Quality vs Quantity - The options --strict-title, --strict-artist and --strict-album will filter any file that - does not contain the title/artist/album in the filename (ignoring case, bounded by boundary - chars). - Another way to prevent false downloads is to set --length-tol to 3 or less to make it ignore - any songs that differ from the input by more than 3 seconds. However, all 4 options are already - enabled as 'preferred' conditions by default, meaning that such files will only be downloaded - as a last resort anyways. Hence it is only recommended to enable them if you need to minimize - false downloads as much as possible. + --fast-search skips waiting until the search completes and downloads as soon as a file + matching the preferred conditions is found + --concurrent-downloads - set it to 4 or more + --max-stale-time is set to 50 seconds by default, so it will wait a long time before giving + up on a file + --searches-per-time - increase at the risk of bans. "; const string fileConditionsHelp = @" @@ -371,6 +362,20 @@ public static class Help that don't satisfy any condition, but some conditions have precedence over others. For instance, a file that only satisfies strict-title (if enabled) will always be preferred over a file that only satisfies the format condition. Run with --print ""results-full"" to reveal the sorting logic. + + Conditions can also be supplied as a semicolon-delimited string with --cond and --pref, e.g + --cond ""br >= 320; format = mp3,ogg; sr < 96000"". + + Filtering irrelevant results + The options --strict-title, --strict-artist and --strict-album will filter any file that + does not contain the title/artist/album in the filename (ignoring case, bounded by boundary + chars). + Another way to prevent false downloads is to set --length-tol to 3 or less to make it ignore + any songs that differ from the input by more than 3 seconds. However, all 4 options are already + enabled as 'preferred' conditions by default, meaning that such files will only be downloaded + as a last resort anyways. Hence it is only recommended to enable them if you need to minimize + false downloads as much as possible, or for special cases like tracks or albums whose name + is just one or a two characters. Important note Some info may be unavailable depending on the client used by the peer. For example, the standard @@ -380,9 +385,6 @@ public static class Help As a consequence, if --min-bitrate is also set then any files shared by users with the default client will be ignored. Also note that the default preferred conditions will already affect ranking with this option due to the bitrate and samplerate checks. - - Conditions can also be supplied as a semicolon-delimited string with --cond and --pref, e.g - --cond ""br >= 320; format = mp3,ogg; sr < 96000"". "; const string nameFormatHelp = @" diff --git a/slsk-batchdl/Search.cs b/slsk-batchdl/Search.cs index f4ba14c..dd6acb8 100644 --- a/slsk-batchdl/Search.cs +++ b/slsk-batchdl/Search.cs @@ -295,6 +295,10 @@ static class Search responseFilter: (response) => { return response.UploadSpeed > 0 && nec.BannedUsersSatisfies(response); + }, + fileFilter: (file) => + { + return !Utils.IsMusicFile(file.Filename) || nec.FileSatisfies(file, track, null); } ); void handler(SlResponse r) @@ -304,14 +308,14 @@ static class Search if (r.Files.Count > 0) { foreach (var file in r.Files) - results.TryAdd(r.Username + "\\" + file.Filename, (r, file)); + results.TryAdd(r.Username + '\\' + file.Filename, (r, file)); } } using var cts = new CancellationTokenSource(); await RunSearches(track, results, getSearchOptions, handler, cts.Token); - string fullPath((SearchResponse r, Soulseek.File f) x) { return x.r.Username + "\\" + x.f.Filename; } + string fullPath((SearchResponse r, Soulseek.File f) x) { return x.r.Username + '\\' + x.f.Filename; } var orderedResults = OrderedResults(results, track, false, false, albumMode: true);