Skip to content

Instantly share code, notes, and snippets.

@a-sync
Created November 26, 2021 09:06
Show Gist options
  • Save a-sync/ff97e5580d766cdf0c935b4c6fc1fb7f to your computer and use it in GitHub Desktop.
Save a-sync/ff97e5580d766cdf0c935b4c6fc1fb7f to your computer and use it in GitHub Desktop.
OFCRA local mod downloader / updater: parses Arma 3 launcher preset files in the current folder and attempts to download and unpack non workshop mods from the OFCRA mod repository.
@echo off
rem # OFCRA local mod downloader / updater
rem # Parses Arma 3 launcher preset files in the current folder and attempts
rem # to download and unpack non workshop mods from the OFCRA mod repository.
rem # https://ofcrav2.org/index.php?page=repository-en
rem #
rem # Usage:
rem # 1. Create a folder for your local mods and place this script and the
rem # Arma 3 launcher preset file in there
rem # 2. Run the script and let it download and unpack the non workshop mods
rem # 3. Open the Arma 3 launcher and load each unpacked folder as `Local mod`
rem # 4. Import the preset file in the Arma 3 launcher
powershell.exe -ExecutionPolicy Bypass -NoLogo -Noninteractive -NoProfile -Command "$ProgressPreference='SilentlyContinue';$mods='|';Get-ChildItem '*.html'|Foreach-Object{Write-Host 'Parsing'$_.name -ForegroundColor Red;ForEach($i in Get-Content -Path $_.name -Delimiter ' data-meta=""local:'|Select-Object -Skip 1){if($i -match '^(.+)\|(.+)\|.*' -and $mods -notlike '*|'+$matches[2]+'|*'){$mods+=$matches[2]+'|';$f=$matches[2]+'.zip';$p=$pwd,$f -Join '\';Write-Host ' Downloading'$f;(New-Object Net.WebClient).DownloadFile('https://www.ofcrav2.org/mods/'+$f,$p);Write-Host ' Extracting'$f;Expand-Archive -LiteralPath $p -DestinationPath $pwd -Force;Remove-Item $p;}else{Write-Host ' Skipping'$matches[2];}}}"
pause
# OFCRA local mod downloader / updater
# Parses Arma 3 launcher preset files in the current folder and attempts
# to download and unpack non workshop mods from the OFCRA mod repository.
# https://ofcrav2.org/index.php?page=repository-en
#
# Usage:
# 1. Create a folder for your local mods and place this script and the
# Arma 3 launcher preset file in there
# 2. Run the script and let it download and unpack the non workshop mods
# 3. Open the Arma 3 launcher and load each unpacked folder as `Local mod`
# 4. Import the preset file in the Arma 3 launcher
$ProgressPreference = 'SilentlyContinue';
$mods = '|';
Get-ChildItem '*.html' |
Foreach-Object {
Write-Host 'Parsing'$_.name -ForegroundColor Red;
ForEach ($i in Get-Content -Path $_.name -Delimiter ' data-meta="local:' | Select-Object -Skip 1) {
if ($i -match '^(.+)\|(.+)\|.*' -and $mods -notlike '*|' + $matches[2] + '|*') {
$mods += $matches[2] + '|';
$f = $matches[2] + '.zip';
$p = $pwd,$f -Join '\';
Write-Host ' Downloading'$f;
(New-Object Net.WebClient).DownloadFile('https://www.ofcrav2.org/mods/' + $f, $p);
Write-Host ' Extracting'$f;
Expand-Archive -LiteralPath $p -DestinationPath $pwd -Force;
Remove-Item $p;
} else {
Write-Host ' Skipping'$matches[2];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment