Created
July 11, 2013 02:28
-
-
Save yin8086/5972079 to your computer and use it in GitHub Desktop.
Use {filename:time} dictionary fix the timestamp in pmf file
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
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu Jul 11 09:50:16 2013 | |
@author: Stardrad Yin | |
""" | |
import os, fnmatch, struct | |
timeDic = {'mv00':89, 'mv04':67, 'mv05':102, 'mv06':29, 'mv07':27,\ | |
'mv08':34, 'mv10':21, 'mv12':21} | |
if __name__ == '__main__': | |
path, dirs, names = os.walk('.').next() | |
for curName in (tmpName for tmpName in names if fnmatch.fnmatch(tmpName, '*.pmf')): | |
with open(curName, 'r+b') as fSrc: | |
fName = curName | |
fSrc.seek(0, 2) | |
mpsLen = fSrc.tell() - 0x800 | |
fSrc.seek(0xc) | |
fSrc.write(struct.pack('>I', mpsLen)) | |
timeSt = struct.pack('>I', timeDic[ fName[:-4] ] * 60 * 60 * 30) | |
fSrc.seek(0x5c) | |
fSrc.write(timeSt) | |
fSrc.seek(0x76) | |
fSrc.write(timeSt) | |
print '%s ---- %02d:%02d' % (fName, timeDic[ fName[:-4] ] / 60, timeDic[ fName[:-4] ] % 60) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment