mirror of
https://github.com/fiso64/slsk-batchdl.git
synced 2024-12-22 22:42:41 +00:00
--debug option
This commit is contained in:
parent
8850478aaa
commit
39d2de773e
2 changed files with 27 additions and 7 deletions
|
@ -177,6 +177,7 @@ Options:
|
||||||
'tracks-full': Print extended information about all tracks
|
'tracks-full': Print extended information about all tracks
|
||||||
'results': Print search results satisfying file conditions
|
'results': Print search results satisfying file conditions
|
||||||
'results-full': Print search results including full paths
|
'results-full': Print search results including full paths
|
||||||
|
--debug Print extra debug info
|
||||||
```
|
```
|
||||||
Files not satisfying the conditions will not be downloaded. For example, `--length-tol` is set to 3 by default, meaning that files whose duration differs from the supplied duration by more than 3 seconds will not be downloaded (disable it by setting it to 99999).
|
Files not satisfying the conditions will not be downloaded. For example, `--length-tol` is set to 3 by default, meaning that files whose duration differs from the supplied duration by more than 3 seconds will not be downloaded (disable it by setting it to 99999).
|
||||||
Files satisfying `pref-` conditions will be preferred. For example, setting `--pref-format "flac,wav"` will make it download high quality files if they exist and only download low quality files if there's nothing else.
|
Files satisfying `pref-` conditions will be preferred. For example, setting `--pref-format "flac,wav"` will make it download high quality files if they exist and only download low quality files if there's nothing else.
|
||||||
|
|
|
@ -16,7 +16,6 @@ using Directory = System.IO.Directory;
|
||||||
using SlDictionary = System.Collections.Concurrent.ConcurrentDictionary<string, (Soulseek.SearchResponse, Soulseek.File)>;
|
using SlDictionary = System.Collections.Concurrent.ConcurrentDictionary<string, (Soulseek.SearchResponse, Soulseek.File)>;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static class Program
|
static class Program
|
||||||
{
|
{
|
||||||
static SoulseekClient? client = null;
|
static SoulseekClient? client = null;
|
||||||
|
@ -114,6 +113,7 @@ static class Program
|
||||||
static int maxTracks = int.MaxValue;
|
static int maxTracks = int.MaxValue;
|
||||||
static int minUsersAggregate = 2;
|
static int minUsersAggregate = 2;
|
||||||
static bool relax = false;
|
static bool relax = false;
|
||||||
|
static bool debugInfo = false;
|
||||||
static int offset = 0;
|
static int offset = 0;
|
||||||
|
|
||||||
static string confPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "slsk-batchdl.conf");
|
static string confPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "slsk-batchdl.conf");
|
||||||
|
@ -295,16 +295,17 @@ static class Program
|
||||||
"\n --searches-renew-time <sec> Controls how often available searches are replenished." +
|
"\n --searches-renew-time <sec> Controls how often available searches are replenished." +
|
||||||
"\n Lower values may cause 30-minute bans. (default: 220)" +
|
"\n Lower values may cause 30-minute bans. (default: 220)" +
|
||||||
"\n --display <option> Changes how searches and downloads are displayed:" +
|
"\n --display <option> Changes how searches and downloads are displayed:" +
|
||||||
"\n single (default): Show transfer state and percentage" +
|
"\n 'single' (default): Show transfer state and percentage" +
|
||||||
"\n double: Transfer state and a large progress bar " +
|
"\n 'double': Transfer state and a large progress bar " +
|
||||||
"\n simple: No download bars or changing percentages" +
|
"\n 'simple': No download bars or changing percentages" +
|
||||||
"\n --listen-port <port> Port for incoming connections (default: 50000)" +
|
"\n --listen-port <port> Port for incoming connections (default: 50000)" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"\n --print <option> Print tracks or search results instead of downloading:" +
|
"\n --print <option> Print tracks or search results instead of downloading:" +
|
||||||
"\n 'tracks': Print all tracks to be downloaded" +
|
"\n 'tracks': Print all tracks to be downloaded" +
|
||||||
"\n 'tracks-full': Print extended information about all tracks" +
|
"\n 'tracks-full': Print extended information about all tracks" +
|
||||||
"\n 'results': Print search results satisfying file conditions" +
|
"\n 'results': Print search results satisfying file conditions" +
|
||||||
"\n 'results-full': Print search results including full paths");
|
"\n 'results-full': Print search results including full paths" +
|
||||||
|
"\n --debug Print extra debug info");
|
||||||
}
|
}
|
||||||
|
|
||||||
static async Task Main(string[] args)
|
static async Task Main(string[] args)
|
||||||
|
@ -659,6 +660,9 @@ static class Program
|
||||||
case "--fast-search":
|
case "--fast-search":
|
||||||
fastSearch = true;
|
fastSearch = true;
|
||||||
break;
|
break;
|
||||||
|
case "--debug":
|
||||||
|
debugInfo = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException($"Unknown argument: {args[i]}");
|
throw new ArgumentException($"Unknown argument: {args[i]}");
|
||||||
}
|
}
|
||||||
|
@ -690,6 +694,7 @@ static class Program
|
||||||
|
|
||||||
if (inputType == "youtube" || (inputType == "" && input.StartsWith("http") && input.Contains("youtu")))
|
if (inputType == "youtube" || (inputType == "" && input.StartsWith("http") && input.Contains("youtu")))
|
||||||
{
|
{
|
||||||
|
WriteLine("Youtube download", debugOnly: true);
|
||||||
ytUrl = input;
|
ytUrl = input;
|
||||||
inputType = "youtube";
|
inputType = "youtube";
|
||||||
|
|
||||||
|
@ -723,6 +728,7 @@ static class Program
|
||||||
}
|
}
|
||||||
else if (inputType == "spotify" || (inputType == "" && (input.StartsWith("http") && input.Contains("spotify")) || input == "spotify-likes"))
|
else if (inputType == "spotify" || (inputType == "" && (input.StartsWith("http") && input.Contains("spotify")) || input == "spotify-likes"))
|
||||||
{
|
{
|
||||||
|
WriteLine("Spotify download", debugOnly: true);
|
||||||
spotifyUrl = input;
|
spotifyUrl = input;
|
||||||
inputType = "spotify";
|
inputType = "spotify";
|
||||||
|
|
||||||
|
@ -790,6 +796,7 @@ static class Program
|
||||||
}
|
}
|
||||||
else if (inputType == "csv" || (inputType == "" && Path.GetExtension(input).Equals(".csv", StringComparison.OrdinalIgnoreCase)))
|
else if (inputType == "csv" || (inputType == "" && Path.GetExtension(input).Equals(".csv", StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
|
WriteLine("CSV download", debugOnly: true);
|
||||||
csvPath = input;
|
csvPath = input;
|
||||||
inputType = "csv";
|
inputType = "csv";
|
||||||
|
|
||||||
|
@ -804,6 +811,7 @@ static class Program
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
WriteLine("String download", debugOnly: true);
|
||||||
searchStr = input;
|
searchStr = input;
|
||||||
inputType = "string";
|
inputType = "string";
|
||||||
var music = ParseTrackArg(searchStr);
|
var music = ParseTrackArg(searchStr);
|
||||||
|
@ -875,6 +883,8 @@ static class Program
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WriteLine("Got tracks", debugOnly: true);
|
||||||
|
|
||||||
if (reverse)
|
if (reverse)
|
||||||
{
|
{
|
||||||
tracks.Reverse();
|
tracks.Reverse();
|
||||||
|
@ -999,9 +1009,13 @@ static class Program
|
||||||
if (!client.State.HasFlag(SoulseekClientStates.LoggedIn))
|
if (!client.State.HasFlag(SoulseekClientStates.LoggedIn))
|
||||||
await Login(useRandomLogin);
|
await Login(useRandomLogin);
|
||||||
|
|
||||||
|
WriteLine("Logged in", debugOnly: true);
|
||||||
|
|
||||||
var UpdateTask = Task.Run(() => Update());
|
var UpdateTask = Task.Run(() => Update());
|
||||||
|
WriteLine("Update started", debugOnly: true);
|
||||||
|
|
||||||
await MainLoop();
|
await MainLoop();
|
||||||
|
WriteLine("Mainloop done", debugOnly: true);
|
||||||
|
|
||||||
|
|
||||||
if (album && downloadedFiles.Count > 0)
|
if (album && downloadedFiles.Count > 0)
|
||||||
|
@ -1024,6 +1038,7 @@ static class Program
|
||||||
|
|
||||||
static async Task MainLoop()
|
static async Task MainLoop()
|
||||||
{
|
{
|
||||||
|
WriteLine("Main loop", debugOnly: true);
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
bool albumDlFailed = false;
|
bool albumDlFailed = false;
|
||||||
|
@ -1231,6 +1246,7 @@ static class Program
|
||||||
|
|
||||||
static async Task Login(bool random=false, int tries=3)
|
static async Task Login(bool random=false, int tries=3)
|
||||||
{
|
{
|
||||||
|
WriteLine($"Login {username}", debugOnly: true);
|
||||||
string user = username, pass = password;
|
string user = username, pass = password;
|
||||||
if (random)
|
if (random)
|
||||||
{
|
{
|
||||||
|
@ -2904,7 +2920,7 @@ static class Program
|
||||||
|
|
||||||
static string[] ParseCommand(string cmd)
|
static string[] ParseCommand(string cmd)
|
||||||
{
|
{
|
||||||
Debug.WriteLine(cmd);
|
WriteLine(cmd, debugOnly: true);
|
||||||
string pattern = @"(""[^""]*""|\S+)";
|
string pattern = @"(""[^""]*""|\S+)";
|
||||||
MatchCollection matches = Regex.Matches(cmd, pattern);
|
MatchCollection matches = Regex.Matches(cmd, pattern);
|
||||||
var args = new string[matches.Count];
|
var args = new string[matches.Count];
|
||||||
|
@ -3148,8 +3164,10 @@ static class Program
|
||||||
Console.WriteLine(item);
|
Console.WriteLine(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WriteLine(string value, ConsoleColor color=ConsoleColor.Gray, bool safe = false)
|
public static void WriteLine(string value, ConsoleColor color=ConsoleColor.Gray, bool safe=false, bool debugOnly=false)
|
||||||
{
|
{
|
||||||
|
if (debugOnly && !debugInfo)
|
||||||
|
return;
|
||||||
if (!safe)
|
if (!safe)
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = color;
|
Console.ForegroundColor = color;
|
||||||
|
@ -3212,6 +3230,7 @@ static class Program
|
||||||
|
|
||||||
public static async Task WaitForNetworkAndLogin()
|
public static async Task WaitForNetworkAndLogin()
|
||||||
{
|
{
|
||||||
|
WriteLine("Wait for network and login", debugOnly: true);
|
||||||
await WaitForInternetConnection();
|
await WaitForInternetConnection();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
|
|
Loading…
Reference in a new issue