Skip to content

Instantly share code, notes, and snippets.

@QbeRoot
Last active December 11, 2022 14:47
Show Gist options
  • Select an option

  • Save QbeRoot/fb9e91f5ca393411450856dc322b42ca to your computer and use it in GitHub Desktop.

Select an option

Save QbeRoot/fb9e91f5ca393411450856dc322b42ca to your computer and use it in GitHub Desktop.
A Python script that parses a Dolphin TAS Movie (DTM) file and extracts its rerecord count
import os
import sys
def main():
if len(sys.argv) != 2:
print('Usage: {} <DTM file path>'.format(sys.argv[0]), file=sys.stderr)
sys.exit()
path = sys.argv[1]
try:
with open(sys.argv[1], 'rb') as dtm:
if dtm.read(4).hex() != '44544d1a':
print('{} is not a valid DTM file'.format(path), file=sys.stderr)
sys.exit()
dtm.seek(0x2D)
rerecords = int.from_bytes(dtm.read(4), 'little')
except EnvironmentError:
print('Failed to read {}'.format(path), file=sys.stderr)
sys.exit()
print('Rerecords: {}'.format(rerecords))
sys.stdout.flush()
os.system('pause')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment