diff --git a/README.md b/README.md index 1d5c9eb..4b9dc3a 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,9 @@ This Minetest mod offers changeable player skins with a graphical interface for ## Installing skins -### Download from the database +### Download from the [database](http://minetest.fensta.bplaced.net/) + +#### Ingame Downloader 1) Get Minetest 5.1.0-dev-cb00632 or newer 2) Start your world @@ -28,6 +30,16 @@ This Minetest mod offers changeable player skins with a graphical interface for You might want to run `minetest` in a Terminal/Console window to check the log output instantly. +#### Python Download script + +**Requirements:** + + * Python 3 + * `requests` library: `pip3 install requests` + +Go to the updater folder of this mod and run `python3 update_skins.py` +The Script will download all the skins from the database for you. + ### Manual addition 1) Copy your skin textures to `textures` as documented in `textures/readme.txt` diff --git a/updater/update_skins.py b/updater/update_skins.py new file mode 100644 index 0000000..f898148 --- /dev/null +++ b/updater/update_skins.py @@ -0,0 +1,44 @@ +import sys, requests, base64 + +print("Downloading skins from minetest.fensta.bplaced.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') + +if r.status_code != 200: + sys.exit("Request failed!") + +data = r.json() +count = 0 + +print("Writing to file and downloading previews ...") +for json in data["skins"]: + id = str(json["id"]) + # Downloading the preview of the skin + r2 = requests.get('http://minetest.fensta.bplaced.net/skins/1/' + id + ".png") + if r.status_code == 200: + preview = r2.content + # Read meta datas + name = str(json["name"]) + author = str(json["author"]) + license = str(json["license"]) + # Texture file + raw_data = base64.b64decode(json["img"]) + file = open("../textures/character_" + id + ".png", "wb") + file.write(bytearray(raw_data)) + file.close() + # Preview file + file = open("../textures/character_" + id + "_preview.png", "wb") + file.write(bytearray(preview)) + file.close() + # Meta file + 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 + + else: + print("Failed to download skin #" + id) + + +print("Fetched " + str(count) + " skins!")