# Installs scene-finder on Windows: downloads the binary from the latest GitHub # release and adds it to your PATH. # # irm https://raw.githubusercontent.com/robinroy03/scene-finder/main/install.ps1 | iex # # Settings (environment variables): # SCENE_FINDER_VERSION release to install, e.g. v0.1.0 (default: latest) # SCENE_FINDER_INSTALL_DIR where to put the binary # (default: %LOCALAPPDATA%\Programs\scene-finder) $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' # the progress bar makes downloads very slow [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $repo = 'robinroy03/scene-finder' $asset = 'scene-finder-windows-amd64.exe' $version = $env:SCENE_FINDER_VERSION if (-not $version) { $version = 'latest' } if ($version -eq 'latest') { $base = "https://github.com/$repo/releases/latest/download" } else { $base = "https://github.com/$repo/releases/download/$version" } $dir = $env:SCENE_FINDER_INSTALL_DIR if (-not $dir) { $dir = Join-Path $env:LOCALAPPDATA 'Programs\scene-finder' } $tmp = Join-Path ([IO.Path]::GetTempPath()) ('scene-finder-' + [Guid]::NewGuid()) New-Item -ItemType Directory -Path $tmp | Out-Null try { Write-Host "Downloading $asset ($version)..." $exe = Join-Path $tmp $asset Invoke-WebRequest -Uri "$base/$asset" -OutFile $exe -UseBasicParsing # Check the download against the release's checksum list. $sums = Join-Path $tmp 'checksums.txt' Invoke-WebRequest -Uri "$base/checksums.txt" -OutFile $sums -UseBasicParsing $line = Get-Content $sums | Where-Object { $_ -match "\s$([regex]::Escape($asset))$" } | Select-Object -First 1 if ($line) { $want = ($line -split '\s+')[0] $got = (Get-FileHash -Algorithm SHA256 $exe).Hash if ($want -ne $got) { throw "checksum mismatch for $asset, not installing" } } New-Item -ItemType Directory -Force -Path $dir | Out-Null Move-Item -Force $exe (Join-Path $dir 'scene-finder.exe') Write-Host "Installed $dir\scene-finder.exe" } finally { Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue } # Add the folder to the user's PATH if it is not there yet. $userPath = [Environment]::GetEnvironmentVariable('Path', 'User') if (-not $userPath) { $userPath = '' } if (($userPath -split ';') -notcontains $dir) { [Environment]::SetEnvironmentVariable('Path', ($userPath.TrimEnd(';') + ';' + $dir).TrimStart(';'), 'User') $env:Path = "$env:Path;$dir" Write-Host "Added $dir to your PATH. Open a new terminal, then run: scene-finder help" } else { Write-Host 'Run: scene-finder help' }