Готова функция скачивания модов

This commit is contained in:
2025-08-11 23:46:48 +07:00
parent a2d3d7625d
commit 5b29ebfb5d
5 changed files with 81 additions and 36 deletions

36
download_mods.ps1 Normal file
View File

@@ -0,0 +1,36 @@
$fileId = "13im-l6X2j-s5scZZlBvt2DCjYBbk2qI8"
$baseUrl = "https://drive.google.com/uc?export=download&id=$fileId"
$outputFile = "$env:TEMP\ruinship_mods.rar"
$response = Invoke-WebRequest -Uri $baseUrl -SessionVariable session
$form = $response.Forms | Where-Object { $_.Id -eq "download-form" }
if ($form) {
$queryParams = @{}
foreach ($field in $form.Fields.GetEnumerator()) {
$queryParams[$field.Key] = $field.Value
}
$uriBuilder = New-Object System.UriBuilder $form.Action
$queryString = ($queryParams.GetEnumerator() | ForEach-Object { "$($_.Key)=$($_.Value)" }) -join "&"
$uriBuilder.Query = $queryString
$downloadUrl = $uriBuilder.Uri.AbsoluteUri
Write-Host "[INFO] Downloading..."
Invoke-WebRequest -Uri $downloadUrl -WebSession $session -OutFile $outputFile
Write-Host "[INFO] The file was successfully downloaded with confirmation."
}
else {
Write-Host "[INFO] Downloading..."
Invoke-WebRequest -Uri $baseUrl -OutFile $outputFile
Write-Host "[INFO] The file was successfully downloaded directly."
}
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
$rimworldMods = Resolve-Path (Join-Path $scriptDir "..")
$sourceFolder = Get-ChildItem $outputFile | Select-Object -First 1
Move-Item -Path $sourceFolder.FullName -Destination $rimworldMods
Write-Host "[INFO] The ruinship_mods.rar file has been installed to the path $rimworldMods. Please extract it to install all the necessary mods." -ForegroundColor Green