2014-03-17 06:25:18 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
from http.client import HTTPConnection
|
|
|
|
import json
|
|
|
|
import base64
|
|
|
|
|
|
|
|
server = "minetest.fensta.bplaced.net"
|
|
|
|
skinsdir = "u_skins/textures/"
|
|
|
|
metadir = "u_skins/meta/"
|
|
|
|
i = 1
|
2014-08-29 22:02:35 +02:00
|
|
|
pages = 1
|
2014-03-17 06:25:18 +01:00
|
|
|
|
|
|
|
c = HTTPConnection(server)
|
|
|
|
def addpage(page):
|
|
|
|
global i, pages
|
2014-08-29 22:02:35 +02:00
|
|
|
print("Page: " + str(page))
|
|
|
|
r = 0
|
2014-03-17 06:25:18 +01:00
|
|
|
try:
|
2014-08-29 22:02:35 +02:00
|
|
|
c.request("GET", "/api/get.json.php?getlist&page=" + str(page) + "&outformat=base64")
|
2014-03-17 06:25:18 +01:00
|
|
|
r = c.getresponse()
|
2014-10-08 11:59:03 +02:00
|
|
|
except Exception:
|
2014-08-29 22:02:35 +02:00
|
|
|
if r != 0:
|
|
|
|
if r.status != 200:
|
|
|
|
print("Error", r.status)
|
|
|
|
exit(r.status)
|
2014-10-08 11:59:03 +02:00
|
|
|
return
|
|
|
|
|
2014-03-17 06:25:18 +01:00
|
|
|
data = r.read().decode()
|
|
|
|
l = json.loads(data)
|
|
|
|
if not l["success"]:
|
|
|
|
print("Success != True")
|
|
|
|
exit(1)
|
2014-08-29 22:02:35 +02:00
|
|
|
r = 0
|
2014-03-17 06:25:18 +01:00
|
|
|
pages = int(l["pages"])
|
|
|
|
for s in l["skins"]:
|
2014-08-29 22:02:35 +02:00
|
|
|
f = open(skinsdir + "character_" + str(i) + ".png", "wb")
|
2014-10-05 18:26:25 +02:00
|
|
|
f.write(base64.b64decode(bytes(s["img"], 'utf-8')))
|
2014-03-17 06:25:18 +01:00
|
|
|
f.close()
|
2014-08-29 22:02:35 +02:00
|
|
|
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"]))
|
2014-07-23 13:46:42 +02:00
|
|
|
f.close()
|
|
|
|
try:
|
2014-08-29 22:02:35 +02:00
|
|
|
c.request("GET", "/skins/1/" + str(s["id"]) + ".png")
|
2014-07-23 13:46:42 +02:00
|
|
|
r = c.getresponse()
|
2014-10-08 11:59:03 +02:00
|
|
|
except Exception:
|
2014-08-29 22:02:35 +02:00
|
|
|
if r != 0:
|
|
|
|
if r.status != 200:
|
|
|
|
print("Error", r.status)
|
2014-10-08 11:59:03 +02:00
|
|
|
continue
|
|
|
|
|
2014-07-23 13:46:42 +02:00
|
|
|
data = r.read()
|
2014-08-29 22:02:35 +02:00
|
|
|
f = open(skinsdir + "character_" + str(i) + "_preview.png", "wb")
|
2014-07-23 13:46:42 +02:00
|
|
|
f.write(data)
|
2014-03-17 06:25:18 +01:00
|
|
|
f.close()
|
|
|
|
i = i + 1
|
|
|
|
addpage(1)
|
|
|
|
if pages > 1:
|
|
|
|
for p in range(pages-1):
|
|
|
|
addpage(p+2)
|
2014-08-29 22:02:35 +02:00
|
|
|
print("Skins have been updated!")
|