2019-10-15, 22:35
Hello all,
I have a large collection of PC games and it was a PITA to manually create a "stand-alone" launcher for each one. So I wrote a powershell script that recursively searches my installed games directory for ".exe" files. Using a series of filters I am able to locate the exact ".exe" needed to launch a game. When multiple ".exe" are found for a game I get a list to choose from.
Based on what is found the following is done:
- Uses the foldername as the name of the game
- specifies the full path of the ".exe"
- sets the platform as "IBM-PC"
- randomly generates a uniquie "ID"
- adds game to a list of imported games to prevent duplicates (makes it run faster too)
The above generates the XML for each new stand-alone launcher (named after the folder). This XML is automatically appended to the "Launcher.xml". It looks like this:
I launch Kodi with a batch file to kick off the above script and start Camtasia BEFORE the kodi app opens (some other stuff too). It works brilliantly! Every time I install a new game to F:\Games or G:\Games, a new "stand-alone" launcher is automatically created and added as a blank tile to the PC games section.
My question is this - Is there a way to make Advanced Launcher automatically download cover art without me having to click each icon?
I have a large collection of PC games and it was a PITA to manually create a "stand-alone" launcher for each one. So I wrote a powershell script that recursively searches my installed games directory for ".exe" files. Using a series of filters I am able to locate the exact ".exe" needed to launch a game. When multiple ".exe" are found for a game I get a list to choose from.
Based on what is found the following is done:
- Uses the foldername as the name of the game
- specifies the full path of the ".exe"
- sets the platform as "IBM-PC"
- randomly generates a uniquie "ID"
- adds game to a list of imported games to prevent duplicates (makes it run faster too)
powershell:#Non-Recrusive search all gaming directories seperate by commas
$Folders = Get-ChildItem G:\Games, F:\Games
#Get list of games that have been added already
$CSVPath = "C:\Users\$env:USERNAME\AppData\Roaming\Kodi\userdata\addon_data\plugin.program.advanced.launcher\Imported-Games.csv"
if(Test-Path $CSVPath){
$ImportedGames = Import-Csv $CSVPath
}else{
$ImportedGames = $null
}
#Import xml data from launchers.xml
[xml]$xml = Get-Content 'C:\Users\$env:USERNAME\AppData\Roaming\Kodi\userdata\addon_data\plugin.program.advanced.launcher\launchers.xml'
#Clone the first PC game node to use as a template AND clear the populated fields (except fields that will be re-used)
$NewNode = $xml.advanced_launcher.launchers.launcher.CloneNode($true)
$NewNode.id = (' ').Trim()
$NewNode.name = (' ').Trim()
#$NewNode.category = (' ').Trim()
$NewNode.application = (' ').Trim()
$NewNode.args = (' ').Trim()
#$NewNode.rompath = (' ').Trim()
#$NewNode.thumbpath = (' ').Trim()
#$NewNode.fanartpath = (' ').Trim()
#$NewNode.trailerpath = (' ').Trim()
#$NewNode.custompath = (' ').Trim()
$NewNode.romext = (' ').Trim()
#$NewNode.platform = (' ').Trim()
$NewNode.thumb = (' ').Trim()
$NewNode.fanart = (' ').Trim()
$NewNode.genre = (' ').Trim()
$NewNode.release = (' ').Trim()
$NewNode.publisher = (' ').Trim()
$NewNode.launcherplot = (' ').Trim()
$NewNode.finished = (' ').Trim()
$NewNode.minimize = (' ').Trim()
$NewNode.lnk = (' ').Trim()
$NewNode.roms = (' ').Trim()
#setting the counter
$i = 0;
foreach($folder in $Folders){
#only execute if the game is NOT on the imported games list
if($ImportedGames.games -notcontains $Folder.Name){
$template = $NewNode.CloneNode($true)
#Recursive search in each game folder for EXE files
$Exe = Get-ChildItem $folder.FullName -Recurse -include "*.exe" -Exclude "*unins*","*DXSETUP*","*vcredist*","*dotnet*","*config*","*dxwebsetup*","*vc_redist*","*Cleanup*","*touchup*","*trial*","*benchmark*","*install*","*server*","*splash*","*activation*","*patch*","*Language*","*setup*","*launcher*","*upload*","*shipping*","*QuickSFV*","*kb*","*profile*","*unlocker*","*injector*","*saves*","*reporter*"
if($Exe.count -gt 0){
Write-Host -ForegroundColor Yellow "Select EXE to launch: " $folder
Write-Host ""
foreach($thing in $exe){
$i = $i+1
Write-Host $i - $thing.Name
}
Write-Host ""
#if more than 1 exe is found select the proper exe to use
if($exe.Count -gt 1){
$Answer = Read-Host "Select 1-" $exe.Count
}else{
$Answer = 1
}
Write-Host ""
$Launcher = $Exe[$answer-1].FullName
#Create a random <id>
$RandomID = ("763a9114f6fc84d7bd3340c4bbbf34cd" -split '' | Sort-Object {Get-Random}) -join ''
#Insert $RandomID, $Launcher and $Folder into XML
$template.id = "$RandomID"
$template.name = '"'+$Folder.name+'"'
$template.application = "$Launcher"
#$template.platform = "IBM PC Compatible"
#Append the new laucher to the original XML
$xml.advanced_launcher.launchers.AppendChild($template)
$folder.name | Out-File $CSVPath -Append
$template = $null
$i=0;
}
}
}
$xml.Save("C:\Users\$env:USERNAME\AppData\Roaming\Kodi\userdata\addon_data\plugin.program.advanced.launcher\launchers.xml")
The above generates the XML for each new stand-alone launcher (named after the folder). This XML is automatically appended to the "Launcher.xml". It looks like this:
xml:<launcher>
<id>2e136fd205809d76d43289da860daba4</id>
<name>Batman Arkham Knight</name>
<category>79a40508ebed41d43eaaca1ff68ae172</category>
<application>F:\Games\Batman - Arkham City\Binaries\Win32\BatmanAC.exe</application>
<args />
<rompath />
<thumbpath></thumbpath>
<fanartpath></fanartpath>
<trailerpath />
<custompath />
<romext />
<platform>IBM PC Compatible</platform>
<thumb></thumb>
<fanart />
<genre />
<release />
<publisher />
<launcherplot />
<finished>false</finished>
<minimize>false</minimize>
<lnk>true</lnk>
<roms />
</launcher>
I launch Kodi with a batch file to kick off the above script and start Camtasia BEFORE the kodi app opens (some other stuff too). It works brilliantly! Every time I install a new game to F:\Games or G:\Games, a new "stand-alone" launcher is automatically created and added as a blank tile to the PC games section.
My question is this - Is there a way to make Advanced Launcher automatically download cover art without me having to click each icon?