Advanced Launcher - Add PC Games Automation
#1
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)

#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:
 <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?
Reply
#2
160 views and no responses Sad

the above script works. now the problem is that each game shows up as a "blank tile". I have to right click each one and manually kick off the cover-art search. Is there a way to make kodi (or advanced launcher) automatically do this for items without a cover-image on launch (similar to updating library)?
Reply
#3
@smaka510

The Games section of the forum is usually a fairly quiet place and it does take a few days or more for the games developers to visit and respond.

Hopefully someone will respond soon.
My Signature
Links to : Forum rules (wiki) | Banned_Add-ons (wiki) | Debug Log (wiki)  
Links to : HOW-TO:Create_Music_Library (wiki) | HOW-TO:Create_Video_Library (wiki)  ||  Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
Reply
#4
@smaka510 Advanced Launcher has not been maintained in four years. I recommend you upgrade your setup to Advanced Emulator Launcher or RCB.

If you use Advanced Emulator Launcher, you can create LNK files for each game you want to launch, place those LNK files in a directory and then create a ROM LNK launcher. LNK files can be created quickly using drag and drop. Then, you can then scrape this ROM LNK launcher for artwork.
Reply
#5
I don't have games setup in Kodi but this looks really useful for steam games.  It looks a lot better than hand jamming everything.
Reply
#6
I did quite a bit of digging on the internet and it looks like advanced launcher is still one of the most used game launchers. I was going to chalk this up as a lost cause, but I guess I will post some updates to the script.

I changed/added the following:
- will not prompt selection on games that have one exe (it assumes the one found is correct)
- toggle OFF/ON selection for multiple exe (if off, any folder with multiple exe's will be skipped)
     a. I mapped the "ON" toggle to a separate shortcut, this way I can open Kodi using a shortcut that will prompt me to select the proper exe when multiples are found for a new game
     b. I mapped the "OFF" toggle to a shortcut that will automatically add newly found games and skip any that have multiple exe's (it will not know what one to use)
- skipped games are NOT appended to the "added" list (this way they will be found the next time kodi runs)
Reply
#7
pending post here
Reply
#8
(2019-10-18, 16:56)Wintermute0110 Wrote: @smaka510 Advanced Launcher has not been maintained in four years. I recommend you upgrade your setup to Advanced Emulator Launcher or RCB.

If you use Advanced Emulator Launcher, you can create LNK files for each game you want to launch, place those LNK files in a directory and then create a ROM LNK launcher. LNK files can be created quickly using drag and drop. Then, you can then scrape this ROM LNK launcher for artwork.

Advanced launcher and RCB are most used game launchers. I did not find much info on AEL at all.
if RCB and AEL both use XML, there is no reason this script cannot be modified to work for them as well.

I already have AL setup with quite a bit of games and it works so I'm keeping it.
Reply
#9
(2019-10-30, 00:57)smaka510 Wrote: Advanced launcher and RCB are most used game launchers. I did not find much info on AEL at all.
if RCB and AEL both use XML, there is no reason this script cannot be modified to work for them as well.

I already have AL setup with quite a bit of games and it works so I'm keeping it.

Yes, there are not much information about AEL because most tutorials out there focus on AL. AL has many bugs which were fixed in AEL.

AEL also uses a combination of XML and JSON to store ROMs and the databases are distributed (one per launcher) instead of having a monolithic XML for all launchers. This was done to solve the scalability issues of AL.
Reply
#10
(2019-10-30, 15:59)Wintermute0110 Wrote:
(2019-10-30, 00:57)smaka510 Wrote: Advanced launcher and RCB are most used game launchers. I did not find much info on AEL at all.
if RCB and AEL both use XML, there is no reason this script cannot be modified to work for them as well.

I already have AL setup with quite a bit of games and it works so I'm keeping it.

Yes, there are not much information about AEL because most tutorials out there focus on AL. AL has many bugs which were fixed in AEL.

AEL also uses a combination of XML and JSON to store ROMs and the databases are distributed (one per launcher) instead of having a monolithic XML for all launchers. This was done to solve the scalability issues of AL. 

you would have to have a HUGE library to see any scaling issues with XML. Powershell works well with both XML and JSON. Maybe when I finish up this script, I will make a version that works with AEL.
Reply
#11
The script copies the first PC game it can find, then clears all of the fields out and uses this as a template.
$NewNode = $xml.advanced_launcher.launchers.launcher.CloneNode($true)

The problem with this
- assumes you have an existing PC Games library (you might not)
- assumes you have at least 1 game in the library to copy/clone (you might have the library created without any games added to it)
- if you have more than 1 game the above command will return an array, preventing the command from working

if(more than 1 game){
     #select the first game in the array
     $NewNode = $xml.advanced_launcher.launchers.launcher[0].CloneNode($true)
}else{
     $NewNode = $xml.advanced_launcher.launchers.launcher.CloneNode($true)
}

I think the better way to go is NOT to clone the first game because actually having a game becomes a requirement (not a huge deal tho). Using powershell to create the tree structure from scratch removes this pre-requisite, but I do not know how to do it. Anyone using this script will have to have 1 single game manually added to the PC Games section in order for the script to work as shown.

when I figure this out I will update the script.
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
Advanced Launcher - Add PC Games Automation00