From d7475852ae530d6bf7c5becbb2f9adf1e431a8dc Mon Sep 17 00:00:00 2001 From: pbsds Date: Sun, 2 Feb 2014 15:42:49 +0100 Subject: [PATCH] Added support for POST form links and made it support converting files through drag and drop in windows explorer. --- UGO.py | 95 +++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 30 deletions(-) diff --git a/UGO.py b/UGO.py index e928a3e..6e916d2 100644 --- a/UGO.py +++ b/UGO.py @@ -11,7 +11,7 @@ # #Note: # The current implentation can possibly mess up the files stored in Section #2, but will do for most needs -# Next version will bring a big change in the ugoxml format +# Next version will probably bring a big change in the ugoxml format # import sys, os from base64 import b64encode, b64decode @@ -136,7 +136,7 @@ class UGO: self.Items.append(("topscreen text", labels, num)) continue elif type == 2:#catogories(like "reccomended" and "new flipnotes" and "most popular") - #this one may change greatly depending on what layout is set in type==0 + #this one may visually change greatly depending on what layout is set in type==0 link = i[1] label = b64decode(i[2]).decode("UTF-16LE") @@ -144,8 +144,12 @@ class UGO: self.Items.append(("category", link, label, selected)) continue - elif type == 3:#POST button? "Post Flipnote" - pass + elif type == 3:#POST button/link to POST form. "Post Flipnote" uses this + link = i[1] + label = b64decode(i[2]).decode("UTF-16LE") + + self.Items.append(("post", link, label)) + continue elif type == 4:#Button link = i[1] trait = int(i[2]) @@ -266,9 +270,13 @@ class UGO: selected = str(1*selected) TableOfContents.append("\t".join(("2", link, label, selected))) - elif i[0] == "post":#not yet implented - pass - elif i[0] == "button": + elif i[0] == "post":#3 + link, label = i[1:] + + label = b64encode(label.encode("UTF-16LE")) + + TableOfContents.append("\t".join(("3", link, label))) + elif i[0] == "button":#4 trait, label, link, other, file = i[1:] trait = str(trait) @@ -313,7 +321,7 @@ class UGO: for i in self.Items: if i[0] == "unknown": - elem = ET.SubElement(ugo_xml, "unknown", type=i[1][0]) + elem = ET.SubElement(ugo_xml, "raw", type=i[1][0]) for value in i[1][1:]: ET.SubElement(elem, "value").text = value continue @@ -339,7 +347,11 @@ class UGO: ET.SubElement(elem, "address").text = link ET.SubElement(elem, "selected").text = str(selected).lower() elif i[0] == "post":#3 - pass#not yet implented/parsed + elem = ET.SubElement(ugo_xml, "post") + link, label = i[1:] + + ET.SubElement(elem, "label").text = label + ET.SubElement(elem, "address").text = link elif i[0] == "button":#4 elem = ET.SubElement(ugo_xml, "button") trait, label, link, other, file = i[1:] @@ -377,9 +389,9 @@ class UGO: Items = [] for elem in ugo_xml: - if elem.tag == "unknown": + if elem.tag == "raw": if "type" not in elem.attrib: - if not silent: print "Invalid formatting. without \"type\" attribute" + if not silent: print "Invalid formatting. without \"type\" attribute" return False values = [elem.attrib["type"]] for value in elem: @@ -454,8 +466,27 @@ class UGO: selected = value.text[0].lower() in "t1" Items.append(("category", link, label, selected)) - elif elem.tag == "post":#3 not yet implented - pass + elif elem.tag == "post":#3 + label = None + link = None + + for value in elem: + if value.tag == "label": + if isinstance(label, str): + if not silent: print "Invalid formatting. Multible