2020-06-07 13:39:57 +02:00
|
|
|
import sys, requests, base64
|
|
|
|
|
2023-05-10 21:41:35 +02:00
|
|
|
# filename seperator to use, either default "-" or ".". see skinsdb/textures/readme.txt
|
|
|
|
#fsep = "_"
|
|
|
|
fsep = "."
|
|
|
|
|
2020-09-06 13:29:59 +02:00
|
|
|
|
|
|
|
|
2023-09-06 16:39:11 +02:00
|
|
|
print("Downloading skins from skinsdb.terraqueststudio.net ...")
|
2020-06-07 13:39:57 +02:00
|
|
|
# Requesting all skins and their raw texture using the API
|
2023-09-06 16:39:11 +02:00
|
|
|
r = requests.get('http://skinsdb.terraqueststudios.net/api/v1/content?client=script&page=1&per_page=10000')
|
2020-06-07 13:39:57 +02:00
|
|
|
|
|
|
|
if r.status_code != 200:
|
|
|
|
sys.exit("Request failed!")
|
|
|
|
|
|
|
|
data = r.json()
|
|
|
|
count = 0
|
|
|
|
|
2023-09-06 16:39:11 +02:00
|
|
|
print("Writing skins")
|
2020-09-06 13:29:59 +02:00
|
|
|
|
|
|
|
|
2020-06-07 13:39:57 +02:00
|
|
|
for json in data["skins"]:
|
2020-09-10 11:08:49 +02:00
|
|
|
id = str(json["id"])
|
2020-09-06 13:29:59 +02:00
|
|
|
|
|
|
|
# Texture file
|
|
|
|
raw_data = base64.b64decode(json["img"])
|
2023-05-10 21:41:35 +02:00
|
|
|
file = open("../textures/character" + fsep + id + ".png", "wb")
|
2020-09-06 13:29:59 +02:00
|
|
|
file.write(bytearray(raw_data))
|
|
|
|
file.close()
|
|
|
|
|
|
|
|
# Meta file
|
|
|
|
name = str(json["name"])
|
|
|
|
author = str(json["author"])
|
|
|
|
license = str(json["license"])
|
|
|
|
file = open("../meta/character_" + id + ".txt", "w")
|
|
|
|
file.write(name + "\n" + author + "\n" + license + "\n")
|
|
|
|
file.close()
|
|
|
|
print("Added #%s Name: %s Author: %s License: %s" % (id, name, author, license))
|
|
|
|
count += 1
|
|
|
|
|
2020-06-07 13:39:57 +02:00
|
|
|
|
|
|
|
print("Fetched " + str(count) + " skins!")
|