Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fiso64 committed Feb 9, 2025
1 parent 6fef76e commit 54e1722
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 38 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Usage: sldl <input> [OPTIONS]
is unavailable.
--search-timeout <ms> Max search time in ms (default: 6000)
--max-stale-time <ms> Max download time without progress in ms (default: 50000)
--max-stale-time <ms> Max download time without progress in ms (default: 30000)
--searches-per-time <num> Max searches per time interval. Higher values may cause
30-minute bans, see `--help search`. (default: 34)
--searches-renew-time <sec> Controls how often available searches are replenished.
Expand Down Expand Up @@ -334,7 +334,7 @@ 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, sldl will wait a long time before giving
- `--max-stale-time` is set to 30 seconds by default, sldl will wait a long time before giving
up on a file
- `--album-parallel-search` - enables parallel searching for album entries

Expand Down Expand Up @@ -521,15 +521,15 @@ To activate the above profile, run `--profile lossless`. To list all available p
run `--profile help`.
Profiles can be activated automatically based on a few simple conditions:
```ini
# never automatically cancel album downloads in interactive mode
[no-stale]
profile-cond = interactive && download-mode == "album"
max-stale-time = 9999999
# album downloads will never be automatically cancelled in interactive mode

# download to another location for youtube
[youtube]
profile-cond = input-type == "youtube"
path = ~/downloads/sldl-youtube
# download to another location for youtube
```
The following operators are supported for use in profile-cond: &&, ||, ==, !=, !{bool}.
The following variables are available:
Expand Down
2 changes: 1 addition & 1 deletion slsk-batchdl/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class Config
public int minSharesAggregate = 2;
public int maxTracks = int.MaxValue;
public int offset = 0;
public int maxStaleTime = 50000;
public int maxStaleTime = 30000;
public int searchTimeout = 6000;
public int concurrentProcesses = 2;
public int unknownErrorRetries = 2;
Expand Down
8 changes: 4 additions & 4 deletions slsk-batchdl/Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Soulseek. yt-dlp must be available from the command line.
is unavailable.
--search-timeout <ms> Max search time in ms (default: 6000)
--max-stale-time <ms> Max download time without progress in ms (default: 50000)
--max-stale-time <ms> Max download time without progress in ms (default: 30000)
--searches-per-time <num> Max searches per time interval. Higher values may cause
30-minute bans, see `--help search`. (default: 34)
--searches-renew-time <sec> Controls how often available searches are replenished.
Expand Down Expand Up @@ -309,7 +309,7 @@ Speeding things up
- `--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, sldl will wait a long time before giving
- `--max-stale-time` is set to 30 seconds by default, sldl will wait a long time before giving
up on a file
- `--album-parallel-search` - enables parallel searching for album entries
";
Expand Down Expand Up @@ -449,15 +449,15 @@ directory. The path variable {bindir} stores the directory of the sldl binary.
run `--profile help`.
Profiles can be activated automatically based on a few simple conditions:
# never automatically cancel album downloads in interactive mode
[no-stale]
profile-cond = interactive && download-mode == ""album""
max-stale-time = 9999999
# album downloads will never be automatically cancelled in interactive mode
# download to another location for youtube
[youtube]
profile-cond = input-type == ""youtube""
path = ~/downloads/sldl-youtube
# download to another location for youtube
The following operators are supported for use in profile-cond: &&, ||, ==, !=, !{bool}.
The following variables are available for use in profile-cond:
Expand Down
33 changes: 8 additions & 25 deletions slsk-batchdl/Services/Searcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,30 +190,12 @@ async Task<bool> process(SlResponse response, SlFile file)
}
}

// the first result is usually fine, no need to sort the entire sequence
var fr = orderedResults.First();
bool success = await process(fr.response, fr.file);

if (!success)
foreach (var (response, file) in orderedResults)
{
fr = orderedResults.Skip(1).FirstOrDefault();
if (fr != default)
{
if (userSuccessCounts.GetValueOrDefault(fr.response.Username, 0) > config.ignoreOn)
{
success = await process(fr.response, fr.file);
}
if (!success)
{
foreach (var (response, file) in orderedResults.Skip(2))
{
if (userSuccessCounts.GetValueOrDefault(response.Username, 0) <= config.ignoreOn)
continue;
success = await process(response, file);
if (success) break;
}
}
}
if (userSuccessCounts.GetValueOrDefault(response.Username, 0) <= config.ignoreOn)
continue;
bool success = await process(response, file);
if (success) break;
}
}

Expand Down Expand Up @@ -704,7 +686,7 @@ Track inferTrack((SearchResponse r, Soulseek.File f) x)
}


public IOrderedEnumerable<(SlResponse response, SlFile file)> OrderedResults(
public IEnumerable<(SlResponse response, SlFile file)> OrderedResults(
IEnumerable<KeyValuePair<string, (SlResponse, SlFile)>> results,
Track track,
Config config,
Expand All @@ -716,7 +698,7 @@ Track inferTrack((SearchResponse r, Soulseek.File f) x)
}


public IOrderedEnumerable<(SlResponse response, SlFile file)> OrderedResults(
public IEnumerable<(SlResponse response, SlFile file)> OrderedResults(
IEnumerable<(SlResponse, SlFile)> results,
Track track,
Config config,
Expand Down Expand Up @@ -778,6 +760,7 @@ int levenshtein((SearchResponse response, Soulseek.File file) x)
.ThenByDescending(x => config.preferredCond.BitDepthSatisfies(x.file))
.ThenByDescending(x => config.preferredCond.FileSatisfies(x.file, track, x.response))
.ThenByDescending(x => x.response.HasFreeUploadSlot)
.ThenByDescending(x => x.response.QueueLength == 0)
.ThenByDescending(x => x.response.UploadSpeed / 1024 / 650)
.ThenByDescending(x => albumMode || FileConditions.StrictString(x.file.Filename, track.Title))
.ThenByDescending(x => !albumMode || FileConditions.StrictString(Utils.GetDirectoryNameSlsk(x.file.Filename), track.Album))
Expand Down
8 changes: 4 additions & 4 deletions slsk-batchdl/slsk-batchdl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

<ItemGroup>
<PackageReference Include="Goblinfactory.ProgressBar" Version="1.0.0" />
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.63.0.3205" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.54" />
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.69.0.3680" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.72" />
<PackageReference Include="SmallestCSVParser" Version="1.1.1" />
<PackageReference Include="Soulseek" Version="6.5.0" />
<PackageReference Include="SpotifyAPI.Web" Version="7.1.1" />
<PackageReference Include="SpotifyAPI.Web.Auth" Version="7.1.1" />
<PackageReference Include="SpotifyAPI.Web" Version="7.2.1" />
<PackageReference Include="SpotifyAPI.Web.Auth" Version="7.2.1" />
<PackageReference Include="TagLibSharp" Version="2.3.0" />
<PackageReference Include="YoutubeExplode" Version="6.5.3" />
</ItemGroup>
Expand Down

0 comments on commit 54e1722

Please sign in to comment.