login fix for older versions

#630
This commit is contained in:
amd64fox
2024-09-17 20:06:08 +03:00
parent b7dc969bfc
commit 5908ad228b
2 changed files with 27 additions and 10 deletions

BIN
res/login.spa Normal file

Binary file not shown.

33
run.ps1
View File

@@ -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
}
while ($retries -lt $MaxRetries) {
if ($OutputPath) {
$params['OutFile'] = $OutputPath
}
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++
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
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 }