1
0
Fork 0
mirror of https://github.com/fiso64/slsk-batchdl.git synced 2024-12-22 06:22:41 +00:00

fix album conditions

This commit is contained in:
fiso64 2024-09-02 22:43:28 +02:00
parent 5b4df5faff
commit b15bb01c89
4 changed files with 47 additions and 39 deletions

View file

@ -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. "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. 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 The following options will make it go faster, but may decrease search result quality or cause
instability: instability:
- --fast-search skips waiting until the search completes and downloads as soon as a file - --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 - --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 - --max-stale-time is set to 50 seconds by default, so it will wait a long time before giving
up on a file up on a file
- --searches-per-time increase at the risk of bans. - --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.
## File conditions ## 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 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. 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 ### Important note
Some info may be unavailable depending on the client used by the peer. For example, the standard 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 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 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. 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 ## Name format
Variables enclosed in {} will be replaced by the corresponding file tag value. Variables enclosed in {} will be replaced by the corresponding file tag value.

View file

@ -34,8 +34,11 @@ public class FileConditions
AcceptNoLength = other.AcceptNoLength; AcceptNoLength = other.AcceptNoLength;
StrictArtist = other.StrictArtist; StrictArtist = other.StrictArtist;
StrictTitle = other.StrictTitle; StrictTitle = other.StrictTitle;
StrictAlbum = other.StrictAlbum;
MinBitDepth = other.MinBitDepth; MinBitDepth = other.MinBitDepth;
MaxBitDepth = other.MaxBitDepth; MaxBitDepth = other.MaxBitDepth;
AcceptMissingProps = other.AcceptMissingProps;
StrictStringDiacrRemove = other.StrictStringDiacrRemove;
Formats = other.Formats.ToArray(); Formats = other.Formats.ToArray();
BannedUsers = other.BannedUsers.ToArray(); BannedUsers = other.BannedUsers.ToArray();
} }
@ -203,7 +206,7 @@ public class FileConditions
if (!StrictAlbum || alname.Length == 0) if (!StrictAlbum || alname.Length == 0)
return true; 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) public static string StrictStringPreprocess(string str, bool diacrRemove = true)

View file

@ -324,25 +324,16 @@ public static class Help
""Waiting""). By default it is configured to allow up to 34 searches every 220 seconds. ""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. 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 The following options will make it go faster, but may decrease search result quality or cause
instability: 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 --fast-search skips waiting until the search completes and downloads as soon as a file
The options --strict-title, --strict-artist and --strict-album will filter any file that matching the preferred conditions is found
does not contain the title/artist/album in the filename (ignoring case, bounded by boundary --concurrent-downloads - set it to 4 or more
chars). --max-stale-time is set to 50 seconds by default, so it will wait a long time before giving
Another way to prevent false downloads is to set --length-tol to 3 or less to make it ignore up on a file
any songs that differ from the input by more than 3 seconds. However, all 4 options are already --searches-per-time - increase at the risk of bans.
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.
"; ";
const string fileConditionsHelp = @" 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, 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 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. 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 Important note
Some info may be unavailable depending on the client used by the peer. For example, the standard 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 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 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. 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 = @" const string nameFormatHelp = @"

View file

@ -295,6 +295,10 @@ static class Search
responseFilter: (response) => responseFilter: (response) =>
{ {
return response.UploadSpeed > 0 && nec.BannedUsersSatisfies(response); return response.UploadSpeed > 0 && nec.BannedUsersSatisfies(response);
},
fileFilter: (file) =>
{
return !Utils.IsMusicFile(file.Filename) || nec.FileSatisfies(file, track, null);
} }
); );
void handler(SlResponse r) void handler(SlResponse r)
@ -304,14 +308,14 @@ static class Search
if (r.Files.Count > 0) if (r.Files.Count > 0)
{ {
foreach (var file in r.Files) 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(); using var cts = new CancellationTokenSource();
await RunSearches(track, results, getSearchOptions, handler, cts.Token); 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); var orderedResults = OrderedResults(results, track, false, false, albumMode: true);