Skip to content

Instantly share code, notes, and snippets.

@ricardo85x
Last active August 8, 2022 00:42
Show Gist options
  • Save ricardo85x/d23a62f589b341c0ba50162372f2cd31 to your computer and use it in GitHub Desktop.
Save ricardo85x/d23a62f589b341c0ba50162372f2cd31 to your computer and use it in GitHub Desktop.
Hide non working roms on EmulationStation DE
from xml.etree import ElementTree as et
# gamelist.xml generated by emulationstation desktop
# ~/.emulationstation/gamelists/mame/gamelist.xml
gamelist_path = r"./gamelist.xml"
# http://adb.arcadeitalia.net/download.php (mame246-gamelist.xml.zip)
mameXXX_gamelist_path = r"./mame246-gamelist.xml"
# list of games to hide
to_hide_roms = []
for _, elem in et.iterparse(mameXXX_gamelist_path, events=("end",)):
if elem.tag == "machine":
# filters
is_bios = True if elem.get("isbios") is not None and elem.get("isbios") == "yes" else False
is_device = True if elem.get("isdevice") is not None and elem.get("isdevice") == "yes" else False
not_runnable = True if elem.get("runnable") is not None and elem.get("runnable") == "no" else False
is_mahjong = elem.find("./input/control[@type='mahjong']") is not None
has_harddisk = elem.find("./device[@type='harddisk']") is not None
has_cdrom = elem.find("./device[@type='cdrom']") is not None
status_preliminary = elem.find("./driver[@status='preliminary']") is not None
emulation_preliminary = elem.find("./driver[@emulation='preliminary']") is not None
if (
is_bios or
is_device or
is_mahjong or
not_runnable or
has_harddisk or # NO CHD
has_cdrom or # NO CHD
status_preliminary or
emulation_preliminary
):
print("To hide", elem.get('name'), " - ", elem.find("description").text)
to_hide_roms.append("./" + elem.get('name') + ".zip")
gamelist_tree = et.parse(gamelist_path)
for current_game in gamelist_tree.findall('.//game'):
path = current_game.find("path")
if path is not None and path.text in to_hide_roms:
print("Hidding", current_game.find('name').text)
if current_game.find("hidden") is not None:
current_game.find("hidden").text = "true"
else:
hidden_element = et.SubElement(current_game, 'hidden')
hidden_element.text = 'true'
et.indent(gamelist_tree, space="\t", level=0)
gamelist_tree.write("./gamelist_edited.xml", encoding="utf-8", xml_declaration=True)
print("\n\gamelist_edited.xml created")
@ricardo85x
Copy link
Author

ricardo85x commented Aug 8, 2022

Created this python3 script to edit the gamelist.xml generated on EmulationStation DE on Steam Deck.

It will add a <hidden>true</hidden> tag on the filtered games.

Filters:

  • rom is a bios
  • rom is a device
  • rom is a mahjong game
  • rom is not runnable
  • rom need a CHD to run
  • rom status is preliminary
  • rom emulation is preliminary

After replacing the gamelist.xml you need to disable the setting Show hidden games (requires restart) from the Other settings menu to make them disappear entirely on emulationstation desktop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment