You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$OptionResult=$LineSplit[1].Split("#")[0].Trim() # The extra functions remove the comments found in the conf file by default
95
+
Set-Variable$OptionName$OptionResult-Scope Global
96
+
if ($OptionName-eq"ApiKey"-and$OptionResult-eq"put-api-key-here")
97
+
{
98
+
Write-Color"ERROR! ","The ","default value ","for the API key is still in the config file! Please change it to your own." Red,$DefaultTextColor,Yellow,$DefaultTextColor
99
+
Exit-WithMessageAndPause
100
+
return
101
+
}
102
+
if ($OptionName-eq"DownloadLocation")
103
+
{
104
+
if (!(Test-Path$Global:DownloadLocation))
105
+
{
106
+
Write-Color"ERROR! ","The download location ",$Global:DownloadLocation," is invalid! Please provide a path to an existing folder, or make the folder at the path provided." Red,$DefaultTextColor,Yellow,$DefaultTextColor
107
+
Exit-WithMessageAndPause
108
+
return
109
+
}
110
+
}
111
+
if ($IsDotSourced)
112
+
{
113
+
Write-Host"The config option ""$OptionName"" is ""$OptionResult"""
Write-Color"Searching mod.io for the mod ID (","Attempt $CurrentAttemptNum",")"$DefaultTextColor,Yellow,$DefaultTextColor
271
+
$ModIoGameData= (Invoke-RestMethod-Method Get -Uri "https://api.mod.io/v1/games/$GameId/mods?api_key=$ApiKey&_offset=$ResultsOffset&_q=$ModNameId").data
272
+
273
+
foreach ($SetOfDatain$ModIoGameData)
274
+
{
275
+
if ($SetOfData.profile_url-eq$Url)
276
+
{
277
+
return$SetOfData.id
278
+
}
279
+
}
280
+
$Global:SearchAttemptsUsed+=1
281
+
if ($Global:SearchAttemptsUsed-eq$Global:ModSearchAttempts)
282
+
{
283
+
Write-Color"Could not get the ","mod ID ","from the URL ",$Url," in ",$Global:ModSearchAttempts," attempts!"$DefaultTextColor,Green,$DefaultTextColor,Yellow,$DefaultTextColor,Yellow,$DefaultTextColor
284
+
Write-Color"Continue searching for another ",$Global:ModSearchAttempts," attempts?"$DefaultTextColor,Green,$DefaultTextColor
285
+
switch (Start-YesOrNoPrompt-Question ''-YesDescription "Continue searching for 10 more attempts."-NoDescription "Do not continue searching, and exit the script.")
$ModData= (Invoke-RestMethod-Method Get -Uri "https://api.mod.io/v1/games/$GameId/mods/$ModId`?api_key=$ApiKey")
314
+
$DownloadUrl=$ModData.modfile.download.binary_url
315
+
$DownloadFileName=$ModData.modfile.filename
316
+
if (Test-Path"$Global:DownloadLocation\$DownloadFileName")
317
+
{
318
+
Write-Color"WARNING! ","The file ",$DownloadFileName," has already been downloaded!" Yellow,$DefaultTextColor,Green,$DefaultTextColor
319
+
switch (Start-YesOrNoPrompt-Question 'Do you want to replace the file?'-YesDescription 'The file will be removed before being downloaded.'-NoDescription 'The script will skip this file.')
0 commit comments