Skip to content

Instantly share code, notes, and snippets.

@dinhani
Last active October 17, 2024 19:27
Show Gist options
  • Save dinhani/7a30004d92af839957fac8cfc0b44abe to your computer and use it in GitHub Desktop.
Save dinhani/7a30004d92af839957fac8cfc0b44abe to your computer and use it in GitHub Desktop.
LaunchBox to Retroarch playlists
$PLATFORMS = @{
"3DO Interactive Multiplayer" = "The 3DO Company - 3DO"
"Arcade" = "MAME"
"Atari 2600" = "Atari - 2600"
"Atari 5200" = "Atari - 5200"
"Atari 7800" = "Atari - 7800"
"Atari Lynx" = "Atari - Lynx"
"Atari Jaguar" = "Atari - Jaguar"
"Atari ST" = "Atari - ST"
"Commodore 64" = "Commodore - 64"
"Commodore Amiga" = "Commodore - Amiga"
"ColecoVision" = "Coleco - ColecoVision"
"GCE Vectrex" = "GCE - Vectrex"
"Nintendo 3DS" = "Nintendo - Nintendo 3DS"
"Nintendo 64" = "Nintendo - Nintendo 64"
"Nintendo 64DD" = "Nintendo - Nintendo 64DD"
"Nintendo DS" = "Nintendo - Nintendo DS"
"Nintendo Entertainment System" = "Nintendo - Nintendo Entertainment System"
"Nintendo Famicom Disk System" = "Nintendo - Family Computer Disk System"
"Nintendo Game Boy Advance" = "Nintendo - Game Boy Advance"
"Nintendo Game Boy Color" = "Nintendo - Game Boy Color"
"Nintendo Game Boy" = "Nintendo - Game Boy"
"Nintendo GameCube" = "Nintendo - GameCube"
"Nintendo Virtual Boy" = "Nintendo - Virtual Boy"
"Nintendo Wii U" = "Nintendo - Wii U"
"Nintendo Wii" = "Nintendo - Wii"
"Super Nintendo Entertainment System" = "Nintendo - Super Nintendo Entertainment System"
"Mattel Intellivision" = "Mattel - Intellivision"
"Magnavox - Odyssey 2" = "Magnavox - Odyssey2"
"Microsoft MSX" = "Microsoft - MSX"
"Microsoft MSX2" = "Microsoft - MSX2"
"NEC TurboGrafx 16" = "NEC - PC Engine - TurboGrafx 16"
"Sega 32X" = "Sega - 32X"
"Sega CD" = "Sega - Mega-CD - Sega CD"
"Sega Dreamcast" = "Sega - Dreamcast"
"Sega Game Gear" = "Sega - Game Gear"
"Sega Genesis" = "Sega - Mega Drive - Genesis"
"Sega Master System" = "Sega - Master System - Mark III"
"Sega Pico" = "Sega - PICO"
"Sega Saturn" = "Sega - Saturn"
"Sega SG-1000" = "Sega - SG-1000"
"Sinclair ZX Spectrum" = "Sinclair - ZX Spectrum"
"Sony PlayStation" = "Sony - PlayStation"
"Sony PlayStation 2" = "Sony - PlayStation 2"
"Sony PSP" = "Sony - PlayStation Portable"
"Watara Supervision" = "Watara - Supervision"
"WonderSwan" = "Bandai - WonderSwan"
"WonderSwan Color" = "Bandai - WonderSwan Color"
}
Get-ChildItem "C:/_emu/launchbox/Data/Platforms/" | ForEach-Object {
Write-Host $_
[xml]$xml = Get-Content $_
$platform = [System.IO.Path]::GetFileNameWithoutExtension($_.Name)
$platformRenamed = $PLATFORMS[$platform]
if ($platformRenamed -ne $null) {
$platform = $platformRenamed
}
# --------------------------------------------------------------------------
# Iterate games
# --------------------------------------------------------------------------
$items = @()
$xml.LaunchBox.Game | Where-Object { $_.ApplicationPath -like "*.7z" } | ForEach-Object {
$7z = & 7z l -slt $_.ApplicationPath
$innerPath = $null
$crc = $null
foreach ($line in $7z) {
if ($line -like "Path*") {
if ($line -like "*.cue") {
$innerPath = $null
continue
}
$innerPath = $line.Substring(7)
$crc = $null
}
if ($line -like "CRC*") {
if ($innerPath -eq $null) {
continue
}
$crc = $line.Substring(6)
$item = @{
path = "$($_.ApplicationPath)#$innerPath"
label = [System.IO.Path]::GetFileNameWithoutExtension($_.ApplicationPath)
core_path = "DETECT"
core_name = "DETECT"
crc32 = "$crc|crc"
db_name = "$platform.lpl"
}
$items += $item
}
}
}
if ($items.Count -eq 0) {
return
}
# --------------------------------------------------------------------------
# Write Playlist
# --------------------------------------------------------------------------
$playlist = @{
version = "1.5"
default_core_path = ""
default_core_name = ""
label_display_mode = 0
right_thumbnail_mode = 0
left_thumbnail_mode = 0
thumbnail_match_mode = 0
sort_mode = 0
items = $items
}
$playlist | ConvertTo-Json -Depth 4 | Set-Content -Path "C:/_emu/retroarch/playlists/$platform.lpl"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment