Skip to content

Instantly share code, notes, and snippets.

@michaelbertoni
Created May 26, 2020 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelbertoni/a0100b729aa02fcc0f7444cd4f5c8cd9 to your computer and use it in GitHub Desktop.
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.
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