mirror of
https://github.com/fiso64/slsk-batchdl.git
synced 2024-12-22 14:32:40 +00:00
--no-wait-for-internet
This commit is contained in:
parent
a017b82f40
commit
e830f3f891
1 changed files with 22 additions and 11 deletions
|
@ -137,6 +137,7 @@ static class Program
|
||||||
static bool printResultsFull = false;
|
static bool printResultsFull = false;
|
||||||
static bool debugPrintTracksFull = false;
|
static bool debugPrintTracksFull = false;
|
||||||
static bool useRandomLogin = false;
|
static bool useRandomLogin = false;
|
||||||
|
static bool noWaitForInternet = false;
|
||||||
|
|
||||||
static int searchesPerTime = 34;
|
static int searchesPerTime = 34;
|
||||||
static int searchResetTime = 220;
|
static int searchResetTime = 220;
|
||||||
|
@ -164,7 +165,7 @@ static class Program
|
||||||
// undocumented options:
|
// undocumented options:
|
||||||
// --artist-col, --title-col, --album-col, --length-col, --yt-desc-col, --yt-id-col
|
// --artist-col, --title-col, --album-col, --length-col, --yt-desc-col, --yt-id-col
|
||||||
// --remove-brackets, --spotify, --csv, --string, --youtube, --random-login
|
// --remove-brackets, --spotify, --csv, --string, --youtube, --random-login
|
||||||
// --danger-words, --pref-danger-words, --no-modify-share-count
|
// --danger-words, --pref-danger-words, --no-modify-share-count, --no-wait-for-internet
|
||||||
Console.WriteLine("Usage: slsk-batchdl <input> [OPTIONS]" +
|
Console.WriteLine("Usage: slsk-batchdl <input> [OPTIONS]" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"\n <input> <input> is one of the following:" +
|
"\n <input> <input> is one of the following:" +
|
||||||
|
@ -316,7 +317,7 @@ static class Program
|
||||||
#if WINDOWS
|
#if WINDOWS
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (Console.BufferHeight <= 50)
|
if (Console.BufferHeight <= 50 && displayStyle != "simple")
|
||||||
WriteLine("Windows: Recommended to use the command prompt instead of terminal app to avoid printing issues.");
|
WriteLine("Windows: Recommended to use the command prompt instead of terminal app to avoid printing issues.");
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
@ -663,6 +664,9 @@ static class Program
|
||||||
case "--debug":
|
case "--debug":
|
||||||
debugInfo = true;
|
debugInfo = true;
|
||||||
break;
|
break;
|
||||||
|
case "--no-wait-for-internet":
|
||||||
|
noWaitForInternet = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException($"Unknown argument: {args[i]}");
|
throw new ArgumentException($"Unknown argument: {args[i]}");
|
||||||
}
|
}
|
||||||
|
@ -1009,8 +1013,6 @@ 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);
|
WriteLine("Update started", debugOnly: true);
|
||||||
|
|
||||||
|
@ -1246,7 +1248,6 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -1255,22 +1256,29 @@ static class Program
|
||||||
user = new string(Enumerable.Repeat(chars, 10).Select(s => s[r.Next(s.Length)]).ToArray());
|
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());
|
pass = new string(Enumerable.Repeat(chars, 10).Select(s => s[r.Next(s.Length)]).ToArray());
|
||||||
}
|
}
|
||||||
|
WriteLine($"Login {user}", debugOnly: true);
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await WaitForInternetConnection();
|
await WaitForInternetConnection();
|
||||||
|
WriteLine($"Connecting {user}", debugOnly: true);
|
||||||
await client.ConnectAsync(user, pass);
|
await client.ConnectAsync(user, pass);
|
||||||
if (!noModifyShareCount)
|
if (!noModifyShareCount) {
|
||||||
|
WriteLine($"Setting share count", debugOnly: true);
|
||||||
await client.SetSharedCountsAsync(10, 50);
|
await client.SetSharedCountsAsync(10, 50);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch {
|
catch (Exception e) {
|
||||||
if (--tries == 0)
|
WriteLine($"Exception while logging in: {e}", debugOnly: true);
|
||||||
throw;
|
if (--tries == 0) throw;
|
||||||
}
|
}
|
||||||
|
WriteLine($"Retry login {user}", debugOnly: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WriteLine($"Logged in {user}", debugOnly: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2144,7 +2152,7 @@ static class Program
|
||||||
try { await Login(useRandomLogin); }
|
try { await Login(useRandomLogin); }
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
string banMsg = useRandomLogin ? "" : " (likely a 30-minute ban caused by frequent searches)";
|
string banMsg = useRandomLogin ? "" : " (possibly a 30-minute ban caused by frequent searches)";
|
||||||
WriteLine($"{ex.Message}{banMsg}", ConsoleColor.DarkYellow, true);
|
WriteLine($"{ex.Message}{banMsg}", ConsoleColor.DarkYellow, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3209,8 +3217,11 @@ static class Program
|
||||||
|
|
||||||
public static async Task WaitForInternetConnection()
|
public static async Task WaitForInternetConnection()
|
||||||
{
|
{
|
||||||
|
if (noWaitForInternet)
|
||||||
|
return;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
WriteLine("Wait for internet", debugOnly: true);
|
||||||
if (NetworkInterface.GetIsNetworkAvailable())
|
if (NetworkInterface.GetIsNetworkAvailable())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -3230,11 +3241,11 @@ 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)
|
||||||
{
|
{
|
||||||
|
WriteLine("Wait for login", debugOnly: true);
|
||||||
if (client.State.HasFlag(SoulseekClientStates.LoggedIn))
|
if (client.State.HasFlag(SoulseekClientStates.LoggedIn))
|
||||||
break;
|
break;
|
||||||
await Task.Delay(500);
|
await Task.Delay(500);
|
||||||
|
|
Loading…
Reference in a new issue