vibecoded ability to select local .zip

This commit is contained in:
2026-05-20 17:27:04 +02:00
parent 73505d3087
commit 38f5a8285c
+83 -13
View File
@@ -1,8 +1,54 @@
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
$apiUrl = 'https://api.github.com/repos/LukeYui/EldenRingSeamlessCoopRelease/releases/latest' $apiUrl = 'https://api.github.com/repos/LukeYui/EldenRingSeamlessCoopRelease/releases/latest'
$scDownloadUrl = $null
$localPath = $null
$input = Read-Host "Do you want to use the official Github-Repository [d] to download the mod or use an already downloaded .zip? [l] [D/l]"
if ($input -match '^(l|local)$') {
Write-Host "Searching Downloads folder..."
$downloads = Join-Path $HOME 'Downloads'
$localPath = Get-ChildItem -Path $downloads -Filter 'Seamless*.zip' -File -ErrorAction SilentlyContinue |
Select-Object -First 1 -ExpandProperty FullName
if ($localPath -and (Test-Path $localPath)) {
Write-Host "File found at $localPath"
}
else {
Write-Host "File not found in $downloads"
$input = Read-Host "Please specify the path to your local .zip archive"
if ([string]::IsNullOrWhiteSpace($input) -or $input -eq 'null') {
throw "Empty path provided"
}
elseif (Test-Path $input -PathType Leaf) {
$localPath = $input
Write-Host "File found at $localPath"
}
elseif (Test-Path $input -PathType Container) {
$localPath = Get-ChildItem -Path $input -Filter 'Seamless*.zip' -File -Recurse -ErrorAction SilentlyContinue |
Select-Object -First 1 -ExpandProperty FullName
if ($localPath) {
Write-Host "File found at $localPath"
}
else {
throw "File not found at $input"
}
}
else {
throw "Invalid path provided"
}
}
}
else {
$release = Invoke-RestMethod -Uri $apiUrl -Headers @{ 'User-Agent' = 'PowerShell' } $release = Invoke-RestMethod -Uri $apiUrl -Headers @{ 'User-Agent' = 'PowerShell' }
$scDownloadUrl = $release.assets[0].browser_download_url $scDownloadUrl = $release.assets[0].browser_download_url
}
function Get-EldenRingGameDir { function Get-EldenRingGameDir {
$steamPaths = @( $steamPaths = @(
@@ -12,44 +58,64 @@ function Get-EldenRingGameDir {
) )
foreach ($path in $steamPaths) { foreach ($path in $steamPaths) {
if (Test-Path (Join-Path $path 'eldenring.exe')) { return $path } if (Test-Path (Join-Path $path 'eldenring.exe')) {
$input = Read-Host "Is this your Elden Ring Game folder? $path [Y/n]"
if ($input -notmatch '^(n|no)$') {
return $path
}
}
} }
$drives = Get-PSDrive -PSProvider FileSystem | Select-Object -ExpandProperty Root $drives = Get-PSDrive -PSProvider FileSystem | Select-Object -ExpandProperty Root
foreach ($drive in $drives) { foreach ($drive in $drives) {
Write-Host "Searching at $drive"
$hit = Get-ChildItem -Path $drive -Filter 'eldenring.exe' -Recurse -File -ErrorAction SilentlyContinue | $hit = Get-ChildItem -Path $drive -Filter 'eldenring.exe' -Recurse -File -ErrorAction SilentlyContinue |
Where-Object { $_.FullName -match '\\Elden Ring\\Game\\eldenring\.exe$' } | Where-Object { $_.FullName -match '\\Elden Ring\\Game\\eldenring\.exe$' } |
Select-Object -First 1 Select-Object -First 1
if ($hit) { return $hit.DirectoryName }
if ($hit) {
$input = Read-Host "Is this your Elden Ring Game folder? $($hit.DirectoryName) [Y/n]"
if ($input -notmatch '^(n|no)$') {
return $hit.DirectoryName
}
}
} }
return $null return $null
} }
Write-Host "Searching for Elden Ring game folder"
$eldenringDir = Get-EldenRingGameDir $eldenringDir = Get-EldenRingGameDir
if (-not $eldenringDir) { if (-not $eldenringDir) {
$eldenringDir = Read-Host "Could not auto-detect your Elden Ring Game folder. Enter the full Game folder path" $eldenringDir = Read-Host "Please provide your Elden Ring Directory Path"
if (-not (Test-Path (Join-Path $eldenringDir 'eldenring.exe'))) { if (-not (Test-Path (Join-Path $eldenringDir 'eldenring.exe'))) {
throw "Incorrect Elden Ring directory. 'eldenring.exe' not found at provided path." throw "Incorrect Elden Ring directory. 'eldenring.exe' not found at provided path."
} }
} else {
$input = Read-Host "Is this your Elden Ring Game folder? $eldenringDir [Y/n]" Write-Host "Correct Elden Ring directory"
if ($input -match '^(n|no)$') {
$eldenringDir = Read-Host "Please provide your Elden Ring Game folder path"
if (-not (Test-Path (Join-Path $eldenringDir 'eldenring.exe'))) {
throw "Incorrect Elden Ring directory. 'eldenring.exe' not found at provided path."
}
}
} }
$tempDir = Join-Path $PWD 'ersc-download' $tempDir = Join-Path $PWD 'ersc-download'
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
$zipPath = Join-Path $tempDir 'ersc.zip'
if (-not $scDownloadUrl -and $localPath) {
Write-Host "Copying .zip"
Copy-Item $localPath $zipPath -Force
}
else {
Write-Host "Downloading Seamless Coop" Write-Host "Downloading Seamless Coop"
Write-Host "Download URL: $scDownloadUrl" Write-Host "Download URL: $scDownloadUrl"
$zipPath = Join-Path $tempDir 'ersc.zip'
Invoke-WebRequest -Uri $scDownloadUrl -OutFile $zipPath Invoke-WebRequest -Uri $scDownloadUrl -OutFile $zipPath
}
Write-Host "Extracting downloaded files" Write-Host "Extracting downloaded files"
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
@@ -59,9 +125,13 @@ $launcherPath = Join-Path $eldenringDir 'ersc_launcher.exe'
if (Test-Path $launcherPath) { if (Test-Path $launcherPath) {
$input = Read-Host "Override existing Seamless Coop settings? This resets your Seamless Coop settings, including multiplayer password [Y/n]" $input = Read-Host "Override existing Seamless Coop settings? This resets your Seamless Coop settings, including multiplayer password [Y/n]"
if ($input -match '^(n|no)$') { if ($input -match '^(n|no)$') {
$settings = Join-Path $seamlessDir 'ersc_settings.ini' $settings = Join-Path $seamlessDir 'ersc_settings.ini'
if (Test-Path $settings) { Remove-Item $settings -Force }
if (Test-Path $settings) {
Remove-Item $settings -Force
}
} }
} }