Skip to content

Instantly share code, notes, and snippets.

@Fix3dll
Last active April 24, 2024 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fix3dll/3963c049e068a3dc5312c4930ce5c938 to your computer and use it in GitHub Desktop.
Save Fix3dll/3963c049e068a3dc5312c4930ce5c938 to your computer and use it in GitHub Desktop.
Python script designed for keeps up to date NEU-REPO gemstonecosts.json
import urllib.request, json
items_api = "https://api.hypixel.net/v2/resources/skyblock/items"
with urllib.request.urlopen(items_api) as url:
data = json.load(url)
slot_unlock_cost = {}
for item in data["items"]:
if item.get("gemstone_slots", None): # item have gemstone slots
count = 0
cost_dict = {}
for slot in item.get("gemstone_slots"):
slot_name = slot.get("slot_type") + "_" + str(count) # ex RUBY_2
if slot.get("costs", None): # some slots are already unlocked
gemstones_dict = {}
for cost in slot.get("costs"):
if cost.get("coins", 0) != 0:
gemstones_dict["SKYBLOCK_COIN"] = cost.get("coins", 0)
if (cost.get("item_id", None)):
gemstones_dict[cost.get("item_id")] = cost.get("amount")
while slot_name in cost_dict: # loop for unique slots
count += 1
slot_name = slot.get("slot_type") + "_" + str(count)
count = 0 # clear count
cost_dict[slot_name] = gemstones_dict
slot_unlock_cost[item["id"]] = cost_dict
elif slot.get("slot_type", None):
while slot_name in cost_dict: # loop for unique slots
count += 1
slot_name = slot.get("slot_type") + "_" + str(count)
count = 0 # clear count
cost_dict[slot_name] = []
slot_unlock_cost[item["id"]] = cost_dict
#print(json.dumps(slot_unlock_cost, indent=2, sort_keys=True))
pretty_slot_unlock_cost = {}
for item in slot_unlock_cost:
slot_dict = {}
for slot, cost in slot_unlock_cost[item].items():
cost_list = [] # slot
if len(cost) != 0:
for ingredient, value in cost.items():
cost_list.append("{}:{}".format(ingredient, value))
slot_dict[slot] = cost_list
pretty_slot_unlock_cost[item] = slot_dict
f = open("gemstonecosts.json", "w")
f.seek(0)
f.write(json.dumps(pretty_slot_unlock_cost, indent=2, sort_keys=True))
f.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment