Last active
December 11, 2022 14:47
-
-
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
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
| 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