teeedubb Posted April 10, 2017 Share Posted April 10, 2017 (edited) This is a Python2.7 script to generate RocketLauncher game data ini files from the LaunchBox xml files so that the info displayed in RL's Pause screen is the same as what is in LB. If populated, it will use the 'Title', 'Publisher', 'Developer', 'ReleaseDate', 'Genre', 'StarRating', 'PlayMode', 'Rating', 'WikipediaURL', 'Notes' fields from the LB xml and will skip games with no data. It creates a backup of your existing RL ini files in the RL game data ini folder. RL will overwrite these files on udating, so you will need to run the script after that. Not sure if its possible to work around this. You need to update the two variables to point to the folders that contain the LB and RL data files (beware of the forward slashes). # -*- coding: utf-8 -*- from __future__ import unicode_literals from __future__ import print_function from itertools import izip from HTMLParser import HTMLParser import os import shutil import re import sys import xml.etree.ElementTree as ET try: txt_encode = sys.getfilesystemencoding() except: txt_encode = 'utf-8' reload(sys) sys.setdefaultencoding('utf-8') lb_dir = 'd:/emulation/LaunchBox/Data/Platforms' rl_dir = 'c:/emulation/RocketLauncher/Data/Game Info' ### rl_dir_backup = os.path.join(rl_dir, 'backup') for system in os.listdir(lb_dir): if system.endswith(".xml"): system_name = system[:-4] print(system_name) xml_lb = os.path.join(lb_dir, system) ini_rl = os.path.join(rl_dir, system_name+'.ini') h = HTMLParser() if os.path.exists(ini_rl): if not os.path.exists(rl_dir_backup): os.makedirs(rl_dir_backup) if os.path.exists(os.path.join(rl_dir_backup, system_name+'.ini')): if os.path.exists(os.path.join(rl_dir_backup, system_name+'.ini.old')): os.remove(os.path.join(rl_dir_backup, system_name+'.ini.old')) shutil.move(os.path.join(rl_dir_backup, system_name+'.ini'), os.path.join(rl_dir_backup, system_name+'.ini.old')) shutil.move(ini_rl, rl_dir_backup) tree = ET.parse(xml_lb) root = tree.getroot() lb_label = ['Title', 'Publisher', 'Developer', 'ReleaseDate', 'Genre', 'StarRating', 'PlayMode', 'Rating', 'WikipediaURL', 'Notes'] rl_label = ['Title', 'Publisher', 'Developer', 'Released', 'Genre', 'Score', 'Players', 'Rating', 'Url', 'Description'] with open(ini_rl, 'w') as f: for game in root.findall('Game'): info_game = '' for lbl,rll in izip(lb_label, rl_label): if game.find(lbl) != None and game.find(lbl).text: if rll == 'Title': info = '[' + h.unescape(game.find(lbl).text) + ']' info = info.replace('\r', ' ').replace('\n', ' ') + "\n" info = re.sub(' +', ' ', info) info_game = info_game + info elif rll == 'Released': info = h.unescape(game.find(lbl).text)[:4] info = rll + '=' + info + "\n" info_game = info_game + info else: info = rll + '=' + h.unescape(game.find(lbl).text) info = info.replace('\r', ' ').replace('\n', ' ') + "\n" info = re.sub(' +', ' ', info) info_game = info_game + info s = ('Publisher', 'Developer', 'Released', 'Genre', 'Players', 'Rating', 'Url', 'Description') if any(x in info_game.encode("utf-8") for x in s): f.write(info_game.encode("utf-8")) f.write("\n") Edited April 10, 2017 by teeedubb 3 Quote Link to comment Share on other sites More sharing options...
johnugamer Posted April 11, 2017 Share Posted April 11, 2017 Just tested this out and it works great. Much better implementation than the default way RocketLauncher creates its game data inis from launchbox. Fixed a couple issues for me, mainly fade screens for mame games now show the actual name of the game, not the zip name. Thanks! 1 Quote Link to comment Share on other sites More sharing options...
teeedubb Posted April 12, 2017 Author Share Posted April 12, 2017 Sweet, thanks for testing. I've posted about keeping the custom ini files through a update in RL and the Devs are talking about implementing it. Quote Link to comment Share on other sites More sharing options...
Styphelus Posted April 14, 2017 Share Posted April 14, 2017 For those of us who don't know anything about programming, how do we use this? 1 Quote Link to comment Share on other sites More sharing options...
teeedubb Posted April 14, 2017 Author Share Posted April 14, 2017 (edited) Save the script above as lb-rl-game-data.py somewhere on your PC, and update the lines beginning with 'lb_dir =' and 'rb_dir =' to point to your launchbox and rocketlauncher game data directories ( a dir full of xml or ini files named the same as platforms in either program). Watch the forward slashes. Download and install Python 2.7. After Python is installed you should be able to simply double click on the lb-rl-game-data.py file, if not, run the following in a cmd prompt (win+r > cmd > enter) "c:\path\to\python.exe" "c:\path\to\lb-rl-game-data.py" Edited April 16, 2017 by teeedubb 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.