# Install or update the SBC Spotify upload helper, a browser extension for Chrome or Edge. # Run in PowerShell (no admin needed): # # irm https://www.spekebaptistchurch.org.uk/tools/spotify-upload-helper/install.ps1 | iex # # It downloads the helper from the church website, checks the download against the checksum the # website publishes, and puts it in a folder of its own. Chrome and Edge only let you add an # extension that isn't from their store by hand, so the first time you finish with "Load # unpacked"; after that, running this again updates the folder in place. $ErrorActionPreference = 'Stop' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # Windows PowerShell 5.1 $site = 'https://www.spekebaptistchurch.org.uk/' $folder = Join-Path $env:LOCALAPPDATA 'SBC\spotify-upload-helper' Write-Host 'Checking the latest version on the church website...' $info = (Invoke-RestMethod ($site + 'podcast-upload.json')).helper if (-not $info.zip) { throw 'The website has no download for the helper at the moment. Try again later.' } $zip = Join-Path ([IO.Path]::GetTempPath()) 'spotify-upload-helper.zip' Invoke-WebRequest ($site.TrimEnd('/') + $info.zip) -OutFile $zip -UseBasicParsing $hash = (Get-FileHash $zip -Algorithm SHA256).Hash.ToLower() if ($hash -ne $info.sha256) { Remove-Item $zip throw "The download doesn't match the checksum the website published, so it was not installed. Try again later." } $firstTime = -not (Test-Path (Join-Path $folder 'manifest.json')) if (Test-Path $folder) { Get-ChildItem $folder -Force | Remove-Item -Recurse -Force } # clear old files New-Item -ItemType Directory -Force $folder | Out-Null Expand-Archive $zip -DestinationPath $folder -Force Remove-Item $zip $copied = '' try { Set-Clipboard $folder; $copied = ' (the folder path is copied)' } catch { } Write-Host '' Write-Host "Installed version $($info.version) in $folder$copied." -ForegroundColor Green Write-Host '' if ($firstTime) { Write-Host 'To finish, in Chrome or Edge:' Write-Host ' 1. Go to chrome://extensions (in Edge: edge://extensions).' Write-Host ' 2. Turn on "Developer mode".' Write-Host " 3. Click `"Load unpacked`" and choose $folder (press Ctrl+V to paste the path)." Write-Host ' 4. Click the Extensions button (the puzzle piece) and pin "SBC Spotify upload helper".' } else { Write-Host 'To finish, go to chrome://extensions (or edge://extensions) and click the reload arrow on' Write-Host '"SBC Spotify upload helper", or restart the browser.' }