Last active
May 11, 2020 03:43
-
-
Save fessehaye/37fdd65300556545d435e3363ababc38 to your computer and use it in GitHub Desktop.
Sort Slippi files by matchup played
This file contains 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
import os,sys,shutil | |
from slippi import Game | |
from tqdm import tqdm | |
slippiDir = 'C:\\Users\\Simon\\Desktop\\FM-v5.9-Slippi-r18-Win\\Slippi\\' | |
target = 'C:\\Users\\Simon\\Desktop\\slippi\\' | |
def getChars(players): | |
chars = [player.character.name for player in players if player] | |
chars.sort() | |
return "vs".join(chars) | |
def sortToDir(slippiFiles): | |
try: | |
for file in tqdm(slippiFiles): | |
game = Game(file) | |
MUs = getChars(game.start.players) | |
if os.path.exists(target+MUs) is False: | |
os.mkdir(target+MUs) | |
shutil.copy(file, target+MUs) | |
else: | |
shutil.copy(file, target+MUs) | |
except IOError as e: | |
print("Unable to copy file. %s" % e) | |
except: | |
print("Unexpected error:", sys.exc_info()) | |
try: | |
shutil.rmtree(target, ignore_errors=True) | |
os.mkdir(target) | |
slippiFiles = [slippiDir + f for f in os.listdir(slippiDir)] | |
print(str(len(os.listdir(slippiDir))) + " Replay Files in total") | |
print("Sorting Slippi Files for Matchups") | |
sortToDir(slippiFiles) | |
except: | |
print('Error while deleting directory') |
Hey, I tried this on windows with python 3.7.4 and I get this unhelpful error
25 Replay Files in total
Sorting Slippi Files for Matchups
10%|████████████████ | 1/10 [00:00<00:05, 1.59it/s]
Unexpected error: (<class 'KeyError'>, KeyError(85), <traceback object at 0x0000022687918F88>)
any idea what could do this?
Hey just double checking that you replaced line 5-6 with the right directories?
It could potentially be that one of the slp files are corrupt or an older version? try using a few slp files and see if you get the same issue. Let me know if this works!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result