From f8c5ed23da0c4b183d68f4b0a4a4bf37d29b7b0a Mon Sep 17 00:00:00 2001 From: fiso64 Date: Tue, 27 Aug 2024 18:48:50 +0200 Subject: [PATCH] commit --- README.md | 39 +++++++++++++++---------------- slsk-batchdl/Config.cs | 8 +++---- slsk-batchdl/Data.cs | 1 + slsk-batchdl/Help.cs | 14 +++++------ slsk-batchdl/Program.cs | 12 ++++++---- slsk-batchdl/SearchAndDownload.cs | 16 +++++++++---- 6 files changed, 50 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index f5c8f80..ae2f8c6 100644 --- a/README.md +++ b/README.md @@ -199,8 +199,8 @@ Usage: sldl [OPTIONS] Aggregate Download -g, --aggregate Aggregate download mode: Find and download all distinct songs associated with the provided artist, album, or title. - --min-users-aggregate Minimum number of users sharing a track or album for it to - be downloaded in aggregate mode. (Default: 2) + --min-shares-aggregate Minimum number of shares of a track or album for it to be + downloaded in aggregate mode. (Default: 2) --relax-filtering Slightly relax file filtering in aggregate mode to include more results ``` @@ -288,26 +288,25 @@ Input String | Artist | Title | Album | Lengt string or csv row has no track title, or when -a/--album is enabled. ### Aggregate - With -g/--aggregate, sldl will first perform an ordinary search for the input, then - attempt to group the results into distinct songs and download one of each kind. A common use - case is finding all remixes of a song or printing all songs by an artist that are not your - music dir. - Two files are considered equal if their inferred track title and artist name are equal - (ignoring case and some special characters), and their lengths are within --length-tol of each - other. - Note that this mode is not 100% reliable, which is why --min-users-aggregate is set to 2 by default, - i.e. any song that is shared by only one peer will be ignored. Enable --relax-filtering to - make the file filtering less aggressive. +With -g/--aggregate, sldl will first perform an ordinary search for the input, then attempt to +group the results into distinct songs and download one of each kind. A common use case is +finding all remixes of a song or printing all songs by an artist that are not your music dir. +Two files are considered equal if their inferred track title and artist name are equal +(ignoring case and some special characters), and their lengths are within --length-tol of each +other. +Note that this mode is not 100% reliable, which is why --min-shares-aggregate is set to 2 by +default, i.e. any song that is shared only once will be ignored. Enable --relax-filtering to +make the file filtering less aggressive. ### Album Aggregate - Activated when --album and --aggregate are enabled, in this mode sldl searches for the query - and groups results into distinct albums. Two folders are considered same if they have the - same number of audio files, and the durations of the files are within --length-tol of each - other (or within 3 seconds if length-tol is not configured). If both folders have exactly one - audio file with similar lengths, also checks if the inferred title and artist name coincide. - More reliable than normal aggregate due to much simpler grouping logic. - Note that --min-users-aggregate is 2 by default, which means that folders shared by only one - peer are ignored. +Activated when --album and --aggregate are enabled, in this mode sldl searches for the query +and groups results into distinct albums. Two folders are considered same if they have the +same number of audio files, and the durations of the files are within --length-tol of each +other (or within 3 seconds if length-tol is not configured). If both folders have exactly one +audio file with similar lengths, also checks if the inferred title and artist name coincide. +More reliable than normal aggregate due to much simpler grouping logic. +Note that --min-shares-aggregate is 2 by default, which means that folders shared only once +will be ignored. ## Searching diff --git a/slsk-batchdl/Config.cs b/slsk-batchdl/Config.cs index bbd84df..fee2d51 100644 --- a/slsk-batchdl/Config.cs +++ b/slsk-batchdl/Config.cs @@ -80,7 +80,7 @@ static class Config public static int minAlbumTrackCount = -1; public static int maxAlbumTrackCount = -1; public static int fastSearchDelay = 300; - public static int minUsersAggregate = 2; + public static int minSharesAggregate = 2; public static int maxTracks = int.MaxValue; public static int offset = 0; public static int maxStaleTime = 50000; @@ -625,9 +625,9 @@ static class Config case "--aggregate": setFlag(ref aggregate, ref i); break; - case "--mua": - case "--min-users-aggregate": - minUsersAggregate = int.Parse(args[++i]); + case "--msa": + case "--min-shares-aggregate": + minSharesAggregate = int.Parse(args[++i]); break; case "--rf": case "--relax": diff --git a/slsk-batchdl/Data.cs b/slsk-batchdl/Data.cs index 72fe363..fe6d716 100644 --- a/slsk-batchdl/Data.cs +++ b/slsk-batchdl/Data.cs @@ -25,6 +25,7 @@ namespace Data public bool OutputsDirectory => Type != TrackType.Normal; public Soulseek.File? FirstDownload => Downloads?.FirstOrDefault().Value.Item2; + public string? FirstUsername => Downloads?.FirstOrDefault().Value.Item1.Username; public Track() { } diff --git a/slsk-batchdl/Help.cs b/slsk-batchdl/Help.cs index 916c30c..5d55d25 100644 --- a/slsk-batchdl/Help.cs +++ b/slsk-batchdl/Help.cs @@ -172,8 +172,8 @@ public static class Help Aggregate Download -g, --aggregate Aggregate download mode: Find and download all distinct songs associated with the provided artist, album, or title. - --min-users-aggregate Minimum number of users sharing a track or album for it to - be downloaded in aggregate mode. (Default: 2) + --min-shares-aggregate Minimum number of shares of a track or album for it to be + downloaded in aggregate mode. (Default: 2) --relax-filtering Slightly relax file filtering in aggregate mode to include more results @@ -265,9 +265,9 @@ public static class Help Two files are considered equal if their inferred track title and artist name are equal (ignoring case and some special characters), and their lengths are within --length-tol of each other. - Note that this mode is not 100% reliable, which is why --min-users-aggregate is set to 2 by - default, i.e. any song that is shared by only one peer will be ignored. Enable --relax-filtering - to make the file filtering less aggressive. + Note that this mode is not 100% reliable, which is why --min-shares-aggregate is set to 2 by + default, i.e. any song that is shared only once will be ignored. Enable --relax-filtering to + make the file filtering less aggressive. Album Aggregate Activated when --album and --aggregate are enabled, in this mode sldl searches for the query @@ -276,8 +276,8 @@ public static class Help other (or within 3 seconds if length-tol is not configured). If both folders have exactly one audio file with similar lengths, also checks if the inferred title and artist name coincide. More reliable than normal aggregate due to much simpler grouping logic. - Note that --min-users-aggregate is 2 by default, which means that folders shared by only one - peer are ignored. + Note that --min-shares-aggregate is 2 by default, which means that folders shared only once + will be ignored. "; const string searchHelp = @" diff --git a/slsk-batchdl/Program.cs b/slsk-batchdl/Program.cs index 001a76e..1702f8e 100644 --- a/slsk-batchdl/Program.cs +++ b/slsk-batchdl/Program.cs @@ -243,10 +243,10 @@ static partial class Program if (tle.needSourceSearch) { - Console.WriteLine($"{tle.source.Type} download: {tle.source.ToString(true)}, searching.."); - await InitClientAndUpdateIfNeeded(); + Console.WriteLine($"{tle.source.Type} download: {tle.source.ToString(true)}, searching.."); + if (tle.source.Type == TrackType.Album) { tle.list = await GetAlbumDownloads(tle.source, responseData); @@ -260,7 +260,10 @@ static partial class Program var res = await GetAggregateAlbums(tle.source, responseData); foreach (var item in res) - trackLists.AddEntry(new TrackListEntry(item, tle.source, false, true, true, false, false)); + { + var newSource = new Track(tle.source) { Type = TrackType.Album }; + trackLists.AddEntry(new TrackListEntry(item, newSource, false, true, true, false, false)); + } } if (Config.skipExisting && tle.needSkipExistingAfterSearch) @@ -993,7 +996,8 @@ static partial class Program user = new string(Enumerable.Repeat(chars, 10).Select(s => s[r.Next(s.Length)]).ToArray()); pass = new string(Enumerable.Repeat(chars, 10).Select(s => s[r.Next(s.Length)]).ToArray()); } - WriteLine($"Login {user}", debugOnly: true); + + WriteLine($"Login {user}"); while (true) { diff --git a/slsk-batchdl/SearchAndDownload.cs b/slsk-batchdl/SearchAndDownload.cs index 6dcddf1..d115c18 100644 --- a/slsk-batchdl/SearchAndDownload.cs +++ b/slsk-batchdl/SearchAndDownload.cs @@ -482,18 +482,24 @@ static partial class Program var albums = await GetAlbumDownloads(track, responseData); - var sortedLengthLists = new List<(int[] lengths, List album)>(); + var sortedLengthLists = new List<(int[] lengths, List album, string username)>(); foreach (var album in albums) { + if (album.Count == 0) + { + continue; + } + var sortedLengths = album.Where(x => !x.IsNotAudio).Select(x => x.Length).OrderBy(x => x).ToArray(); - sortedLengthLists.Add((sortedLengths, album)); + string user = album[0].FirstUsername; + sortedLengthLists.Add((sortedLengths, album, user)); } var lengthsList = new List(); var res = new List>>(); - foreach ((var lengths, var album) in sortedLengthLists) + foreach ((var lengths, var album, var user) in sortedLengthLists) { bool found = false; @@ -536,7 +542,7 @@ static partial class Program } } - res = res.Where(x => x.Count >= Config.minUsersAggregate).OrderByDescending(x => x.Count).ToList(); + res = res.Where(x => x.Count >= Config.minSharesAggregate).OrderByDescending(x => x.Count).ToList(); return res; // Note: The nested lists are still ordered according to OrderedResults } @@ -611,7 +617,7 @@ static partial class Program IEnumerable<(SlResponse, SlFile)> fileResponses, int minShares = -1) { if (minShares == -1) - minShares = Config.minUsersAggregate; + minShares = Config.minSharesAggregate; Track inferTrack((SearchResponse r, Soulseek.File f) x) {