Replace skinsdb API source (#91)

The old API is no longer reachable, thus got replaced.
This also removes the obsolete skin preview download because the mod is capable of generating them automatically.

Co-authored-by: CallMeDax <142984237+CallMeDax@users.noreply.github.com>
This commit is contained in:
wsor4035
2023-09-06 10:39:11 -04:00
committed by GitHub
parent d3c7fa71c0
commit 271c109073
2 changed files with 5 additions and 25 deletions

View File

@ -4,12 +4,11 @@ import sys, requests, base64
#fsep = "_"
fsep = "."
download_preview = ( len (sys.argv) > 1 and sys.argv[1] == "with_preview" )
print("Downloading skins from minetest.fensta.bplaced.net ...")
print("Downloading skins from skinsdb.terraqueststudio.net ...")
# Requesting all skins and their raw texture using the API
r = requests.get('http://minetest.fensta.bplaced.net/api/v2/get.json.php?getlist&page=1&per_page=999999999')
r = requests.get('http://skinsdb.terraqueststudios.net/api/v1/content?client=script&page=1&per_page=10000')
if r.status_code != 200:
sys.exit("Request failed!")
@ -17,10 +16,7 @@ if r.status_code != 200:
data = r.json()
count = 0
if download_preview:
print("Writing to file and downloading previews ...")
else:
print("Writing skins")
print("Writing skins")
for json in data["skins"]:
@ -42,17 +38,5 @@ for json in data["skins"]:
print("Added #%s Name: %s Author: %s License: %s" % (id, name, author, license))
count += 1
if download_preview:
# Downloading the preview of the skin
r2 = requests.get('http://minetest.fensta.bplaced.net/skins/1/' + id + ".png")
if r2.status_code == 200:
# Preview file
preview = r2.content
file = open("../textures/character_" + id + fsep + "preview.png", "wb")
file.write(bytearray(preview))
file.close()
else:
print("Failed to download skin preview #" + id)
print("Fetched " + str(count) + " skins!")