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
+60
-61
No files matched your search
@@ -479,23 +479,23 @@ class TMB:
|
|||||||
#if ppm: self = ppm
|
#if ppm: self = ppm
|
||||||
|
|
||||||
out = ["PARA",#magic
|
out = ["PARA",#magic
|
||||||
DecAsc(self.AudioOffset-0x6a0, 4, True),#animation data size
|
DecAsc(self.AudioOffset-0x6a0, 4, True),#animation data size
|
||||||
DecAsc(self.AudioLenght, 4, True),#audio data size
|
DecAsc(self.AudioLenght, 4, True),#audio data size
|
||||||
DecAsc(self.FrameCount-1, 2, True),#frame count
|
DecAsc(self.FrameCount-1, 2, True),#frame count
|
||||||
"\x24\x00",#unknown
|
"\x24\x00",#unknown
|
||||||
chr(self.Locked), "\0",#locked
|
chr(self.Locked), "\0",#locked
|
||||||
DecAsc(self.ThumbnailFrameIndex, 2, True),#which frame is in the thumbnnail
|
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.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.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.Username.encode("UTF-16LE") + "\0\0"*(11-len(self.Username)),#Username
|
||||||
self.OriginalAuthorID.decode("HEX")[::-1],#OriginalAuthorID
|
self.OriginalAuthorID.decode("HEX")[::-1],#OriginalAuthorID
|
||||||
self.EditorAuthorID.decode("HEX")[::-1],#EditorAuthorID
|
self.EditorAuthorID.decode("HEX")[::-1],#EditorAuthorID
|
||||||
self.OriginalFilenameC,#OriginalFilename
|
self.OriginalFilenameC,#OriginalFilename
|
||||||
self.CurrentFilenameC,#CurrentFilename
|
self.CurrentFilenameC,#CurrentFilename
|
||||||
self.PreviousEditAuthorID.decode("HEX")[::-1],#EditorAuthorID
|
self.PreviousEditAuthorID.decode("HEX")[::-1],#EditorAuthorID
|
||||||
self.PartialFilenameC,#PartialFilename
|
self.PartialFilenameC,#PartialFilename
|
||||||
DecAsc(self.Date, 4, True),#Date in seconds
|
DecAsc(self.Date, 4, True),#Date in seconds
|
||||||
"\0\0",#padding
|
"\0\0",#padding
|
||||||
self.PackThumbnail()]#thumbnail
|
self.PackThumbnail()]#thumbnail
|
||||||
|
|
||||||
return "".join(out)
|
return "".join(out)
|
||||||
@@ -592,26 +592,26 @@ def WriteImage(image, outputPath):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def get_metadata(flipnote):
|
def get_metadata(flipnote):
|
||||||
meta = {
|
meta = {
|
||||||
u"Current filename":flipnote.CurrentFilename[:-3]+filetype,
|
u"Current filename":flipnote.CurrentFilename[:-3]+filetype,
|
||||||
u"Original filename":flipnote.OriginalFilename[:-3]+filetype,
|
u"Original filename":flipnote.OriginalFilename[:-3]+filetype,
|
||||||
u"Number of frames":flipnote.FrameCount,
|
u"Number of frames":flipnote.FrameCount,
|
||||||
u"Locked":flipnote.Locked,
|
u"Locked":flipnote.Locked,
|
||||||
u"Thumbnail frame index":(flipnote.ThumbnailFrameIndex+1),
|
u"Thumbnail frame index":(flipnote.ThumbnailFrameIndex+1),
|
||||||
u"Original author":flipnote.OriginalAuthorName,
|
u"Original author":flipnote.OriginalAuthorName,
|
||||||
u"Editor author":flipnote.EditorAuthorName,
|
u"Editor author":flipnote.EditorAuthorName,
|
||||||
u"Username":flipnote.Username,
|
u"Username":flipnote.Username,
|
||||||
u"Original author ID":flipnote.OriginalAuthorID,
|
u"Original author ID":flipnote.OriginalAuthorID,
|
||||||
u"Editor author ID":flipnote.EditorAuthorID,
|
u"Editor author ID":flipnote.EditorAuthorID,
|
||||||
u"Date(seconds since 1'st Jan 2000)":flipnote.Date,
|
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)),
|
u"Date":time.strftime("%H:%M %d/%m-%Y (faulty)", time.gmtime(epoch+flipnote.Date)),
|
||||||
}
|
}
|
||||||
if filetype == "ppm":
|
if filetype == "ppm":
|
||||||
meta[u"Frame speed"]=flipnote.Framespeed
|
meta[u"Frame speed"]=flipnote.Framespeed
|
||||||
meta[u"Frame speed"]=flipnote.BGMFramespeed
|
meta[u"Frame speed"]=flipnote.BGMFramespeed
|
||||||
meta[u"Looped"]=flipnote.Looped
|
meta[u"Looped"]=flipnote.Looped
|
||||||
|
|
||||||
return meta
|
return meta
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@@ -765,23 +765,22 @@ if __name__ == '__main__':
|
|||||||
f.write(newline.join(meta).encode("UTF-8"))
|
f.write(newline.join(meta).encode("UTF-8"))
|
||||||
f.close()
|
f.close()
|
||||||
elif sys.argv[1] == "-oa":
|
elif sys.argv[1] == "-oa":
|
||||||
regex = re.compile(sys.argv[2])
|
regex = re.compile(sys.argv[2])
|
||||||
os.chdir(sys.argv[3])
|
os.chdir(sys.argv[3])
|
||||||
for filename in os.listdir("."):
|
for filename in os.listdir("."):
|
||||||
epoch = time.mktime(time.struct_time([2000, 1, 1, 0, 0, 0, 5, 1, -1]))
|
epoch = time.mktime(time.struct_time([2000, 1, 1, 0, 0, 0, 5, 1, -1]))
|
||||||
|
if not os.path.isfile(filename):
|
||||||
if not os.path.isfile(filename):
|
print "Error!\nSpecified file doesn't exist!"
|
||||||
print "Error!\nSpecified file doesn't exist!"
|
sys.exit()
|
||||||
sys.exit()
|
|
||||||
|
filetype = "ppm" if filename[-3:] == "ppm" else "tmb"
|
||||||
filetype = "ppm" if filename[-3:] == "ppm" else "tmb"
|
flipnote = TMB().ReadFile(filename) if filetype == "tmb" else PPM().ReadFile(filename, ReadFrames=False)
|
||||||
flipnote = TMB().ReadFile(filename) if filetype == "tmb" else PPM().ReadFile(filename, ReadFrames=False)
|
if not flipnote:
|
||||||
if not flipnote:
|
continue
|
||||||
continue
|
|
||||||
|
|
||||||
meta = get_metadata(flipnote)
|
meta = get_metadata(flipnote)
|
||||||
if regex.match(meta["Original author"]):
|
if regex.match(meta["Original author"]):
|
||||||
print filename
|
print filename
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print "Error!\nThere's no such mode."
|
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):
|
def zipalign(length, r=4):
|
||||||
return length + (4 - length % r) if length % r else length
|
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
|
def indentXML(elem, level=0):#"borrowed" from: http://effbot.org/zone/element-lib.htm#prettyprint
|
||||||
i = "\n" + level*"\t"
|
i = "\n" + level*"\t"
|
||||||
if len(elem):
|
if len(elem):
|
||||||
if not elem.text or not elem.text.strip():
|
if not elem.text or not elem.text.strip():
|
||||||
elem.text = i + "\t"
|
elem.text = i + "\t"
|
||||||
if not elem.tail or not elem.tail.strip():
|
if not elem.tail or not elem.tail.strip():
|
||||||
elem.tail = i
|
elem.tail = i
|
||||||
for elem in elem:
|
for elem in elem:
|
||||||
indentXML(elem, level+1)
|
indentXML(elem, level+1)
|
||||||
if not elem.tail or not elem.tail.strip():
|
if not elem.tail or not elem.tail.strip():
|
||||||
elem.tail = i
|
elem.tail = i
|
||||||
else:
|
else:
|
||||||
if level and (not elem.tail or not elem.tail.strip()):
|
if level and (not elem.tail or not elem.tail.strip()):
|
||||||
elem.tail = i
|
elem.tail = i
|
||||||
|
|
||||||
#class UGO:
|
#class UGO:
|
||||||
class UGO:
|
class UGO:
|
||||||
|
|||||||
Reference in new issue
Block a user
