mirror of
https://github.com/RekuNote/Hatenatools3.git
synced 2026-10-30 00:09:13 +00:00
Fixed a lot of indentation discrepancies, so everything should now use tabs and you should be able to expand/unexpand filters to change these locally (sorry about this, I just couldn't get anything to play nice with the code how it was)
This commit is contained in:
1 parent
3431ca85c6
commit
0ef45d240e
2 files changed
+57
-58
No files matched your search
@@ -479,23 +479,23 @@ class TMB:
|
||||
#if ppm: self = ppm
|
||||
|
||||
out = ["PARA",#magic
|
||||
DecAsc(self.AudioOffset-0x6a0, 4, True),#animation data size
|
||||
DecAsc(self.AudioLenght, 4, True),#audio data size
|
||||
DecAsc(self.FrameCount-1, 2, True),#frame count
|
||||
"\x24\x00",#unknown
|
||||
chr(self.Locked), "\0",#locked
|
||||
DecAsc(self.ThumbnailFrameIndex, 2, True),#which frame is in the thumbnnail
|
||||
self.OriginalAuthorName.encode("UTF-16LE") + "\0\0"*(11-len(self.OriginalAuthorName)),#Original Author Name
|
||||
self.EditorAuthorName.encode("UTF-16LE") + "\0\0"*(11-len(self.EditorAuthorName)),#Editor Author Name
|
||||
self.Username.encode("UTF-16LE") + "\0\0"*(11-len(self.Username)),#Username
|
||||
DecAsc(self.AudioOffset-0x6a0, 4, True),#animation data size
|
||||
DecAsc(self.AudioLenght, 4, True),#audio data size
|
||||
DecAsc(self.FrameCount-1, 2, True),#frame count
|
||||
"\x24\x00",#unknown
|
||||
chr(self.Locked), "\0",#locked
|
||||
DecAsc(self.ThumbnailFrameIndex, 2, True),#which frame is in the thumbnnail
|
||||
self.OriginalAuthorName.encode("UTF-16LE") + "\0\0"*(11-len(self.OriginalAuthorName)),#Original Author Name
|
||||
self.EditorAuthorName.encode("UTF-16LE") + "\0\0"*(11-len(self.EditorAuthorName)),#Editor Author Name
|
||||
self.Username.encode("UTF-16LE") + "\0\0"*(11-len(self.Username)),#Username
|
||||
self.OriginalAuthorID.decode("HEX")[::-1],#OriginalAuthorID
|
||||
self.EditorAuthorID.decode("HEX")[::-1],#EditorAuthorID
|
||||
self.OriginalFilenameC,#OriginalFilename
|
||||
self.CurrentFilenameC,#CurrentFilename
|
||||
self.PreviousEditAuthorID.decode("HEX")[::-1],#EditorAuthorID
|
||||
self.PartialFilenameC,#PartialFilename
|
||||
DecAsc(self.Date, 4, True),#Date in seconds
|
||||
"\0\0",#padding
|
||||
DecAsc(self.Date, 4, True),#Date in seconds
|
||||
"\0\0",#padding
|
||||
self.PackThumbnail()]#thumbnail
|
||||
|
||||
return "".join(out)
|
||||
@@ -592,26 +592,26 @@ def WriteImage(image, outputPath):
|
||||
return True
|
||||
|
||||
def get_metadata(flipnote):
|
||||
meta = {
|
||||
u"Current filename":flipnote.CurrentFilename[:-3]+filetype,
|
||||
u"Original filename":flipnote.OriginalFilename[:-3]+filetype,
|
||||
u"Number of frames":flipnote.FrameCount,
|
||||
u"Locked":flipnote.Locked,
|
||||
u"Thumbnail frame index":(flipnote.ThumbnailFrameIndex+1),
|
||||
u"Original author":flipnote.OriginalAuthorName,
|
||||
u"Editor author":flipnote.EditorAuthorName,
|
||||
u"Username":flipnote.Username,
|
||||
u"Original author ID":flipnote.OriginalAuthorID,
|
||||
u"Editor author ID":flipnote.EditorAuthorID,
|
||||
u"Date(seconds since 1'st Jan 2000)":flipnote.Date,
|
||||
u"Date":time.strftime("%H:%M %d/%m-%Y (faulty)", time.gmtime(epoch+flipnote.Date)),
|
||||
}
|
||||
if filetype == "ppm":
|
||||
meta[u"Frame speed"]=flipnote.Framespeed
|
||||
meta[u"Frame speed"]=flipnote.BGMFramespeed
|
||||
meta[u"Looped"]=flipnote.Looped
|
||||
meta = {
|
||||
u"Current filename":flipnote.CurrentFilename[:-3]+filetype,
|
||||
u"Original filename":flipnote.OriginalFilename[:-3]+filetype,
|
||||
u"Number of frames":flipnote.FrameCount,
|
||||
u"Locked":flipnote.Locked,
|
||||
u"Thumbnail frame index":(flipnote.ThumbnailFrameIndex+1),
|
||||
u"Original author":flipnote.OriginalAuthorName,
|
||||
u"Editor author":flipnote.EditorAuthorName,
|
||||
u"Username":flipnote.Username,
|
||||
u"Original author ID":flipnote.OriginalAuthorID,
|
||||
u"Editor author ID":flipnote.EditorAuthorID,
|
||||
u"Date(seconds since 1'st Jan 2000)":flipnote.Date,
|
||||
u"Date":time.strftime("%H:%M %d/%m-%Y (faulty)", time.gmtime(epoch+flipnote.Date)),
|
||||
}
|
||||
if filetype == "ppm":
|
||||
meta[u"Frame speed"]=flipnote.Framespeed
|
||||
meta[u"Frame speed"]=flipnote.BGMFramespeed
|
||||
meta[u"Looped"]=flipnote.Looped
|
||||
|
||||
return meta
|
||||
return meta
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -765,23 +765,22 @@ if __name__ == '__main__':
|
||||
f.write(newline.join(meta).encode("UTF-8"))
|
||||
f.close()
|
||||
elif sys.argv[1] == "-oa":
|
||||
regex = re.compile(sys.argv[2])
|
||||
os.chdir(sys.argv[3])
|
||||
for filename in os.listdir("."):
|
||||
epoch = time.mktime(time.struct_time([2000, 1, 1, 0, 0, 0, 5, 1, -1]))
|
||||
regex = re.compile(sys.argv[2])
|
||||
os.chdir(sys.argv[3])
|
||||
for filename in os.listdir("."):
|
||||
epoch = time.mktime(time.struct_time([2000, 1, 1, 0, 0, 0, 5, 1, -1]))
|
||||
if not os.path.isfile(filename):
|
||||
print "Error!\nSpecified file doesn't exist!"
|
||||
sys.exit()
|
||||
|
||||
if not os.path.isfile(filename):
|
||||
print "Error!\nSpecified file doesn't exist!"
|
||||
sys.exit()
|
||||
filetype = "ppm" if filename[-3:] == "ppm" else "tmb"
|
||||
flipnote = TMB().ReadFile(filename) if filetype == "tmb" else PPM().ReadFile(filename, ReadFrames=False)
|
||||
if not flipnote:
|
||||
continue
|
||||
|
||||
filetype = "ppm" if filename[-3:] == "ppm" else "tmb"
|
||||
flipnote = TMB().ReadFile(filename) if filetype == "tmb" else PPM().ReadFile(filename, ReadFrames=False)
|
||||
if not flipnote:
|
||||
continue
|
||||
|
||||
meta = get_metadata(flipnote)
|
||||
if regex.match(meta["Original author"]):
|
||||
print filename
|
||||
meta = get_metadata(flipnote)
|
||||
if regex.match(meta["Original author"]):
|
||||
print filename
|
||||
|
||||
else:
|
||||
print "Error!\nThere's no such mode."
|
||||
@@ -51,19 +51,19 @@ def DecAsc(dec, length=None, LittleEndian=False):#Converts a decimal into an asc
|
||||
def zipalign(length, r=4):
|
||||
return length + (4 - length % r) if length % r else length
|
||||
def indentXML(elem, level=0):#"borrowed" from: http://effbot.org/zone/element-lib.htm#prettyprint
|
||||
i = "\n" + level*"\t"
|
||||
if len(elem):
|
||||
if not elem.text or not elem.text.strip():
|
||||
elem.text = i + "\t"
|
||||
if not elem.tail or not elem.tail.strip():
|
||||
elem.tail = i
|
||||
for elem in elem:
|
||||
indentXML(elem, level+1)
|
||||
if not elem.tail or not elem.tail.strip():
|
||||
elem.tail = i
|
||||
else:
|
||||
if level and (not elem.tail or not elem.tail.strip()):
|
||||
elem.tail = i
|
||||
i = "\n" + level*"\t"
|
||||
if len(elem):
|
||||
if not elem.text or not elem.text.strip():
|
||||
elem.text = i + "\t"
|
||||
if not elem.tail or not elem.tail.strip():
|
||||
elem.tail = i
|
||||
for elem in elem:
|
||||
indentXML(elem, level+1)
|
||||
if not elem.tail or not elem.tail.strip():
|
||||
elem.tail = i
|
||||
else:
|
||||
if level and (not elem.tail or not elem.tail.strip()):
|
||||
elem.tail = i
|
||||
|
||||
#class UGO:
|
||||
class UGO:
|
||||
|
||||
Reference in new issue
Block a user
