# RadioTEDU Terminal — Windows PowerShell # Download: https://radiotedu.com/install.ps1 $ErrorActionPreference = 'Stop' $terminalRelease = Invoke-RestMethod -Uri 'https://radiotedu.com/tui/latest.json' -Headers @{'Cache-Control'='no-cache'} $terminalVersion = $terminalRelease.version $terminalPackageUrl = [uri]$terminalRelease.package if ($terminalPackageUrl.Scheme -ne 'https' -or $terminalPackageUrl.Host -ne 'radiotedu.com' -or $terminalPackageUrl.AbsolutePath -notmatch '^/tui/radiotedu-[a-zA-Z0-9.-]+\.tgz$' -or $terminalRelease.sha256 -notmatch '^[a-f0-9]{64}$') { throw 'The release manifest is invalid.' } if (-not (Get-Command node -ErrorAction SilentlyContinue)) { throw 'Node.js is required. Install the current LTS release from https://nodejs.org or use: winget install OpenJS.NodeJS.LTS' } $terminalNodeMajor = [int]((& node --version).TrimStart('v').Split('.')[0]) if ($terminalNodeMajor -lt 18) { throw 'RadioTEDU requires Node.js 18 or newer. Please install the current LTS release.' } $terminalNpm = Get-Command npm.cmd -ErrorAction SilentlyContinue if (-not $terminalNpm) { $terminalNpm = Get-Command npm -ErrorAction SilentlyContinue } if (-not $terminalNpm) { throw 'npm was not found. Reinstall Node.js with npm, then open a new terminal.' } Write-Host "Installing RadioTEDU Terminal $terminalVersion..." $terminalDownload = Join-Path ([IO.Path]::GetTempPath()) ('radiotedu-' + [guid]::NewGuid().ToString('N') + '.tgz') Invoke-WebRequest -Uri $terminalPackageUrl -OutFile $terminalDownload -UseBasicParsing if ((Get-FileHash -LiteralPath $terminalDownload -Algorithm SHA256).Hash.ToLowerInvariant() -ne $terminalRelease.sha256) { Remove-Item -LiteralPath $terminalDownload; throw 'Package checksum mismatch. Installation stopped.' } $terminalArgs = @('install', '--global', '--ignore-scripts', $terminalDownload) $terminalGlobalRoot = (& $terminalNpm.Source root --global | Select-Object -Last 1) if ($LASTEXITCODE -ne 0) { throw 'Could not determine the npm global package directory.' } $terminalOtherName = if ($terminalRelease.name -eq 'radiotedu-tui') { 'radiotedu' } else { 'radiotedu-tui' } $terminalLegacy = Join-Path $terminalGlobalRoot ($terminalOtherName + '\package.json') if (Test-Path -LiteralPath $terminalLegacy) { $terminalLegacyPackage = Get-Content -LiteralPath $terminalLegacy -Raw | ConvertFrom-Json if ($terminalLegacyPackage.name -eq $terminalOtherName) { # Both official package names own these two launch commands. Keep user data intact. $terminalArgs += '--force' Write-Host 'Updating the existing RadioTEDU command aliases. Saved account settings are preserved.' } } try { & $terminalNpm.Source @terminalArgs if ($LASTEXITCODE -ne 0) { throw 'Installation failed. Account settings have not been deleted.' } } finally { if (Test-Path -LiteralPath $terminalDownload) { Remove-Item -LiteralPath $terminalDownload } } $terminalPrefix = (& $terminalNpm.Source prefix --global | Select-Object -Last 1) $terminalCommand = Join-Path $terminalPrefix 'radiotedu.cmd' if (-not (Test-Path -LiteralPath $terminalCommand)) { throw 'The package was installed, but its Windows launch command is missing.' } & $terminalCommand --version if ($LASTEXITCODE -ne 0) { throw 'The installed command did not pass its version check.' } if (-not (Get-Command radiotedu -ErrorAction SilentlyContinue)) { $terminalUserPath = [string][Environment]::GetEnvironmentVariable('Path', 'User') if ($terminalPrefix -notin ($terminalUserPath -split ';')) { [Environment]::SetEnvironmentVariable('Path', (($terminalUserPath.TrimEnd(';') + ';' + $terminalPrefix).TrimStart(';')), 'User') } $env:Path = $env:Path + ';' + $terminalPrefix } Write-Host 'Ready. Type radiotedu in CMD or PowerShell to open the player.' -ForegroundColor Green Write-Host 'If an older terminal does not find it, open a new terminal window.' if (-not (Get-Command mpv -ErrorAction SilentlyContinue) -and -not (Get-Command ffplay -ErrorAction SilentlyContinue)) { Write-Host 'Audio needs mpv or ffplay. The application can offer a player download; you can also install an audio engine yourself.' } Write-Host 'Optional account pairing: radiotedu login'