Skip to content

Commit

Permalink
Replace skinsdb API source (#91)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
wsor4035 and dax-er authored Sep 6, 2023
1 parent d3c7fa7 commit 271c109
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
8 changes: 2 additions & 6 deletions skins_updater.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ if #internal.errors > 0 then
end

-- http://minetest.fensta.bplaced.net/api/apidoku.md
local root_url = "http://minetest.fensta.bplaced.net"
local page_url = root_url .. "/api/v2/get.json.php?getlist&page=%i&outformat=base64" -- [1] = Page#
local preview_url = root_url .. "/skins/1/%i.png" -- [1] = ID
local root_url = "http://skinsdb.terraqueststudios.net"
local page_url = root_url .. "/api/v1/content?client=mod&page=%i" -- [1] = Page#

local mod_path = skins.modpath
local meta_path = mod_path .. "/meta/"
Expand Down Expand Up @@ -100,9 +99,6 @@ local function safe_single_skin(skin)
skins_path .. name .. ".png",
core.decode_base64(skin.img)
)
fetch_url(preview_url:format(skin.id), function(preview)
unsafe_file_write(skins_path .. name .. skins.fsep .. "preview.png", preview)
end)
core.log("action", ("%s: Completed skin %s"):format(_ID_, name))
end

Expand Down
22 changes: 3 additions & 19 deletions updater/update_skins.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,19 @@
#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!")

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"]:
Expand All @@ -42,17 +38,5 @@
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!")

0 comments on commit 271c109

Please sign in to comment.