Created
May 26, 2020 17:15
-
-
Save michaelbertoni/a0100b729aa02fcc0f7444cd4f5c8cd9 to your computer and use it in GitHub Desktop.
Livesplit - Add an offset to all the splits game time of a run.
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
from datetime import datetime, timedelta | |
from xml.dom import minidom | |
file_name = "Portal 2 - first run.lss" | |
lss_file = minidom.parse(file_name) | |
game_times = lss_file.getElementsByTagName('GameTime') | |
for game_time in game_times: | |
string_game_time = game_time.firstChild.data[0:8] | |
t = datetime.strptime(string_game_time,'%H:%M:%S') | |
delta = timedelta(hours=t.hour, minutes=t.minute, seconds=t.second, microseconds=t.microsecond) | |
offset_delta = timedelta(minutes=4, seconds=41, microseconds=130000) | |
new_time = delta + offset_delta | |
print(new_time) | |
game_time.firstChild.data = new_time | |
with open(file_name, "w") as xml_file: | |
lss_file.writexml(xml_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment