Created
April 6, 2018 16:56
-
-
Save tristansokol/fbd537a272080440f35411519009514d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def merge(*args, quiet=True): | |
import retro | |
known_hashes = {} | |
for game in retro.list_games(): | |
shafile = os.path.join(retro.get_game_path(game), 'rom.sha') | |
with open(shafile) as f: | |
shas = f.read().strip().split('\n') | |
for ext, platform in retro.EMU_EXTENSIONS.items(): | |
if game.endswith('-' + platform): | |
break | |
for sha in shas: | |
known_hashes[sha] = (game, ext) | |
for rom in args: | |
try: | |
data, hash = groom_rom(rom) | |
except IOError: | |
continue | |
if hash in known_hashes: | |
game, ext = known_hashes[hash] | |
if not quiet: | |
print('Importing', game) | |
with open(os.path.join(retro.get_game_path(game), 'rom%s' % ext), 'wb') as f: | |
f.write(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment