diff --git a/res/login.spa b/res/login.spa new file mode 100644 index 00000000..ac2f99a3 Binary files /dev/null and b/res/login.spa differ diff --git a/run.ps1 b/run.ps1 index 14c01d36..ebbc224b 100644 --- a/run.ps1 +++ b/run.ps1 @@ -388,31 +388,42 @@ $online = ($onlineFull -split ".g")[0] function Get { param ( + [Parameter(Mandatory = $true)] [string]$Url, [int]$MaxRetries = 3, - [int]$RetrySeconds = 3 + [int]$RetrySeconds = 3, + [string]$OutputPath ) - $retries = 0 + $params = @{ + Uri = $Url + TimeoutSec = 15 + } + + if ($OutputPath) { + $params['OutFile'] = $OutputPath + } - while ($retries -lt $MaxRetries) { + for ($i = 0; $i -lt $MaxRetries; $i++) { try { - return Invoke-RestMethod -Uri $Url + $response = Invoke-RestMethod @params + return $response } catch { - Write-Warning "Request failed: $_" - $retries++ - Start-Sleep -Seconds $RetrySeconds + Write-Warning "Attempt $($i+1) of $MaxRetries failed: $_" + if ($i -lt $MaxRetries - 1) { + Start-Sleep -Seconds $RetrySeconds + } } } + Write-Host Write-Host "ERROR: " -ForegroundColor Red -NoNewline; Write-Host "Failed to retrieve data from $Url" -ForegroundColor White - Write-Host - + Write-Host return $null - } + function incorrectValue { Write-Host ($lang).Incorrect"" -ForegroundColor Red -NoNewline @@ -1807,6 +1818,12 @@ if ($rexex1 -and $rexex2 -and $rexex3) { # Binary patch extract -counts 'exe' -helper 'Binary' +# fix login for old versions +if ([version]$offline -ge [version]"1.1.87.612" -and [version]$offline -le [version]"1.2.5.1006") { + $login_spa = Join-Path (Join-Path $env:APPDATA 'Spotify\Apps') 'login.spa' + Get -Url (Get-Link -e "/res/login.spa") -OutputPath $login_spa +} + # Start Spotify if ($start_spoti) { Start-Process -WorkingDirectory $spotifyDirectory -FilePath $spotifyExecutable }