1
0
Fork 0
mirror of https://github.com/fiso64/slsk-batchdl.git synced 2025-02-25 04:00:50 +00:00
This commit is contained in:
fiso64 2024-12-15 22:35:42 +01:00
parent 104b44ba98
commit 85b94de641
4 changed files with 55 additions and 48 deletions

View file

@ -557,6 +557,7 @@ Add a profile to your `sldl.conf`:
input = ~/sldl/wishlist.txt
input-type = list
index-path = ~/sldl/wishlist-index.sldl
album-parallel-search = true
```
This will create a global index file `wishlist-index.sldl` which will be scanned every time sldl is run to skip wishlist items that have already been downloaded. If you want to continue searching until a version satisfying the preferred conditions is downloaded, also add `skip-check-pref-cond = true` (note that this requires the files to remain in the same spot after being downloaded).
Finally, set up a cron job (or a scheduled task on windows) to periodically run sldl with the following option:

View file

@ -175,6 +175,11 @@ public class Config
ProcessArgs(arguments);
}
public Config()
{
}
public Config Copy() // deep copies all fields except configProfiles and arguments
{
var copy = (Config)this.MemberwiseClone();

View file

@ -5,6 +5,7 @@ using System.Data;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Net.Sockets;
using Konsole;
using Models;
using Enums;
@ -15,7 +16,6 @@ using static Printing;
using Directory = System.IO.Directory;
using File = System.IO.File;
using SlFile = Soulseek.File;
using Konsole;
static partial class Program
{
@ -393,7 +393,7 @@ static partial class Program
await parallelSearchSemaphore.WaitAsync();
progress = enableParallelSearch ? Printing.GetProgressBar(config) : null;
Printing.RefreshOrPrint(progress, 0, $"{tle.source.Type} download: {tle.source.ToString(true)}, searching..", print: true);
Printing.RefreshOrPrint(progress, 0, $" {tle.source.Type} download: {tle.source.ToString(true)}, searching..", print: true);
bool foundSomething = false;
var responseData = new ResponseData();
@ -428,8 +428,12 @@ static partial class Program
if (!foundSomething)
{
var lockedFiles = responseData.lockedFilesCount > 0 ? $" (Found {responseData.lockedFilesCount} locked files)" : "";
var str = progress != null ? $"{tle.source}: " : "";
Printing.RefreshOrPrint(progress, 0, $"{str}No results.{lockedFiles}", true);
var str = progress != null ? $": {tle.source}" : "";
Printing.RefreshOrPrint(progress, 0, $"No results{str}{lockedFiles}", true);
}
else if (progress != null)
{
Printing.RefreshOrPrint(progress, 0, $"Found results: {tle.source}", true);
}
parallelSearchSemaphore.Release();
@ -533,8 +537,6 @@ static partial class Program
{
await Task.WhenAll(parallelSearches.Select(x => x.task));
Console.WriteLine();
foreach (var (tle, task) in parallelSearches)
{
(bool foundSomething, var responseData) = task.Result;

View file

@ -13,7 +13,6 @@ namespace Tests
public static async Task RunAllTests()
{
TestStringUtils();
throw new NotImplementedException("Outdated test code");
//TestAutoProfiles();
//TestProfileConditions();
//await TestStringExtractor();
@ -80,11 +79,11 @@ namespace Tests
//{
// SetCurrentTest("TestAutoProfiles");
// ResetConfig();
// Config.I.inputType = InputType.YouTube;
// Config.I.interactiveMode = true;
// Config.I.aggregate = false;
// Config.I.maxStaleTime = 50000;
// var config = new Config();
// config.inputType = InputType.YouTube;
// config.interactiveMode = true;
// config.aggregate = false;
// config.maxStaleTime = 50000;
// string path = Path.Join(Directory.GetCurrentDirectory(), "test_conf.conf");
@ -110,19 +109,19 @@ namespace Tests
// File.WriteAllText(path, content);
// Config.I.LoadAndParse(new string[] { "-c", path });
// config.LoadAndParse(new string[] { "-c", path });
// var tle = new TrackListEntry(TrackType.Album);
// Config.UpdateProfiles(tle);
// Assert(Config.I.maxStaleTime == 10 && !Config.I.fastSearch && Config.I.necessaryCond.Formats[0] == "flac");
// Assert(config.maxStaleTime == 10 && !config.fastSearch && config.necessaryCond.Formats[0] == "flac");
// ResetConfig();
// Config.I.inputType = InputType.CSV;
// Config.I.album = true;
// Config.I.interactiveMode = true;
// Config.I.useYtdlp = false;
// Config.I.maxStaleTime = 50000;
// config.inputType = InputType.CSV;
// config.album = true;
// config.interactiveMode = true;
// config.useYtdlp = false;
// config.maxStaleTime = 50000;
// content =
// "\n[no-stale]" +
// "\nprofile-cond = interactive && download-mode == \"album\"" +
@ -134,16 +133,16 @@ namespace Tests
// File.WriteAllText(path, content);
// Config.I.LoadAndParse(new string[] { "-c", path });
// config.LoadAndParse(new string[] { "-c", path });
// Config.UpdateProfiles(tle);
// Assert(Config.I.maxStaleTime == 999999 && !Config.I.useYtdlp);
// Assert(config.maxStaleTime == 999999 && !config.useYtdlp);
// ResetConfig();
// Config.I.inputType = InputType.YouTube;
// Config.I.album = false;
// Config.I.interactiveMode = true;
// Config.I.useYtdlp = false;
// Config.I.maxStaleTime = 50000;
// config.inputType = InputType.YouTube;
// config.album = false;
// config.interactiveMode = true;
// config.useYtdlp = false;
// config.maxStaleTime = 50000;
// content =
// "\n[no-stale]" +
// "\nprofile-cond = interactive && download-mode == \"album\"" +
@ -153,10 +152,10 @@ namespace Tests
// "\nyt-dlp = true";
// File.WriteAllText(path, content);
// Config.I.LoadAndParse(new string[] { "-c", path });
// config.LoadAndParse(new string[] { "-c", path });
// Config.UpdateProfiles(new TrackListEntry(TrackType.Normal));
// Assert(Config.I.maxStaleTime == 50000 && Config.I.useYtdlp);
// Assert(config.maxStaleTime == 50000 && config.useYtdlp);
// if (File.Exists(path))
// File.Delete(path);
@ -168,10 +167,10 @@ namespace Tests
//{
// SetCurrentTest("TestProfileConditions");
// Config.I.inputType = InputType.YouTube;
// Config.I.interactiveMode = true;
// Config.I.album = true;
// Config.I.aggregate = false;
// config.inputType = InputType.YouTube;
// config.interactiveMode = true;
// config.album = true;
// config.aggregate = false;
// var conds = new (bool, string)[]
// {
@ -193,7 +192,7 @@ namespace Tests
// foreach ((var b, var c) in conds)
// {
// Console.WriteLine(c);
// Assert(b == Config.I.ProfileConditionSatisfied(c));
// Assert(b == config.ProfileConditionSatisfied(c));
// }
// Passed();
@ -250,29 +249,29 @@ namespace Tests
// var extractor = new Extractors.StringExtractor();
// Config.I.aggregate = false;
// Config.I.album = false;
// config.aggregate = false;
// config.album = false;
// Console.WriteLine("Testing songs: ");
// for (int i = 0; i < strings.Count; i++)
// {
// Config.I.input = strings[i];
// Console.WriteLine(Config.I.input);
// var res = await extractor.GetTracks(Config.I.input, 0, 0, false);
// config.input = strings[i];
// Console.WriteLine(config.input);
// var res = await extractor.GetTracks(config.input, 0, 0, false);
// var t = res[0].list[0][0];
// Assert(Extractors.StringExtractor.InputMatches(Config.I.input));
// Assert(Extractors.StringExtractor.InputMatches(config.input));
// Assert(t.ToKey() == tracks[i].ToKey());
// }
// Console.WriteLine();
// Console.WriteLine("Testing albums");
// Config.I.album = true;
// config.album = true;
// for (int i = 0; i < strings.Count; i++)
// {
// Config.I.input = strings[i];
// Console.WriteLine(Config.I.input);
// var t = (await extractor.GetTracks(Config.I.input, 0, 0, false))[0].source;
// Assert(Extractors.StringExtractor.InputMatches(Config.I.input));
// config.input = strings[i];
// Console.WriteLine(config.input);
// var t = (await extractor.GetTracks(config.input, 0, 0, false))[0].source;
// Assert(Extractors.StringExtractor.InputMatches(config.input));
// Assert(t.ToKey() == albums[i].ToKey());
// }
@ -283,10 +282,10 @@ namespace Tests
//{
// SetCurrentTest("TestM3uEditor");
// Config.I.skipMode = SkipMode.Index;
// Config.I.skipMusicDir = "";
// Config.I.printOption = PrintOption.Tracks | PrintOption.Full;
// Config.I.skipExisting = true;
// config.skipMode = SkipMode.Index;
// config.skipMusicDir = "";
// config.printOption = PrintOption.Tracks | PrintOption.Full;
// config.skipExisting = true;
// string path = Path.Join(Directory.GetCurrentDirectory(), "test_m3u.m3u8");