prepping, mostly

This commit is contained in:
Firepup Sixfifty 2024-09-17 23:01:58 -05:00
parent 553906b2da
commit 4ba9e5c452
Signed by: Firepup650
SSH key fingerprint: SHA256:cb8sEJwc0kQJ6/nMUhscWRe35itf0NFMdSKl3v4qt48

View file

@ -1,6 +1,7 @@
from dotenv import load_dotenv from dotenv import load_dotenv
from os import environ as env from os import environ as env
from requests import request from requests import request
from ast import literal_eval as litEval
# Try to load cache # Try to load cache
print("[[ Info ]] Trying to load installed versions from cache...") print("[[ Info ]] Trying to load installed versions from cache...")
@ -19,7 +20,7 @@ hangarPlugins = {
# "slug-of-plugin": {"Channel": "channel-to-pull", "Version": 'version-to-pull or "latest"'} # "slug-of-plugin": {"Channel": "channel-to-pull", "Version": 'version-to-pull or "latest"'}
} }
spigotPlugins = { spigotPlugins = {
# "resource-id-of-plugin": {"Version": 'version-id-to-pull or "latest"'} # "resource-id-of-plugin": {"Version": 'version-id-to-pull or "latest"', "Name": "Friendly name used for local downloads of the plugin"}
} }
geyser = True geyser = True
floodgate = True floodgate = True
@ -36,16 +37,18 @@ if hangarPlugins and not env.get("HANGAR_KEY", ""):
if hangarPlugins: if hangarPlugins:
for plugin in hangarPlugins: for plugin in hangarPlugins:
# check version = hangarPlugins[plugin]["Version"]
# download update if version == "latest":
# update version storage to match version = request("GET", f"https://hangar.papermc.io/api/v1/projects/{plugin}/latest?channel={channel}").text
... if not knownVersions.get(plugin, "") or knownVersions[plugin] != version:
# download update
knownVersions[plugin] = version
if spigotPlugins: if spigotPlugins:
for plugin in spigotPlugins: for plugin in spigotPlugins:
version = spigotPlugins[plugin]["Version"] version = spigotPlugins[plugin]["Version"]
if spigotPlugins[plugin]["Version"] == "latest": if version == "latest":
version = le(request("GET", "https://api.spiget.org/v2/resources/60310/versions/latest").text)["id"] version = litEval(request("GET", f"https://api.spiget.org/v2/resources/{plugin}/versions/latest").text)["id"]
if not knownVersions.get(plugin, "") or knownVersions[plugin] != version: if not knownVersions.get(plugin, "") or knownVersions[plugin] != version:
# download update # download update
knownVersions[plugin] = version knownVersions[plugin] = version