summaryrefslogtreecommitdiff
path: root/update_from_db.py
diff options
context:
space:
mode:
authorSmallJoker <st.rentsch@hotmail.com>2014-08-29 22:02:35 +0200
committerSmallJoker <st.rentsch@hotmail.com>2014-08-29 22:02:35 +0200
commit8d5709661fbd89b4e59aa0f0fa5c49d65569c40d (patch)
tree602be174a127ed171627e09b97401c673f18c989 /update_from_db.py
parent7c25df22dceac0acca1f219baa3bd3269dd55e70 (diff)
Fix dat weird stuff.
Diffstat (limited to 'update_from_db.py')
-rwxr-xr-xupdate_from_db.py42
1 files changed, 21 insertions, 21 deletions
diff --git a/update_from_db.py b/update_from_db.py
index a943000..123b200 100755
--- a/update_from_db.py
+++ b/update_from_db.py
@@ -7,47 +7,47 @@ server = "minetest.fensta.bplaced.net"
skinsdir = "u_skins/textures/"
metadir = "u_skins/meta/"
i = 1
-pages = 0
+pages = 1
c = HTTPConnection(server)
def addpage(page):
global i, pages
- print( "Page: "+str(page))
+ print("Page: " + str(page))
+ r = 0
try:
- c.request("GET","/api/get.json.php?getlist&page="+str(page)+"&outformat=base64")
+ c.request("GET", "/api/get.json.php?getlist&page=" + str(page) + "&outformat=base64")
r = c.getresponse()
except StandardError:
- c.request("GET","/api/get.json.php?getlist&page="+str(page)+"&outformat=base64")
- r = c.getresponse()
- if r.status != 200:
- print("Error", r.status)
- exit(r.status)
+ if r != 0:
+ if r.status != 200:
+ print("Error", r.status)
+ exit(r.status)
data = r.read().decode()
l = json.loads(data)
if not l["success"]:
print("Success != True")
exit(1)
+ r = 0
pages = int(l["pages"])
for s in l["skins"]:
- f = open(skinsdir+"character_"+str(i)+".png",'wb')
+ f = open(skinsdir + "character_" + str(i) + ".png", "wb")
f.write(base64.b64decode(s["img"]))
f.close()
- f = open(metadir+"character_"+str(i)+".txt",'w')
- f.write(s["name"] + '\n')
- f.write(s["author"] + '\n')
- f.write(s["license"])
+ f = open(metadir + "character_" + str(i) + ".txt", "w")
+ f.write(str(s["name"]) + '\n')
+ f.write(str(s["author"]) + '\n')
+ f.write(str(s["license"]))
f.close()
try:
- c.request("GET","/skins/1/"+str(s["id"])+".png")
+ c.request("GET", "/skins/1/" + str(s["id"]) + ".png")
r = c.getresponse()
except StandardError:
- c.request("GET","/skins/1/"+str(s["id"])+".png")
- r = c.getresponse()
- if r.status != 200:
- print("Error", r.status)
- exit(r.status)
+ if r != 0:
+ if r.status != 200:
+ print("Error", r.status)
+ exit(r.status)
data = r.read()
- f = open(skinsdir+"character_"+str(i)+"_preview.png",'wb')
+ f = open(skinsdir + "character_" + str(i) + "_preview.png", "wb")
f.write(data)
f.close()
i = i + 1
@@ -55,4 +55,4 @@ addpage(1)
if pages > 1:
for p in range(pages-1):
addpage(p+2)
-print("Skins have been updated!") \ No newline at end of file
+print("Skins have been updated!")