Fixed bugs on API key pool
This commit is contained in:
@@ -1773,6 +1773,28 @@ namespace URLNotesGrabberCORE
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public static bool IsAllRateLimited(out int minRetrySeconds)
|
||||
{
|
||||
minRetrySeconds = 0;
|
||||
if (!_usePool || _overrideKey != null) return false;
|
||||
if (_keys.Count <= 1) return true;
|
||||
|
||||
var now = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
||||
bool all = true;
|
||||
int min = int.MaxValue;
|
||||
|
||||
foreach (var key in _keys)
|
||||
{
|
||||
var retryUntil = GetRetryUntil(key);
|
||||
if (retryUntil <= now) { all = false; break; }
|
||||
int remaining = (int)(retryUntil - now);
|
||||
if (remaining < min) min = remaining;
|
||||
}
|
||||
|
||||
minRetrySeconds = all ? min : 0;
|
||||
return all;
|
||||
}
|
||||
|
||||
private static void SaveState()
|
||||
{
|
||||
using var conn = new System.Data.SQLite.SQLiteConnection("Data Source=" + _dbPath);
|
||||
|
||||
Reference in New Issue
Block a user