From 553906b2dad415774ab9eca1585bf59492e17bb5 Mon Sep 17 00:00:00 2001 From: Firepup Sixfifty Date: Tue, 17 Sep 2024 21:31:30 -0500 Subject: [PATCH] Inital Commit --- .gitignore | 1 + update-plugins.py | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 .gitignore create mode 100644 update-plugins.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/update-plugins.py b/update-plugins.py new file mode 100644 index 0000000..5b7c0dc --- /dev/null +++ b/update-plugins.py @@ -0,0 +1,61 @@ +from dotenv import load_dotenv +from os import environ as env +from requests import request + +# Try to load cache +print("[[ Info ]] Trying to load installed versions from cache...") +knownVersions = {} +try: + from cache import knownVersions + print(f"[[ Info ]] Loaded {len(knownVersions)} installed versions from cache...") +except ImportError: + # Fallback to just a warning + print("""[[ Warn ]] Failed to load versions from cache +[[ Warn ]] If this is not your first time running this script, it's recommended you investigate why.""") + +load_dotenv() + +hangarPlugins = { + # "slug-of-plugin": {"Channel": "channel-to-pull", "Version": 'version-to-pull or "latest"'} +} +spigotPlugins = { + # "resource-id-of-plugin": {"Version": 'version-id-to-pull or "latest"'} +} +geyser = True +floodgate = True + +if hangarPlugins and not env.get("HANGAR_KEY", ""): + print( + """!! Notice !! This script cannot download hangar plugins without a hangar api key! +!! Notice !! Please signup for an account at https://hangar.papermc.io/auth/signup +!! Notice !! Then generate an api key with the "view_public_info" permission at https://hangar.papermc.io/auth/settings/api-keys + +!! Notice !! Since there's no hangar api key, the defined list of hangar plugins will be COMPLETELY IGNORED on this run.""" + ) + hangarPlugins = {} + +if hangarPlugins: + for plugin in hangarPlugins: + # check + # download update + # update version storage to match + ... + +if spigotPlugins: + for plugin in spigotPlugins: + version = spigotPlugins[plugin]["Version"] + if spigotPlugins[plugin]["Version"] == "latest": + version = le(request("GET", "https://api.spiget.org/v2/resources/60310/versions/latest").text)["id"] + if not knownVersions.get(plugin, "") or knownVersions[plugin] != version: + # download update + knownVersions[plugin] = version + +if geyser: + # download https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/spigot + ... + +if floodgate: + # download https://download.geysermc.org/v2/projects/floodgate/versions/latest/builds/latest/downloads/spigot + ... + +# write cache file